In: Computer Science
1.Write a new expression similar to the following :
E1= a+b*c+(d*e+f)*g
a)Convert your expression to postfix form.
b) Trace the algorithm Postfix on slide 38 using your expression.
2.Write a new expression similar to the following :
E2= 6*((5+(2+3)*8)+3)
3.Write a program that receives some input values and
a ) Displays these values by pointers, c)Displays their memory addresses.
1) E1= a+b*c+(d*e+f)*g
a) Postfix form:
abc*+de*f+g*+
b)
| Symbol | Postfix String | Stack |
| a | a | |
| + | a | + |
| b | ab | + |
| * | ab | +* |
| c | abc | +* |
| + | abc*+ | + |
| ( | abc*+ | +( |
| d | abc*+d | +( |
| * | abc*+d | +(* |
| e | abc*+de | +(* |
| + | abc*+de* | +(+ |
| f | abc*+de*f | +(+ |
| ) | abc*+de*f+ | + |
| * | abc*+de*f+ | +* |
| g | abc*+de*f+g | +* |
| abc*+de*f+g*+ |
2) E2= 6*((5+(2+3)*8)+3)
a) Postfix form:
6523+8*+3+*
b)
| Symbol | Postfix expression | Stack |
| 6 | 6 | |
| * | 6 | * |
| ( | 6 | *( |
| ( | 6 | *(( |
| 5 | 65 | *(( |
| + | 65 | *((+ |
| ( | 65 | *((+( |
| 2 | 652 | *((+( |
| + | 652 | *((+(+ |
| 3 | 6523 | *((+(+ |
| ) | 6523+ | *((+ |
| * | 6523+ | *((+* |
| 8 | 6523+8 | *((+* |
| ) | 6523+8*+ | *( |
| + | 6523+8*+ | *(+ |
| 3 | 6523+8*+3 | *(+ |
| ) | 6523+8*+3+ | * |
| 6523+8*+3+* |
3)
//Program:
#include<stdio.h>
int main()
{
int x, y; //declaring variables of integer type
int *a, *b; //declaring pointers of integer type
printf("Enter x: ");
scanf("%d",&x); //Taking input from user
printf("\nEnter y: ");
scanf("%d",&y); //Taking input from user
/*assigning pointers to variable*/
a=&x;
b=&y;
printf("\nValue of x: %d", *a); //printing value of x
through pointer a
printf("\nValue of y: %d", *b); //printing value of y
through pointer b
printf("\nMemory address of x: %p", a); //printing
memory address of x
printf("\nMemory address of y: %p", b); //printing
memory address of y
return 0;
}

//Output:
