Results 1 to 10 of 17
-
20th Nov 2011, 07:25 AM #1OPBannedWebsite's:
cityvillehelp.comFind the bug in this C program!
Hello Guys,
I am new in C Programming
I had wrote a code to reverse the number given by the user
but the problem is
When the user inputs number less than 10 it works fine
but just as the user inputs number like 134 or 351 nothing happens
help me what is the problem
here is the program
Code:#include<stdio.h> #include<conio.h> main() { int num=0, revnum=0, temp=0; printf("Program to reverse the number"); printf("\n\nEnter a Number "); scanf("%d",&num); if (num<=10) printf("\nEnter Number Greater than 10\n"); else { while(num!=0) { temp=num%10; revnum=revnum*10+temp; num=num%10; } printf("Reversed Number=%d",revnum); } getch(); }
Please don't write your own new code , i want just to find the bug in the programprateek Reviewed by prateek on . Find the bug in this C program! Hello Guys, I am new in C Programming I had wrote a code to reverse the number given by the user but the problem is When the user inputs number less than 10 it works fine but just as the user inputs number like 134 or 351 nothing happens Rating: 5
-
20th Nov 2011, 07:28 AM #2
Edit : he corrected himself
-
20th Nov 2011, 07:28 AM #3OPBannedWebsite's:
cityvillehelp.comHey! i got it
there was only one silly mitake
i am soo foolish
the mistake was
this
Wrong : num=num%10;
Correct : num=num/10;
-
20th Nov 2011, 07:29 AM #4OPBannedWebsite's:
cityvillehelp.comHere is the working correct program
Code:#include<stdio.h> #include<conio.h> main() { int num=0, revnum=0, temp=0; printf("Program to reverse the number"); printf("\n\nEnter a Number "); scanf("%d",&num); if (num<=10) printf("\nEnter Number Greater than 10\n"); else { while(num!=0) { temp=num%10; revnum=revnum*10+temp; num=num/10; } printf("Reversed Number=%d",revnum); } getch(); }
-
20th Nov 2011, 07:30 AM #5OPBannedWebsite's:
cityvillehelp.com@Bharat
Thanks for your help bro :
-
20th Nov 2011, 07:31 AM #6OPBannedWebsite's:
cityvillehelp.comCan anyone suggest me some questions of C Programming to Develop Logic
?
please help needed
-
20th Nov 2011, 07:34 AM #7The King of KingsWebsite's:
rukidding.org thetechnews.org
-
20th Nov 2011, 07:35 AM #8
This site is nice , i guess it do got some good logical questions as well , or best is to get some book from your library .
http://cquestionbank.blogspot.com/
-
20th Nov 2011, 07:39 AM #9OPBannedWebsite's:
cityvillehelp.com@bharat
thanks , i will surely visit that site and learn new things
Yes, I have booksfor C
@Mind Freak™
Since I am new in C , we haven't yet taught array and also that function strrev
but your coding is very small andcool
-
20th Nov 2011, 07:41 AM #10OPBannedWebsite's:
cityvillehelp.com@ mind freak
lol
i asked for the program to reverse the number and not stingshehehehehehe
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
I Find VPS
By ponsix in forum Hosting DiscussionReplies: 3Last Post: 24th Mar 2012, 08:57 PM -
Find solid program transfer files remotely?
By deelow66 in forum General DiscussionReplies: 1Last Post: 11th Nov 2011, 07:09 AM -
Find the cat, LOL
By cyber-cliff in forum General DiscussionReplies: 62Last Post: 1st Oct 2011, 09:58 PM -
Not Selected for The Program (MEPI- Student Leaders Program)!!
By DoctorX in forum General DiscussionReplies: 0Last Post: 9th Feb 2011, 04:29 PM -
Need some invoice program source code/or program only
By Nikolasr in forum Webmaster DiscussionReplies: 2Last Post: 1st Feb 2010, 10:55 AM
themaCreator - create posts from...
Version 3.47 released. Open older version (or...