//Palindrome
#include<iostream.h>
#include<conio.h>
void
main()
{
clrscr();
int
num,rev=0,rem,i;
cout<<"ENTER
A NUMBER:";
cin>>num;
for(i=num;i>0;i=i/10)
{
rem=i%10;
rev=rev*10+rem;
}
if(rev==num)
cout<<"NUMBER IS
PALINDROME";
else
cout<<"NUMBER IS NOT A PALINDROME";
getch();
}
9. Program
to find sum of natural numbers up to 100.
//
Sum of natural numbers
#include<iostream.h>
#include<conio.h>
void
main()
{
clrscr();
int
sum=0,i;
for
(i=0;i<=100;i++)
sum=sum+i;
cout<<"Sum
of Natural Numbers up to100="<<sum;
getch();
}
No comments:
Post a Comment