Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
algorithm of palindrome
0
votes
asked
May 6, 2020
by
M Yogendra Sai
(
120
points)
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
3 Answers
0
votes
answered
May 7, 2020
by
Afloarei Ioana
(
290
points)
edited
May 8, 2020
by
Afloarei Ioana
//Hi, this is c++
#include <iostream>
using namespace std;
long u, n, r, aux;
int main()
{
cin>>n;
aux=n;
r=0;
do{
u=aux%10;
r=r*10+u;
}while(aux>0);
if(n==r){
cout<<"palindrom"<<endl;
}
else
cout<<"no palindrom";
return 0;
}
commented
May 8, 2020
by
Afloarei Ioana
(
290
points)
is it correct?
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
0
votes
answered
May 7, 2020
by
Afloarei Ioana
(
290
points)
//Hi, this is c++
#include <iostream>
using namespace std;
long u, n, r, aux;
int main()
{
cin>>n;
aux=n;
r=0;
do{
u=aux%10;
r=r*10+u;
}while(aux>0);
if(n==r){
cout<<"palindrom"<<endl;
}
else
cout<<"no palidrom";
return 0;
}
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
0
votes
answered
May 13, 2020
by
MatthiasEbert
(
140
points)
cout << "Is your number a palindrome? " << endl;
cout << "---------------------------- " << endl;
/// INPUT
number = -1;
cout << "Input a positive number: ";
cin >> number;
cout << "number= " << number << endl;
if(number <= 0)
{
cout << "not allowed" << endl;
return 1;
}
/// CALCULATION
for ( input = number ; input > 0 ; input /= 10) // cut the last digit from input from right (last out)
{
output=output*10 + input%10; // shift output one digit left and put that cutted digit in (first in)
cout << "input=" << input << " output=" << output << endl; //
}
/// OUTPUT
if(output == number)
{
cout<<"palindrom";
}
else
{
cout<<"no palindrom";
}
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...