By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,037 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,037 IT Pros & Developers. It's quick & easy.

can anyone please tell me what is wrong with this programme i wrote?

P: 2
i just started learning C, but after i finished writing this programme, it wouldn't respond to the number that i had entered. can anyone please tell me what is going on? thx!
Attached Images
File Type: jpg Screen Shot 2015-09-25 at 2.49.46 AM.jpg (33.4 KB, 175 views)
Sep 24 '15 #1
Share this Question
Share on Google+
4 Replies


P: 22
It works for me. What exactly is the problem you are facing. Better initialize all the local variables i, num1, num2 to 0.
Sep 25 '15 #2

P: 2
I've been unable to enter any values once i started running the program, it happened to some of my other programs too.
Sep 26 '15 #3

P: 1
you need to put your case in parenthesis
case 1:
{
num1=....
num2=.....
printf.....
}

break;
also try to initialize all int to zero
like this
i=num1=num2=0;
Oct 12 '15 #4

Expert 100+
P: 2,400
  1. Catch and print the return value from scanf (at least for debugging purposes).
  2. Terminate your puts strings with newline ('\n'). This is helpful when stdio uses buffered I/O.
  3. Notice that if the number is even you fall out of main rather than loop back to enter a new value.
Putting braces around the cases won't change anything.
Oct 14 '15 #5

Post your reply

Sign in to post your reply or Sign up for a free account.