Program to count uppercase, lowercase, digits and other characters | C++ Programming
Saturday, February 29, 2020//program to count uppercase,lowercase,digits and other charcters
#include<iostream.h>
#include<conio.h>
#include<ctype.h>
#include<stdio.h>
void COUNT(char str[20]);
void main()
{clrscr();
char string[20];
cout<<"\n Enter a string: ";
gets(string);
COUNT(string);
getch();
}
void COUNT(char str[20])
{int upper=0,lower=0,digit=0,other=0;
for(int i=0; str[i]!='\0'; i++)
{
if(isupper(str[i]))
upper++;
else if(islower(str[i]))
lower++;
else if(isdigit(str[i]))
digit++;
else
other++;
}
cout<<"\n Number of uppercase characters = "<<upper;
cout<<"\n Number of lowercase characters = "<<lower;
cout<<"\n Number of digits = "<<digit;
cout<<"\n Number of other characters = "<<other;
}
#include<iostream.h>
#include<conio.h>
#include<ctype.h>
#include<stdio.h>
void COUNT(char str[20]);
void main()
{clrscr();
char string[20];
cout<<"\n Enter a string: ";
gets(string);
COUNT(string);
getch();
}
void COUNT(char str[20])
{int upper=0,lower=0,digit=0,other=0;
for(int i=0; str[i]!='\0'; i++)
{
if(isupper(str[i]))
upper++;
else if(islower(str[i]))
lower++;
else if(isdigit(str[i]))
digit++;
else
other++;
}
cout<<"\n Number of uppercase characters = "<<upper;
cout<<"\n Number of lowercase characters = "<<lower;
cout<<"\n Number of digits = "<<digit;
cout<<"\n Number of other characters = "<<other;
}
0 Comments