0
Where does 8 come from, when there is no input from the user?
#include <stdio.h> int main () { int a,b,c; printf("Enter the values of a and b") ; scanf("%d%d", &a, &b) ; c=a+b; printf ("The sum is %d", c) ; return 0 ; }
4 Respostas
+ 1
Do you mean if the user fails to input anything?
By only declaring a variable, you basically only 'mark the spot' where you want to store it.
But if you don't put something there (initialize), that spot still contains what was there before - could be anything really.
0
I mean when u run it, it quickly outputs
Enter the values of a and b
The sum is 8, it doesn't ask for user input
0
Have you tried it here on Sololearn only?
Yeah, this place is somewhat special about user input:
You have to put it in the popup window in the beginning and hit submit.
I just tried it - worked!
If you don't input anything though - see what I wrote above.
0
Thanks it worked