*/
#include <stdio.h>
main(){
char ch;
int n=0;
while((ch=getchar()) == '#'){
/*fflush(stdin);
*/
++n;
}
printf("You entered %d characters\n",n);
}
/*
using command for
in nested loop
*/
#include<stdio.h>
main(){
int i,j;
for(i=1;i<=5;i++){
printf("%d - ",i);
for(j=1;j<=i;++j)
printf("%c",'*');
printf("\n");
}
/* scroll back */
i-=2;
for(;i>=1;i--){
printf("%d - ",i);
for(j=1;j<=i;++j)
printf("%c",'*');
printf("\n");
}
}
*/
#include<stdio.h>
main(){
char ch;
int a=0,b=0,c=0,d=0,e=0,f=0,g=0;
printf("Enter a string of characters:");
while((ch=getchar()) != '\n'){
if(ch != ' ')
a++;
else
e++;
if(ch>='A' && ch <='Z'){
d++;
b++;
}
else if(ch>='a' && ch<='z'){
c++;
b++;
}
else if(ch>='0' && ch<='9')
f++;
else
g++;
}
printf("Total no. of chars entered:%d\n",a);
printf("Total no. of alphabets :%d\n",b);
printf("Total no. of lower alphabets:%d\n",c);
printf("Total no. of upper alphabets:%d\n",d);
printf("Total no. of spaces entered:%d\n",e);
printf("Total no. of digits entered:%d\n",f);
printf("Total no. of others entered:%d\n",g);
}
This page created with Netscape Navigator Gold (17/9/1999)