Activity Stream
48,167 MEMBERS
6758 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1.     
    #1
    Banned
    Website's:
    cityvillehelp.com

    Default 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

    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 program
    prateek 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

  2.   Sponsored Links

  3.     
    #2
    Respected Member
    Bharat's Avatar
    Website's:
    ShineServers.Com Pickadedi.com
    Edit : he corrected himself

  4.     
    #3
    Banned
    Website's:
    cityvillehelp.com
    Hey! 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;

  5.     
    #4
    Banned
    Website's:
    cityvillehelp.com
    Here 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();
    	}

  6.     
    #5
    Banned
    Website's:
    cityvillehelp.com
    @Bharat

    Thanks for your help bro :

  7.     
    #6
    Banned
    Website's:
    cityvillehelp.com
    Can anyone suggest me some questions of C Programming to Develop Logic ?

    please help needed

  8.     
    #7
    The King of Kings
    Website's:
    rukidding.org thetechnews.org

    Smile Well i would use a different method

    Note i code in Dev C++

    Code: 
    #include<stdio.h>
    #include<conio.h>
    #include<string.h>
    
    main()
    {
          
          char a1[20];
          printf("\tEnter the number here : ");
          scanf("%s",&a1);
          printf("\tThe Reverse of the number is %s",strrev(a1));
    getch();      
    }

  9.     
    #8
    Respected Member
    Bharat's Avatar
    Website's:
    ShineServers.Com Pickadedi.com
    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/

  10.     
    #9
    Banned
    Website's:
    cityvillehelp.com
    @bharat
    thanks , i will surely visit that site and learn new things
    Yes, I have books for 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 and cool

  11.     
    #10
    Banned
    Website's:
    cityvillehelp.com
    @ mind freak

    lol

    i asked for the program to reverse the number and not stings hehehehehehe

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. I Find VPS
    By ponsix in forum Hosting Discussion
    Replies: 3
    Last Post: 24th Mar 2012, 08:57 PM
  2. Find solid program transfer files remotely?
    By deelow66 in forum General Discussion
    Replies: 1
    Last Post: 11th Nov 2011, 07:09 AM
  3. Find the cat, LOL
    By cyber-cliff in forum General Discussion
    Replies: 62
    Last Post: 1st Oct 2011, 09:58 PM
  4. Replies: 0
    Last Post: 9th Feb 2011, 04:29 PM
  5. Need some invoice program source code/or program only
    By Nikolasr in forum Webmaster Discussion
    Replies: 2
    Last Post: 1st Feb 2010, 10:55 AM

Tags for this Thread

BE SOCIAL