Sunday 21 December 2014

Q.WAP to read a syring and print out the following:
1]No. of capital alphabets.
2]No. of small alphabets.
3]No. of non-alphabets.

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
void main()
{
clrscr();
char ch[30];
int m=0,n=0,o=0;
cout<<"Input a string:";
gets(ch);
for(int i=0;ch[i]!='\0';i++)
{
  if(isupper(ch[i]))
  m++;
  if(islower(ch[i]))
  n++;
  if(isdigit(ch[i]))
  o++;
}
cout<<endl<<"Number of capital alphabets:"<<m;
cout<<endl<<"Number of small alphabets:"<<n;
cout<<endl<<"Number of digits:"<<o;
getch();
}

No comments:

Post a Comment