Some More Questions On Unit1,2,3
Some More Questions On Unit1,2,3
1) Explain how the result of an expression changes if you use the prefix increment operator
(++x) instead of the postfix increment operator ( x++). Provide a specific example to
illustrate the difference.
2) Write a small C program that calculates the area of a rectangle and the area of a circle using
arithmetic operators, and compares the two areas using relational operators.
3) Given the variable x = 10, write a C expression that uses compound assignment operators
to double the value of x and then subtract 5. Explain how each operator works in the
expression.
4) Use parentheses to change the order of operations in the expression a + b * c - d / e.
Explain how each change in the expression affects the result.
5) Write a C program that demonstrates the use of different data types (int, float, char, and
double). Explain how you would initialize and declare each variable and comment on the
memory size each one typically occupies.
6) You are given an integer variable x. Write an expression using arithmetic and relational
operators to check if x is both even and greater than 10, and explain the logic behind your
solution.
7) Demonstrate the use of conditional operator, increment and decrement operator with
example of each.
Unit III
1) Create a program using a switch-case statement that simulates a basic calculator. The
user enters two numbers and selects an operation (addition, subtraction, multiplication, or
division). Implement the program to display the result.
2) Demonstrate the use of decision making/ conditional statement (if else, else if ladder and
nested if else) with example of each.
3) Demonstrate the use of switch statement with syntax and the example of it.
4) Create a program to check whether number is even or odd.
5) Given two integers x and y, write a program to find and print the largest of the two
numbers using an if-else statement.
6) Write a program that reads a student's marks and prints the corresponding grade using an
if-else ladder. Use the following criteria:
Marks >= 90: Grade A
Marks >= 70: Grade B
Marks >= 50: Grade C
Marks < 50: Grade F
7) Write a program to find the largest of three numbers using an if-else ladder.
8) Write a program to find the largest of three numbers using nested if else.
9) Write a for loop that prints all even numbers between 1 and 50.
10) Write a program to find out sum of first n natural numbers.
11) Write a program to print the factorial of a number entered by the user using a while loop.
12) Demonstrate the difference between all three looping statements with proper program.