Pages

Showing posts with label whether. Show all posts
Showing posts with label whether. Show all posts

Tuesday, February 17, 2015

C Program check whether a number is palindrome or not


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
unsigned long n,num,d,rev=0;
cout<<"Enter any number: ";
cin>>n;
num=n;
do
{
d=n%10;
rev=(rev*10)+d;
n=n/10;
}while(n!=0);
if(num==rev)
cout<<endl<<"Number is Palindrome";
else
cout<<endl<<"Number is not Palindrome";
getch();
}

Read more »

Monday, February 16, 2015

C Program to check whether a String is Palindrome or not

C++ Program to check whether a String is Palindrome or not

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int i,j,len,flag=1;
char a[20];
cout<<"Enter a string:";
cin>>a;

for(len=0;a[len]!=
Read more »

Thursday, February 12, 2015

C program to check whether the given number is palindrome or not


#include<stdio.h>
#include<conio.h>

void main()
{
int n,a,b=0,num;
clrscr(); //to clear the screen
printf("Enter any number:");
scanf("%d",&n);
num=n;

while(n!=0)
{
a=n%10;
b=a+(b*10);
n=n/10;
}
if(num==b)
printf("
The given number is palindrome");

else
printf("
The given number is not palindrome");

getch(); //to clear the screen;
}
Read more »

Wednesday, February 11, 2015

C program to find whether a given character is an alphabet digit or any special character using ASCII values


#include<stdio.h>
#include<conio.h>


void main()
{
    char ch;
    clrscr();    //to clear the screen
    printf("Enter any character:");
    scanf("%c",&ch);
    if((ch>=A&&ch<=Z)||(ch>=a&&ch<=z))
        printf("
You have entered an alphabet");

    else
        if(ch>=0&&ch<=9)
            printf("
You have entered a digit");

        else
            printf("
You have entered a special character");



    getch();    //to stop the screen
}
Read more »