program:
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
main()
{
char str[100],ch;
int n=0;i=0,j,m;
printf("enter the line of text:");
do
{
scanf("%c",&str[i]);
ch=str[i];
i++;
}
while(ch!='/n');
//checking strlen(str);
for(i=0;i<n;i++)
{
ch=str[i];
if(!isalnum(ch))
{
switch(ch)
{
case '+':if(str[i+1]=='+')
{
printf("\n ++ is an arithematic operator");
i=i+1;
}
else
printf("/n +is arithmetic operator");
break;
case '-':if(str[i+1]=='-')
{
printf("\n -- is an arithematic operator");
i=i+1;
}
else
printf("/n - is arithmetic operator");
break;
case '*':printf("\n * is an arithematic operator");
break;
case '/':printf("\n / is an arithematic operator");
break;
case '%':printf("\n % is an arithematic operator");
break;
case '/':printf("\n / is an arithematic operator");
break;
case '%':printf("\n % is an arithematic operator");
break;
case '<':if(str[i+1]=='=')
printf("\n <= is an relational operator");
i=i+1;
}
else
printf("/n < is relational operator");
break;
case '>':if(str[i+1]=='=')
{
printf("\n >= is an relational operator");
i=i+1;
}
else
printf("/n > is relational operator");
break;
case '=':if(str[i+1]=='=')
{
printf("\n == is an relational operator");
i=i+1;
}
else
printf("/n = is assignment operator");
break;
case '|':if(str[i+1]=='|')
{
printf("\n || is an logical operator");
i=i+1;
}
else
printf("/n | is bitwise operator");
break;
case '&':if(str[i+1]=='&')
{
printf("\n && is an logical operator");
i=i+1;
}
else
printf("/n & is bitwise operator");
break;
}
}
}
}
}
}
No comments:
Post a Comment