NEW1WORD - } else if(str[i]==' ') { state=3; break; } else

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> #include<conio.h> #include<ctype.h> #include<stdlib.h> #include<string.h> void main(void) { clrscr(); c char str[50]; char var; int state=0; printf("Enter a Sentence:"); gets(str); g for(int i=0;i<strlen(str);i++) { if(state!=-1) { switch(state) { case 0: { if(isupper(str[i])) { state=1; break; } else { state=-1; break; } } case 1: { if(islower(str[i])) { state=1; break; } else if(str[i]==' ') { state=3; break; } else if(str[i]==','||str[i]==':'||str[i]==';') { state=4; break; } else if(str[i]=='-') { state=6; break; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
else if(str[i]=='\'') { state=5; break; } else if(str[i]=='.'||str[i]=='!'||str[i]=='?') { state=2; break; } else { state=-1; break; } } case 2: { if(str[i]==' ') { state=3; break; } else { state=-1; break; } } case 3: { if(str[i]>='a' || str[i]<='z') { state=1; break; } else if(str[i]>='A' || str[i]<='Z') { state=5; break; } else if(str[i]>='0' || str[i]<='9') { state=7; break; } else if(str[i]=='0') { state=8; break; } else { state=-1; break; }
Background image of page 2
} case 4: { if(str[i]==' ') { state=3; break; } else { state=-1; break; } } case 5: { if(str[i]>='a' || str[i]<='z') { state=1; break;
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } else if(str[i]==' ') { state=3; break; } else if(str[i]=='.'||str[i]=='!'||str[i]=='?') { state=2; break; } else { state=-1; break; } } case 6: { if(str[i]>='a' || str[i]<='z') { state=1; break; } else if(str[i]>='0' || str[i]<='9') { state=7; break; } else if(str[i]=='0') { state=8; break; } else { state=-1; break; } } case 7: { if(str[i]==' ') { state=3; break; } else if(str[i]=='-') { state=6; break; } else if(str[i]>='0' || str[i]<='9') { state=7; break; } else if(str[i]=='.'||str[i]=='!'||str[i]=='?') { state=2; break; } else { state=-1; break; } } case 8: { if(str[i]==' ') { state=3; break; } else if(str[i]=='-') { state=6; break; } else if(str[i]=='.'||str[i]=='!'||str[i]=='?') { state=2; break; } else { state=-1; break; } } } } else break ; } if(state==2) printf("sentence is correct"); else printf("sentence is incorrect"); getch(); }...
View Full Document

This note was uploaded on 04/23/2010 for the course QWE 2131 taught by Professor Asda during the Spring '10 term at University of Karachi.

Page1 / 5

NEW1WORD - } else if(str[i]==' ') { state=3; break; } else

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online