Академический Документы
Профессиональный Документы
Культура Документы
& TECHNOLOGY
COMPILER LAB
(ECS - 653)
Submitted to:
Submitted by:
NEETIKA GUPTA
0813310047 (CS 6 A)
PROGRAM 1
#include<stdio.h>
#include<conio.h>
void main()
char *str;
int i,l,flag=0;
clrscr();
scanf("%s",str);
l = strlen(str);
for(i= 0;i<l;i++)
if(str[i]>=97&&str[i]<=122)
flag = 1;
break;
}
if (flag==1)
else
getch();
}
OUTPUT:
PROGRAM 2
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
char *str;
int i,l,flag=0;
clrscr();
printf("Enter a String:");
scanf("%s",str);
l=strlen(str);
for(i= 0;i<l;i++)
if(str[i]>=96&&str[i]<=97)
flag = flag+1;
if(flag==l)
getch();
}
OUTPUT:
PROGRAM 3
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
char *str;
int i,l,flag=0;
clrscr();
scanf("%s",str);
l=strlen(str);
if((str[l-1]==98)&&(str[l-2]==98)&&(str[l-3]==97))
flag=3;
for(i = 0;i<l-3;i++)
flag = flag+1;
}
if(flag==l)
printf("String valid");
else
printf("String invalid");
getch();
}
OUTPUT:
PROGRAM 4
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
int i,l,flag=0,flag2=0;
char str[10];
clrscr();
printf("Enter a String:");
scanf("%s",str);
l=strlen(str);
flag=1;
for(i=1;i<l;i++)
flag=flag+1;
}
if(flag==l)
printf("String is identifier");
flag=1;
if(str[1])
flag=0;
if(flag ==1)
flag=1;
for(i=1;i<l;i++)
if(str[i]=='.')
flag2=flag2+1;
if(flag2<=1)
flag=flag+1;
if(flag!=l )
printf("String invalid");
getch();
}
OUTPUT: