/* 15. INPUT A STRING AND FIND THE NUMBER OF NUMERIC CHARACTERS,
LOWERCASE AND UPPERCASE ALPHABETIC CHARACTERS RESPECTIVELY
AND ANY OTHER THAN THE ABOVE
*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
#define MAX 50
#define ASCII_0 48
#define ASCII_9 57
#define ASCII_A 65
#define ASCII_Z 90
#define ASCII_a 97
#define ASCII_z 122
void main()
{
char str[MAX];
int i,num=0,low=0,up=0,other=0;
clrscr();
printf("Enter a String : ");
gets(str);
for(i=0;i<strlen(str);i++)
{
if( (int)str[i]>=ASCII_0 && (int)str[i]<=ASCII_9 )
num++;
else if( (int)str[i]>=ASCII_A && (int)str[i]<=ASCII_Z )
up++;
else if( (int)str[i]>=ASCII_a && (int)str[i]<=ASCII_z )
low++;
else
other++;
}
printf("\nThe Number of NUMERIC characters is : %d ",num);
printf("\nThe Number of LOWERCASE characters is : %d ",low);
printf("\nThe Number of UPPERCASE characters is : %d ",up);
printf("\nThe Number of OTHER characters is : %d ",other);
getch();
}
/*
=====OUT PUT=====
Enter a String : KAUNDINYA is born in the year 1981.
The Number of NUMERIC characters is : 4
The Number of LOWERCASE characters is : 15
The Number of UPPERCASE characters is : 9
The Number of OTHER characters is : 7
*/
No comments:
Post a Comment