Input a sentence and write a program to find how many capital later, small later digits, spaces and special characters are there.
#include <stdio.h>
#include <conio.h>
void main ( )
{
char nm[80], ch;
int i, ln, ac = 0, as = 0, dg = 0, sp = 0, spl = 0;
clrscr ( );
printf("\n\n\n\t\t Enter a sentence....:"); gets (nm);
for ( ln = 0; nm[ln] != '\0'; ln++ );
for ( i = 0; i < ln; i++ )
{
ch = nm[i];
if ( ch >= 65 && ch <= 90 )
{
ac++;
}
if ( ch >= 97 && ch <= 122 )
{
as++;
}
if ( ch >= 48 && ch <= 57 )
{
dg++;
}
if ( ch == 32 )
{
sp++;
}
}
spl = ln - ( ac + as + dg + sp );
printf("\n\n\n\t\t Capital Later.........: %d ", ac);
printf("\n\n\n\t\t Small Later...........: %d ", as);
printf("\n\n\n\t\t Digits................: %d ", dg);
printf("\n\n\n\t\t Spaces................: %d ", sp);
printf("\n\n\n\t\t Special Characters ...: %d ", spl);
getch ( );
}
Click here to contact us
#include <stdio.h>
#include <conio.h>
void main ( )
{
char nm[80], ch;
int i, ln, ac = 0, as = 0, dg = 0, sp = 0, spl = 0;
clrscr ( );
printf("\n\n\n\t\t Enter a sentence....:"); gets (nm);
for ( ln = 0; nm[ln] != '\0'; ln++ );
for ( i = 0; i < ln; i++ )
{
ch = nm[i];
if ( ch >= 65 && ch <= 90 )
{
ac++;
}
if ( ch >= 97 && ch <= 122 )
{
as++;
}
if ( ch >= 48 && ch <= 57 )
{
dg++;
}
if ( ch == 32 )
{
sp++;
}
}
spl = ln - ( ac + as + dg + sp );
printf("\n\n\n\t\t Capital Later.........: %d ", ac);
printf("\n\n\n\t\t Small Later...........: %d ", as);
printf("\n\n\n\t\t Digits................: %d ", dg);
printf("\n\n\n\t\t Spaces................: %d ", sp);
printf("\n\n\n\t\t Special Characters ...: %d ", spl);
getch ( );
}
Click here to contact us
No comments:
Post a Comment