// THIS IS C CODE SO YOU HAVE TO INSTALL TURBO C OR DEV C++ IN YOUR SYSTEM, // YOU CAN COPY THE CODE AND PASTE IN NOTEPAD OR ANY TEXT EDITOR THEN SAVE WITH " .c " ext. // OR DOWNLOAD THE GIVEN FILE AND COMPILE THAT FILE. CODE : : // MunAvvArHushen // System programming // practical 1 // AIM // WAP TO COUNT THE NUMBER OF DIGITS , // VOVELS , SYMBOLS IN A USER ENTERED STRING #include "stdio.h" #include "conio.h" void main() { char a[20]; // char array ( STRING ) int i,n,cv=0,ci=0,cs=0,cl=0; // init counters variables and loop variables clrscr(); // no need to explain printf("Enter the string :"); scanf("%s",a); // get string from user n=strlen(a); // get string length for FOR loop for(i=0;i<=n;i++) // LOOP to incr the counters { if(a[i]>=65 && a[i]<=90 || a[i]>=97 && a[i]<=122) // condition of A to Z and a to z { cl++; // alphabetic's counter incremented if(a[i]=='A' || a[i]=='E' || a[i]=='I' || a[i]=='O' || a[i]=='U'|| a[i]=='a' || a[i]=='e' || a[i]=='i' || a[i]=='o' || a[i]=='u') { cv++; // vovel's counter incremented } } else if(a[i]>=48 && a[i]<=57) { ci++; // digit's counter incremented } else { cs++; // special char's counter incremented } } printf("\ntotal :%d",n); // printf("\ntotal alphabets are: %d",cl); // printf("\nnumber of vovels are: %d",cv); // PRINTING THE RESULT printf("\nnumber of digits are: %d",ci); // printf("\nnumber of special char are: %d",cs-1); // getch(); } OUTPUT : :
|