Learn to program with c - Part 7 - Looping

preview_player
Показать описание
In this part we learn how to repeat things over and over with aid of looping.
Рекомендации по теме
Комментарии
Автор

21:39 yeah empty range ;) thanks a lot Ash, you are helping me with my CS classes!

ll-szfl
Автор

Really good series you have done here! I find your teaching style really easy to follow and very thorough! I don't programme for work but I am wanting to learn C programming as a hobby. On a different note, can you do a video on how you use ffmpeg to record the sessions?
Kind regards,
Simon

srs
Автор

Ascii number offset, I always wondered why no "getint" function, but this makes sense enough, Thanks!!

JoelGarcia-mljx
Автор

That space after 'Looping' though.. :D :D

msandiip
Автор

I think one thing you weren't clear on: when the first getc is called, and the user enters a 2 digit number, 'c' is being set to the second digit. You were obviously more clear at the second getc. After running the program and entering '55' for example, reading the code is confusing because it is clearly greater than 9, which looks like the error 'invalid number' should have been printed. Also, your foray into the ASCII table was confusing without the previously mentioned information.

macblanelw
Автор

I took me some time finally I could do it:D, Thanks for this excellent explanations a enjoy it a lot. My best wishes to you:D!!

#include <stdio.h>

int main(void)
{
int number = 0;
char c = 0;
int multi = 10;
int sign_type= 1;

while (1)
{
if (c == '-')
{
sign_type = -1;
continue;
}
if (c < '0' || c > '9')
break;
if (c == '\n')
break;
number *= multi;
number += c - '0';
}

printf("Number is: %d\n", number * sign_type);

return 0;
}

angelluna