Professional Documents
Culture Documents
Programming Logic
Final Exam
Submitted by: Amarjot Kaur Bhambra
2) What is the difference between equal to (==) and Assignment Operator (=)?
Answer:
1
Amir Ghasemi
The difference between equal to (==) and Assignment Operator (=) is as
follows:
Assignment operator is used to assign a value to the variable whereas equal to
operator is used to compare two values.
Example pf assignment operator is : a=2. In this 2 is the value that is assigned
to the variable a using = operator.
Example of equal to operator is : 10==10. In this the result will be true as both
the values are same. Another example is 10==5 that will return the result false
because both values are not same.
3) There are several syntax errors in the following program. Fix the errors and
run the program.
2
Amir Ghasemi
Answer:
3
Amir Ghasemi
4) Write a program that prompts the user to input the radius of a circle and
outputs the area and circumference of the circle. The formula is :
• Area = pi × radius2
• Circumference = 2 × pi × radius
Answer:
4
Amir Ghasemi
5) Write a program that prompts the user to input the length and the width of a
rectangle and outputs the area and circumference of the rectangle.
The formula is
Area = Length × Width
Circumference = 2 × ( Length + Width)
Answer:
5
Amir Ghasemi
Answer:
6
Amir Ghasemi