•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 401,667 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,627 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 4886 | Replies: 5
![]() |
•
•
Join Date: Nov 2004
Posts: 11
Reputation:
Rep Power: 0
Solved Threads: 0
hi all....I need help with a pragram which i wrote .....Itz to check if a number is palindrome or not using a function...i.e. the program will ask the user to input any number....then if u reverse the number it will give u the same old number then it is a palindrome number....For Example: if the user enters 121 ...then if u reverse it will give u the same number 121..and so 121 is a palindrome number.....The program which i wrote is below:
#include<iostream.h>
int palindrome(int n)
{
int x, m=0;
while(n>0)
{
x=n%10;
m*=10;
m+=x;
n/=10;
}
return m;
}
void main()
int n, y;
cout<<"Enter any number"<<endl;
cin>>n;
y=palindrome(n);
if(n==y)
cout<<"The entered number is a palindrome number "<<endl;
else
cout<<"The entered number is not a palindrome number "<<endl;
}
_______________________________________________________________
The errors of the program are:
:warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
: error C2146: syntax error : missing ';' before identifier 'n'
: fatal error C1004: unexpected end of file found
#include<iostream.h>
int palindrome(int n)
{
int x, m=0;
while(n>0)
{
x=n%10;
m*=10;
m+=x;
n/=10;
}
return m;
}
void main()
int n, y;
cout<<"Enter any number"<<endl;
cin>>n;
y=palindrome(n);
if(n==y)
cout<<"The entered number is a palindrome number "<<endl;
else
cout<<"The entered number is not a palindrome number "<<endl;
}
_______________________________________________________________
The errors of the program are:
:warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
: error C2146: syntax error : missing ';' before identifier 'n'
: fatal error C1004: unexpected end of file found
>>>Extreme<<<
•
•
Join Date: Nov 2004
Posts: 12
Reputation:
Rep Power: 4
Solved Threads: 1
Hi, just wondering what complier you're using. I compiled your code with Borland C++ 5.5.1 and obtained the following error messages.
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
palindrome.cpp:
Error E2141 palindrome.cpp 28: Declaration syntax error
Error E2141 palindrome.cpp 30: Declaration syntax error
Error E2141 palindrome.cpp 32: Declaration syntax error
Error E2303 palindrome.cpp 34: Type name expected
Error E2451 palindrome.cpp 34: Undefined symbol 'n'
Error E2040 palindrome.cpp 36: Declaration terminated incorrectly
Error E2040 palindrome.cpp 40: Declaration terminated incorrectly
Error E2190 palindrome.cpp 45: Unexpected }
*** 8 errors in Compile ***
All that I did next is to correct the very last error. After inserting a brace '{' after line 26 (i.e. after the code 'void main()'), the code compiled without error. I think that's all that you missed.
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
palindrome.cpp:
Error E2141 palindrome.cpp 28: Declaration syntax error
Error E2141 palindrome.cpp 30: Declaration syntax error
Error E2141 palindrome.cpp 32: Declaration syntax error
Error E2303 palindrome.cpp 34: Type name expected
Error E2451 palindrome.cpp 34: Undefined symbol 'n'
Error E2040 palindrome.cpp 36: Declaration terminated incorrectly
Error E2040 palindrome.cpp 40: Declaration terminated incorrectly
Error E2190 palindrome.cpp 45: Unexpected }
*** 8 errors in Compile ***
All that I did next is to correct the very last error. After inserting a brace '{' after line 26 (i.e. after the code 'void main()'), the code compiled without error. I think that's all that you missed.
•
•
•
•
Originally Posted by Extreme
hi all....I need help with a pragram which i wrote .....Itz to check if a number is palindrome or not using a function...i.e. the program will ask the user to input any number....then if u reverse the number it will give u the same old number then it is a palindrome number....For Example: if the user enters 121 ...then if u reverse it will give u the same number 121..and so 121 is a palindrome number.....The program which i wrote is below:
#include<iostream.h>
int palindrome(int n)
{
int x, m=0;
while(n>0)
{
x=n%10;
m*=10;
m+=x;
n/=10;
}
return m;
}
void main()
int n, y;
cout<<"Enter any number"<<endl;
cin>>n;
y=palindrome(n);
if(n==y)
cout<<"The entered number is a palindrome number "<<endl;
else
cout<<"The entered number is not a palindrome number "<<endl;
}
_______________________________________________________________
The errors of the program are:
:warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
: error C2146: syntax error : missing ';' before identifier 'n'
: fatal error C1004: unexpected end of file found
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,693
Reputation:
Rep Power: 18
Solved Threads: 195
if you read back a few replies you'll see the answer to that.
Learning to read compiler output can be a bit tricky but is extremely helpful.
Tutorials and teachers should spend time on it (even though different compilers produce different output the principles remain the same), sadly most don't and just expect everything to compile first time...
Learning to read compiler output can be a bit tricky but is extremely helpful.
Tutorials and teachers should spend time on it (even though different compilers produce different output the principles remain the same), sadly most don't and just expect everything to compile first time...
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- memory management in wndows 2000 (Windows NT / 2000 / XP / 2003)
- Remove Hidden Windows Components (Windows tips 'n' tweaks)
- help with creating and calling a function (C++)
- Help! (C++)
- Help - Most Important Windows Maintenance Tasks (Windows Users Lounge)
- Compiling And Running (Java)
- I had a experience of a website coded in PHP (PHP)
- Error C2228 (C++)
- correct errors in this program (C)
Other Threads in the C++ Forum
- Previous Thread: c.COM
- Next Thread: OnInitUpdate



Linear Mode