CSE 110 Computer Programming Sessional
Practice Problems (Week 2)
Subtopics: Data types, constants and variables, operators and expressions,
type conversion, branching, for loops.
1. Write a program that takes as input an integer n and prints out the sum of
integers from 1 to n. Here, 1 ≤ ≤ 2 − 1.
2. Know about precedence and associativity. Follow this link.
3. Comment about the output of the following code snippet.
int main(){
unsigned int i=10;
if(i>-1){
printf("Yes");
}
else printf("No");
}
4. Write a C program that takes a real number and prints the ceiling of that
number.
5. Write a C program that takes a real number and rounds the number and prints
the rounded value.
6. Write a C program that takes a real number and prints the ceiling of that number
up to n digits.
7. Assume that you are given 2 two-digit numbers. Read each of the digits as
characters and print out the summation of the two numbers.
8. Write a C program print total number of days in a month using switch case.
9. Write a C program to check whether an alphabet is vowel or consonant using
switch case.
10.Write a C program that takes as input the date of birth of two persons and prints
weather the first person is older that the second one.
11.Write a C program that takes as input the x and y coordinates of 3 points.
Your program should find out if we can draw a circle where one of the points is
the center and the others are on the circle.
12.Write a C program that takes a year as input and prints whether it is leap year or
not.
13.Write a program to determine the grade based on an input number. The grades
chart is given below:
Marks Obtained Grade
80 or above A+
75 - 79 A
70 - 74 A-
65 - 69 B+
60 - 64 B
0 - 59 D
14. Write a program that takes two integers x and n and computes .
15. Write a program to compute the factorial of a number n.
16. Write a program prints the results of the following series. Here, n is an input to
your program,
a. 1 + 2 + 3 + ⋯ +
b. + + + ⋯+
17. Write a program to print the following pyramids with “*” characters. Take the
number of rows n as input.
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
N=5 N=5
*
* *
* *
* *
* * * * * * * * *
N=5