Define a language for arithmetic expressions that consist of unsigned integer nu
ID: 3925748 • Letter: D
Question
Define a language for arithmetic expressions that consist of unsigned integer numbers and operators +, -, *, and /. An unsigned integer number consists of any number of digits (0 through 9), but contains no leading zeros. For example, 0, 1, 700, 101, 10 are all acceptable integers, but 00, 01, 0009, 0101 are not. An arithmetic expression consists of any number of unsigned integer numbers connected by the four operators. No parenthesis are used.
With a regular expression for the arithmetic expressions defined above.
Transform the NFA to regular grammar.
Explanation / Answer
int main(void)
{
unsigned int num = 0x80000000;
printf("%%d shows: %d, %%u shows: %u ", num, num);
return 0;
}
int first, second, add, subtract, multiply;
float divide;
{
printf("Enter two integers ");
scanf("%d%d", &first, &second);
add = first + second;
subtract = first - second;
multiply = first * second;
divide = first / (float)second; //typecasting
printf("Sum = %d ",add);
printf("Difference = %d ",subtract);
printf("Multiplication = %d ",multiply);
printf("Division = %.2f ",divide);
return 0;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.