#include
#include
void main (void)
{
char a;
printf("enter an alphabet:\n");
scanf("%c",&a);
if((a>='A')&&(a<='Z'))
printf("the character is uppercase\n");
else if((a>='a')&&(a<='z'))
printf("the character is lowercase");
getch();
}
Program to print even numbers up to 400:
# include
# include
void main (void)
{
int a;
for(a=2;a<=400;a=a+2)
{
printf("%d\t",a);
}
getch();
}
program to find out if a number is even or odd
#include
#include
void main (void)
{
int a,b;
printf("enter a number : ");
scanf("%d",&a);
b=a%2;
if(b==0)
{
printf("%d is an even number",a);
}
else if(b==1)
{
printf("%d is an odd number",a);
}
getch();
}
Program to find out if an entered number is prime or not
#include
#include
void main (void)
{
int a,b,c;
printf("enter a number : ");
scanf("%d",&a);
for(b=2;b<=a;b++)
{
c=a%b;
if(c==0)
break;
}
if(a==b||a==1)
printf("the numbr is prime");
else
printf("the number isn't prime");
getch();
}
Program to find the factorial of a number:
#include
#include
int fact (int);
int fact (int n)
{
int a;
if (n==0)
return 1;
else
a= n*fact(n-1);
return (a);
}
void main (void)
{
int a;
printf("enter a number: ");
scanf("%d", &a);
printf("\nthe factorial of %d is %d", a,fact(a));
getch();
}
all the best
No comments:
Post a Comment