0
No output
I am making a add 1 calculator for myself. It says no output and I need help. Thanks. https://code.sololearn.com/cTFms1305yS8/?ref=app
2 ответов
+ 1
1. You need to declare "num" before using it in scanf(). If you try to use it in the same line as its definition, it won't have been declared yet.
2. scanf() reads the value directly into the memory location, so you don't need to assign "num" its return value (which is different from the entered value by the way) anyway. That is also why the ampersand operator & is used.
3. On the other hand, printf() writes the value to the output stream, so you don't need the adress of the variable when displaying it.
4. The format specifier "%ls" matches a wide string, not an integral value. For a normal integer, use "%d" just as in scanf().
If you fix all of the above, it would look something like this:
int main( void )
{
int num = 0;
scanf( "%d", &num );
printf( "%d", num + 1 );
return 0;
}
+ 1
The way you are taking input and printing it is wrong..
Just a little changes and you are done
int num;
scanf("%d",&num);
printf("%d", num + 1);