Bhuvana D T , ESD ,
Assignment - II
1. Develop a C program to perform operations (+,*,-, / and %) on two whole numbers. Identify
suitable data types to represent the numbers and resultant values.
2. Develop a C program to add two operands and store the result in one of the operands using
the addition assignment operator.
3. Write a C program to find the maximum of 2 numbers using Conditional Operator.
4. A C program contains the following declarations and initial assignments: int i= 8, j = 5;
float x = 0.005, y = 0.01; char c = ‘c’, d = ‘d’;
Determine the value of each of the following expressions.
▪ (3*i*j)%(2*d)
▪ (i*j)%(c+2*d) / (x*y)
▪ 5 * (i + j) > 'c'
▪ 2*x+ (y== 0)
▪ (x > y) && (i > 0) || (j < 5)
5. Write a program to find the area and the perimeter of a circle. Take radius “r” as input.(create
a function to find perimeter)
6. Develop a C program to calculate simple interest using the formula I=PTR/100. Display
Interest with two digit precision after decimal point
7. Write a program to check whether a given number is odd or even.
8. Write a C program to check whether the input is digit or alphabet. Print the ASCII number if
it is a digit.
9. Write a program to create a simple calculator to perform Addition, Subtraction,
Multiplication and Division using switch cases. Take the required operation as input from the
user (Write separate functions for arithmetic operations).
10. Write a program to find out the sum of first n natural numbers. Take n as input from the user.
A. Perform using loops
B. Perform using recursion
11. Write a program to check whether the given number is a perfect number or not.
A. number is called a perfect number if the sum of the factors of that number is equal to the
same number. Example: 6 = 1 + 2 + 3 )
12. Write a program to find the sum of numbers in a given range.
13. Write a program to calculate the sum of the digits of a given number.
14. Develop a C program which adds all numbers from 1 to N, except those which are divisible
by five. Implement this using a for loop and continue statement.
15. Develop a C program to find factorial of a number N using for loop.
16. Develop a C program to find the sum of all odd numbers upto N using while loop.
17. Write a Program to find if a given number is Armstrong number.
Hint: (153 = 1^3 + 5^3 + 3^3)
18. Write a program to find whether a given number is palindrome or not.
Functions
1. Write a function to swap contents of two variables using functions.
2. Write a program to print the prime Fibonacci numbers in a given range.
A. using control flow statements
B. using functions
3. Write a program to reverse an integer number. Use recursion.
4. Write a program to find the factorial of a number.
a. Using Functions
b. Using Recursion