Thread: Do-While error in code

  1. #1
    Registered User
    Join Date
    Aug 2015
    Posts
    2

    Do-While error in code

    Could someone help in finding the error in the following code


    Code:
    #include<iostream.h> #include<conio.h> void main() { int choice,choiceexit,np,num,rev=0,digit; do { cout<<"What do you want to check?\n1.Palindrome\n2.Armstrong No.\nPerfect No.\n"; cin>>choice; if(choice==1) { cout<<"Enter your number \n"; cin>>num; np=num; while(num>0) { digit=num%10; rev=(rev*10)+digit; num=num/10; } cout<<"Reverse is "<<rev; if(np==rev) { cout<<"\n It is a palindrome \n"; } else if(np!=rev) { cout<<"\n It is not a palindrome \n"; } cout<<"Do you want to continue?? (1=yes | 0=no)"; cin>>choiceexit; } } while(choiceexit!=0) getch(); }
    I am getting the error:
    Do statement must have a while
    Last edited by Jyotinder; 08-24-2015 at 09:34 AM.

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Apply neat and consistent indentation and formatting to your code, and the problem will become apparent.

  3. #3
    Registered User
    Join Date
    Aug 2015
    Posts
    2
    I have been trying for hours, but am not able to locate the error....

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Check for missing semicolons.

    You should also think about finding a more modern compiler. Any compiler that accepts an include file of <iostream.h> should be replaced.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. code error
    By nadji in forum C Programming
    Replies: 4
    Last Post: 06-25-2012, 10:03 AM
  2. Error in code
    By Waqas Asad in forum C Programming
    Replies: 4
    Last Post: 02-18-2012, 08:09 AM
  3. Help with code, I can't seem to fix the error
    By saszew in forum C Programming
    Replies: 2
    Last Post: 11-13-2008, 08:28 PM
  4. Code Error
    By kbat82 in forum C Programming
    Replies: 13
    Last Post: 11-13-2008, 03:05 PM
  5. Code error
    By DeepFyre in forum C++ Programming
    Replies: 9
    Last Post: 12-27-2004, 01:32 AM