#include<stdio.h>
#include<stdlib.h>
int main()
{
int n,i,k,flag=0;
char vari[15],typ[15],b[15],c;
printf("enter the number of variables:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter the variable[%d]:",i);
scanf(" %c",&vari[i]);
printf("enter the
variable-type[%d](float-f,int-i):",i);
scanf(" %c",&typ[i]);
if(typ[i]=='f')
flag=1;
}
printf("\nenter the expression(end with
$)\n");
i=0;
getchar();
while((c=getchar())!='$')
{
b[i]=c;
i++;
}
k=i;
for(i=0;i<k;i++)
{
if(b[i]=='/')
{
flag=1;
break;
}
}
for(i=0;i<n;i++)
{
if(b[0]==vari[i])
{
if(flag==1)
{
if(typ[i]=='f')
{
printf("\nthe datatype is correctly defined..!\n");
break;
}
else
{
printf("\nidentifier %c must be of float type..!\n",vari[i]);
break;
}
}
else
{
printf("\nthe data type is correctly defined..!\n");
break;
}
}
}
return 0
}
OUTPUT:
No comments:
Post a Comment