Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
17 views2 pages

AssignmentPgms3 5

Uploaded by

pradeep hebbare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

AssignmentPgms3 5

Uploaded by

pradeep hebbare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

C program to check weather the given character is 'uppercase', 'lowercase' or

special character

#include <stdio.h>
int main()
{
char ch;

/* Input character from user */


printf("Enter any character: ");
scanf("%c", &ch);

if(ch >= 'A' && ch <= 'Z')


{
printf("'%c' is uppercase alphabet.", ch);
}
else if(ch >= 'a' && ch <= 'z')
{
printf("'%c' is lowercase alphabet.", ch);
}
else if(ch >= '0' && ch <= '9')
{
printf("'%c' is digit.", ch);
}
else
{
printf("'%c' is special character.", ch);
}

return 0;
}

4.C program to find the reverse of a number and check for palindrome.

#include <stdio.h>

int main()
{
int num, temp, remainder, reverse = 0;

printf("Enter an integer \n");


scanf("%d", &num);
/* original number is stored at temp */
temp = num;
while (num > 0)
{
remainder = num % 10;
reverse = reverse * 10 + remainder;
num /= 10;
}
printf("Given number is = %d\n", temp);
printf("Its reverse is = %d\n", reverse);
if (temp == reverse)
printf("Number is a palindrome \n");
else
printf("Number is not a palindrome \n");
return 0;
}

5.C program to print prime numbers between two numbers

#include <stdio.h>
int main(){
int number1,number2,i,j,flag;
printf("enter the two intervals:");
scanf("%d %d",&number1,&number2);
printf("prime numbers present in between %d and %d:",number1,number2);
for(i=number1+1;i<number2;i++){// interval between two numbers
flag=0;
for(j=2;j<=i/2;++j){ //checking number is prime or not
if(i%j==0){
flag=1;
break;
}
}
if(flag==0)
printf("\n%d",i);
}
return 0;
}

You might also like