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 ; }

14th Feb 2019, 11:35 AM
Puluko Sibanda
Puluko Sibanda - avatar
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.
14th Feb 2019, 11:44 AM
HonFu
HonFu - avatar
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
14th Feb 2019, 11:56 AM
Puluko Sibanda
Puluko Sibanda - avatar
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.
14th Feb 2019, 12:02 PM
HonFu
HonFu - avatar
0
Thanks it worked
14th Feb 2019, 5:39 PM
Puluko Sibanda
Puluko Sibanda - avatar