Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 5

# 1 .Given number is palendrome or not.

#include<stdio.h>

#include<conio.h>

void main()

int n,s=0,m;

clrscr();

printf("enter any no");

scanf("%d",&n);

m=n;

while(n>0)

r=n%10;

s=s*10+r;

n=n/10;

if(m==n)

printf("the no is palindrome");

else

printf("no is not palindrome");

getch();

}
#2 Given String is Palendrome or not

#include<stdio.h>

#include<string.h>

#define size 26

void main()

char strsrc[size];

char strtmp[size];

clrscr();

printf("\n Enter String:= "); gets(strsrc);

strcpy(strtmp,strsrc);

strrev(strtmp);

if(strcmp(strsrc,strtmp)==0)

printf("\n Entered string \"%s\" ispalindrome",strsrc);

else

printf("\n Entered string \"%s\" is not

palindrome",strsrc);

getch();

#3 Swap the two variable without using temprary variable


void swap(int &x, int &y)

x -= y;

y += x; // y gets the original value of x

x = (y - x); // x gets the original value of y

#4 reverse the given string

#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

char name[25] rev[25];

int i l;

printf( enter the name );


gets(name);

l=strlen(name);

for(i=0;i<l;i++)

name[i]=rev[l-1-i];

i++;

getch();

#5 checking perfect number or not

#include<stdio.h>

#include<conio.h>

main()

int a,b,c,d;
printf("Enter a Number");

scanf("%d", &a);

a=d;

for (int i=1;i<=a-1;i++)

b=n%i; // im not sure if its b= n%i or b=i%n i cant remember which is the right one

if(b==0)

c=c+i;

if(d==a)

printf("Entered Number is perfect number");

else

printf("Entered Number is not perfect");

getch();

You might also like