answersLogoWhite

0

#include

#include

#include

void keyw(char str[10])

{

if(strcmp("for",str)==0)

printf("%s is a keyword",str);

else if(strcmp("while",str)==0)

printf("%s is a keyword",str);

else if(strcmp("char",str)==0)

printf("%s is a keyword",str);

else if(strcmp("int",str)==0)

printf("%s is a keyword",str);

else if(strcmp("if",str)==0)

printf("%s is a keyword",str);

else if(strcmp("else",str)==0)

printf("%s is a keyword",str);

else

printf("%s is an identifier",str);

printf("\n");

}

main()

{

FILE *f1,*f2,*f3;

char c,str[10];

int num[100],ln=0,tvalue=0,i=0,j=0,k=0;

printf("Enter a C program expression");

f1=fopen("input.c","w");

while((c=getchar())!=EOF)

fputc(c,f1);

f1=fopen("input.c","r");

f2=fopen("identifier.txt","w");

f3=fopen("specialchars.txt","w");

while((c=fgetc(f1))!=EOF)

{

if(isdigit(c))

{

tvalue=c-'0';

c=fgetc(f1);

while(isdigit(c))

{

tvalue=tvalue*10+c-'0';

c=fgetc(f1);

}

num[i++]=tvalue;

ungetc(c,f1);

}

else if(isalpha(c))

{

fputc(c,f2);

c=fgetc(f1);

while((isdigit(c))isalpha(c)c==' 'c=='$')

{

fputc(c,f2);

c=fgetc(f1);

}

fputc(' ',f2);

ungetc(c,f1);

}

else if(c==' 'c=='\t');

else if(c=='\n')

ln++;

else

fputc(c,f3);

}

fclose(f1);

fclose(f2);

fclose(f3);

printf("Numbers in the program are \n");

for(j=0;j

printf("%d",num[j]);

printf("\n");

f2=fopen("identifier.txt","r");

k=0;

while((c=fgetc(f2))!=EOF)

{

if(c!=' ')

str[k++]=c;

else

{

str[k]='\0';

keyw(str);

k=0;

}

}

fclose(f2);

f3=fopen("specialchars.txt","r");

printf("The special chars in the pgm are \n");

while((c=fgetc(f3))!=EOF)

printf("%c",c);

printf("\n");

fclose(f3);

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Can you identify the d-block element in the periodic table?

The d-block elements in the periodic table are located in groups 3 to 12. They are transition metals that have partially filled d orbitals.


How many transition elements are there in the periodic table?

There are 38 transition elements in the periodic table.


Where are transition metals located on the periodic table?

The transition metals are located in groups 3 - 12 on the Periodic Table.


Is francium a transition metal?

No, francium is not a transition metal. It belongs to the alkali metal group on the periodic table. Transition metals are found in the d-block of the periodic table.


Where placed keywords in c?

Inside the symbol table of the compiler.


Is sodium a transition metal?

Sodium is an alkali metal, group 1 in the periodic table of Mendeleev (not a transition metal !).NO!


How many elements are classified as transition metals in the periodic table?

There are 38 elements classified as transition metals in the periodic table.


Is lithium a transition element?

No, the Transition Metals are found in Groups III B to II B in the periodic table.


How many elements are in transition metals?

transition metals are not in any groups, however they are elements between group II & III of the periodic table


Where are the transition meatls on the perdioc table?

in the middle


Is chlorine a transition metal?

No, chlorine is not a transition metal. It is a nonmetal element in the halogen group of the periodic table. Transition metals are found in the d-block of the periodic table.


Which is the most unstable species in periodic table among transition and inner transition element?

The most unstable species in the periodic table among transition and inner transition elements is #43 Technetium (Tc). It is so unstable that it does not occur naturally.