click on this link......

LinkGrand.com

Thursday 12 September 2013

program for lowercase and uppercase

Ask the user to enter an alphabetic character. If it is an uppercase character, ask for two numbers and calculate the average of them.
If it is a lowercase character, ask for three numbers and calculate the average of them…

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,p,q,r,avg1,avg2;
char ch;
clrscr();
printf("\nEnter a character: ");
scanf("%c",&ch);
printf("\nThe ascii code is %d\n",ch);
if(ch>=65 && ch<=90)
{
printf("\nIt is an uppercase character\n");
printf("\nEnter two nos\n");
scanf("%d%d",&a,&b);
avg1=(a+b)/2;
printf("\nThe average is %d \n",avg1);
}
else if(ch>96 && ch<=122)
{
printf("\nIt is lowercase character\n");
printf("\nEnter three nos: ");
scanf("%d%d%d",&p,&q,&r);
avg2=(p+q+r)/3;
printf("\nThe average is %d",avg2);
}
else
{
printf("\nIt is a special character");
}
getch();

}

Output1:
Enter a character: g
The ascii code is 103
It is lowercase character.
Enter three nos: 25 36 85
The average is 48

Output 2:
Enter a character: G
The ascii code is 71
It is uppercase character.
Enter three nos: 25 36 
The average is 30

Output 3:
Enter a character: @
The ascii code is 64
It is a special character.

No comments:

Post a Comment