#include <stdio.h>
main()
{
int num_bns, num_ch;
printf("How many brothers and sisters do you have?\n");
scanf("%d",&num_bns);
printf("How many children do you have?\n");
scanf("%d",&num_ch);
printf("You have %d brothers and sisters and %d children.\n",num_bns,num_ch);
fflush(stdin);
getchar();
}
Question1) Now if i enter a alphabet(instead of a number) for num_bns, then the program does something wired while reading num_bns. It doesn't accepts input for 2nd question and finally prints "You have 2 brothers and sisters and 75 childern." WHY DOES IT DO SO?
Question2) If i remove the "&" symbol then while reading num_bns using scanf, the program crashes? WHY DOES IT CRASH?
Glad if you could answer these two questions.
Regards,
Sandy
This post has been edited by sandeepcu: 29 February 2008 - 03:02 AM

New Topic/Question
Reply




MultiQuote



|