Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: amit14 on December 26, 2017, 05:32:23 am
-
actually I am facing a problem in creating a program. I have recently started learning c, and in the code
main()
{
char another;
int num;
do
{
printf("enter a number");
scan("%d", & num);
printf("want to enter another no. y/n");
scanf("%c", &another);
}while(another=='y');
}
the program ends without accepting the value of y or n
I changed the %c to %d, then it accepted the ASCII values of y and n(121 and 110), instead of the letters.
please help me solve this problem
-
Please read and follow the rules in the future.
http://forums.codeblocks.org/index.php/topic,9996.0.html (http://forums.codeblocks.org/index.php/topic,9996.0.html)
Please use code tags in the future
The likely fix of your code; please read up on what a space does in front of "%c" in calling scanf.
Tim S.
-
thanks
it is solved
well there is one more issue
can u explain me how to make a program for counting the no. of +ve, -ve, and zeroes I entered.
-
The line below is a hyperlink follow it!
http://catb.org/~esr/faqs/smart-questions.html (http://catb.org/~esr/faqs/smart-questions.html)
Be sensitive in choosing where you ask your question. You are likely to be ignored, or written off as a loser, if you:
post your question to a forum where it's off topic
post a very elementary question to a forum where advanced technical questions are expected, or vice-versa
cross-post to too many different newsgroups
post a personal e-mail to somebody who is neither an acquaintance of yours nor personally responsible for solving your problem
You will likely be banned or this thread locked because you are still posting off topic questions!
Another link to the rules of this site; that, you seem to be unable to follow!
http://forums.codeblocks.org/index.php/topic,9996.0.html (http://forums.codeblocks.org/index.php/topic,9996.0.html)
Tim S.
-
oh
sorry for this mistake
it means questions related to programming can't be asked on this forum.
then can you suggest me where can I ask these questions
can I inbox you or other users directly
-
can I inbox you or other users directly
Nope, this is an even worse then asking public questions...
-
Topic locked, because it violates our forum rules (http://forums.codeblocks.org/index.php/topic,9996.0.html).