COMPILER DESIGN

ADVANCED TOPICS IN COMPILER DESIGN

CODE GENERATION FOR OBJECT ORIENTED LANGUAGES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Develop an algorithm to input two numbers, add them and output the result.Start read num1, num2 sum <-num1+num2 print sumStopWhat is accomplished by the algorithm above?
A
The algorithm prints the two numbers, calculates the sum and prints the sum
B
The algorithms adds the values stored in num1 and num2 and stores the result in the variable sum
C
The algorithm will not accomplish anything because their is no value.
D
The algorithm stores the result in num1 and num2 and sets it to sum and prints sum
Explanation: 

Detailed explanation-1: -Algorithm: To find the sum and product of two given numbers: Step 1: Read A, B Step 2: Let Sum= A+B Step 3: Let Product=A*B Step 4: Print Sum, Product Step 5: Stop. Ex 2: Develop an algorithm to interchange the values assigned to two variables A and B.

Detailed explanation-2: -Write Pseudocode for adding two given numbers Step 1: Start Step 2: Declare variables num1, num2 and sum. Step 3: Read values for num1, num2. Step 4: Calculate sum=num1+num2 Step 5: Display sum Step 6: Stop 2.

Detailed explanation-3: -printf("Enter two integers: “); scanf("%d %d", &number1, &number2); Then, these two numbers are added using the + operator, and the result is stored in the sum variable. Finally, the printf() function is used to display the sum of numbers. printf("%d + %d = %d", number1, number2, sum);

Detailed explanation-4: -Start. Declare variables num1, num2, and res. Read values for num1 and num2. Add the values of num1 and num2 and assigned the result to a res variable. Print res. Stop. 19-Nov-2022

There is 1 question to complete.