You are on page 1of 7

Amir Ghasemi

Programming Logic
Final Exam
Submitted by: Amarjot Kaur Bhambra

1) What are the various Arithmetic Operators in C++?


Answer:

Arithmetic operators are used to perform arithmetic operations on variables and


data. ,
Example: a + b, the + operator is used to add two variables a and b . Similarly,
there are various other arithmetic operators in C++ like Subtraction, Multiplication,
Division, Modulus,Increment and decrement Operator.

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.

*/ What's wrong with this program? /*


#include stdio.h
int main();
}
int a,b,c \* Three integers */
a = 3
b = 4
c = a + b
printf("The value of c is %d" , C);
return 0;
}

2
Amir Ghasemi

The possible output:

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

The possible output:

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)

The possible output:

Answer:

5
Amir Ghasemi

6) Write a program in C++ to print the following pattern.

The possible output:

Answer:

6
Amir Ghasemi

You might also like