0% found this document useful (0 votes)
3 views1 page

Week1 La

The document contains a C program that reads an algebraic expression from the user and identifies its components. It separates and prints identifiers (alphabetic characters), operators (such as +, -, *, /, ^), and constants (numeric values) from the input string. The program utilizes functions from the ctype.h library to check character types.

Uploaded by

Sharanya Avudari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Week1 La

The document contains a C program that reads an algebraic expression from the user and identifies its components. It separates and prints identifiers (alphabetic characters), operators (such as +, -, *, /, ^), and constants (numeric values) from the input string. The program utilizes functions from the ctype.h library to check character types.

Uploaded by

Sharanya Avudari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <ctype.

h>int main() { char str[100],ch; int i=0; printf("Enter an


algebraic expression: "); scanf("%s", str); printf("Identifiers: ");
for(int i = 0; str[i] != '\0'; i++) { if(isalpha(str[i])) {
printf("%c ", str[i]); } } printf("\nOperators: "); for(int i = 0;
str[i] != '\0'; i++) { if(str[i] == '+' || str[i] == '-' || str[i] == '*'
|| str[i] == '/' || str[i] == '^') { printf("%c ", str[i]);
} } printf("\nConstants: "); while ((ch = str[i++]) != '\0') {
if (isdigit(ch)) { printf("%c", ch); while
(isdigit(str[i])) { printf("%c", str[i++]); }
printf(" "); } }����return�0;}

You might also like