// 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 : : #include<stdio.h> #include<ctype.h> #include<string.h> void keyw(char *p); int i=0,id=0,kw=0,num=0,op=0; char keys[32][10]={"auto","break","case","char","const","continue","default","do","double","else", "enum","extern","float","for","goto","if","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while"}; main() { char ch,str[25],seps[15]=" \t\n,;(){}[]#\"<>",oper[]="!%^&*-+=~|.<>/?"; int j; char fname[50]; FILE *f1; clrscr(); printf("enter file path (drive:\\fold\\filename)\n"); scanf("%s",fname); f1 = fopen(fname,"rw"); if(f1==NULL) { printf("file not found"); exit(0); } while((ch=fgetc(f1))!=EOF) { for(j=0;j<=14;j++) { if(ch==oper[j]) { printf("%c is an operator\n",ch); op++; str[i]='\0'; keyw(str); } } for(j=0;j<=14;j++) { if(i==-1) break; if(ch==seps[j]) { if(ch=='#') { while(ch!='>') { printf("%c",ch); ch=fgetc(f1); } printf("%c is a header file\n",ch); i=-1; break; } if(ch=='"') { do { ch=fgetc(f1); printf("%c",ch); }while(ch!='"'); printf("\b is an argument\n"); i=-1; break; } str[i]='\0'; keyw(str); } } if(i!=-1) { str[i]=ch; i++; } else i=0; } printf("Keywords: %d\nIdentifiers: %d\nOperators: %d\nNumbers: %d\n",kw,id,op,num); getch(); return 0; } void keyw(char *p) { int k,flag=0; for(k=0;k<=31;k++) { if(strcmp(keys[k],p)==0) { printf("%s is a keyword\n",p); kw++; flag=1; break; } } if(flag==0) { if(isdigit(p[0])) { printf("%s is a number\n",p); num++; } else { if(p[0]!='\0') { printf("%s is an identifier\n",p); id++; } } } i=-1; } OUTPUT : :
// 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 : : #include "stdio.h" #include "conio.h" #include "string.h" void main() { char ue[20]; char pe[20]; char sy[20]=""; int i; clrscr(); while(1) { printf("Enter username:"); scanf("%s",&ue); printf("Enter password:"); scanf("%s",&pe); for(i=0;i<strlen(pe);i++) { strcat(sy,"*"); } if( !(strcmp(ue,pe)) ) { printf("Username and password is correct\n"); printf("Welcome %s password is : %s ",ue,sy); break; } else { printf("Invalid username or password"); printf("\nEnter again\n"); } } getch(); } please Enter username and paswword same,, OUTPUT : :
// 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 : :
|