Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Lab 2: Control Statements

Objectives: To know various types of branching statements and looping statements

Write C programming, draw flowchart and also write respective input/output of the following questions.

Branching statements
1. Check the given number is odd or even.
2. Check the input number is divisible by 5 and not divisible by 10.
3. Find out the greatest among four input numbers.
4. Check the given number is negative, positive or zero.
5. Find the greatest and smallest among three numbers.
6. WAP which finds sum, difference and product of two numbers using switch case statement.
7. Make an interactive program that takes an integer (1 to 7) and displays the name of the respective
day on screen (Note: use option 1-Sunday, 2-Monday and so on)

Looping Statements
8. Write a program that takes your name and print the same name 10 times using while loop.
9. Display the series 2,4,6,8,10……………......n using do while loop.
10. Display the series 1 5 9………………. upto 10 terms using for loop.
11. Display the multiplication table of an input number.
12. Calculate cumulative sum upto N. (Note: sum=1+2+3+……..nth terms)
13. Generate the Fibonacci series upto N. (Note: 1,1,2,3,4,5………………………n th terms)
14. Calculate the factorial of given numbers.

Nested looping
15. Display the series : 1 3 5……………upto N using CONTINUE statement.
16. Check the given number is palindrome or not. (Note: 121, 12321, 5555 etc)
17. Check the given number is prime or composite. (Note: a prime number is divisible by itself and one)
18. Find the prime numbers between 1 and 100. (Note: Prime series 1 2 3 5 7 1 1………)
19. If you input n=5, write a program to display the following pyramid:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
20. Write a program to display multiplication table of nth terms (Note: multiplication matrix n*n)
1 2 3…………n
2 4 6…………2n
3 6 9………….2n
n 2n 3n…………Nn

------------------------------------------------- ----------------------------------------------
Prepared By Supervised By
Faculty Member
Name: …………………………………………..

Roll no………. Shift ………..…..Sec ……..

Note: Last date of submission: 10th September 2017

+2 Lab Works: C Programming

You might also like