Leap Year

WAP to find whether given year is a Leap Year

#include
#include
main()
{
int y;
clrscr();
printf("\n enter the year\n ");
scanf("%d",&y);
if(y%4==0)
{
if(y%100==0)
{
if(y%400==0)
{
printf(" common year");
if(y%1000==0)
{
if(y%4000==0)
printf(" common year");
}}}
else
printf(" leap year");
}
else
printf(" common year");
getch();
}

Palindrome - String

check whether the given string is a palindrome

#include < stdio.h>
#include < conio.h>
#include < string.h>
main()
{
char a[20],b[20]="";
int i,l,j;
clrscr();
printf("ENTER THE STRING:");
gets(a);
l=strlen(a);
for(i=0;i{
b[i]=a[l-i-1];
}
j=strcmp(a,b);
if(j==0)
printf("palindrom");
else
printf("not palindrom");
getch();
}

Amstong no

Find whether given no is an Amstrong no?


#include < stdio.h>
#include < conio.h>
main()
{
int i,j,a,k=0;
clrscr();
printf("\n enter the no:");
scanf("%d",&i);
a=i;
while(i!=0)
{
j=i%10;
k=k+(j*j*j);
i=i/10;
}
if(k==a)
printf("amstrong no");
else
printf("not an amstrong no");
getch();
}