C-Lang Programss List - If, Switch, Loops, Break and Continue
C-Lang Programss List - If, Switch, Loops, Break and Continue
Contents
S.No. Content Page No.
3. Switch .......................................................................................................................... 4
5. LOOPS—CONCEPT .................................................................................................. 6
0-50 2.90
51-100 3.25
101-150 4.88
151-200 5.63
201-350 7.38
>350 8.38
11. write a program to read the no. of items in each type and generate a bill with the
discount from following data
type cost
saree→2000
shirt→750
pant→1250
shoes→895
2000to<3000→10%
3000to<5000→20%
>=5000→30%
3. Switch
1. write a program to read two no’s and display +or –or *or / or remainder
depending on user choice(menu driven program)
Verify whether the following program can be written with switch or if-else.
3. Write a program for comparing range of no’s
100-95→A
94-75→B
74-40→C
<40→fail.
1. i/p o/p
a → A
B → b
2. verify whether the given character is: alphabet or digit or a special character.
16. Write a program to find the sum of even no’s and sum of odd no’s from 1 to 10
17. Write a program to count number of even numbers from 1 to 10.
18. Write a program to display the even no’s, sum of even no’s, average of even no’s from 1 to
40.
19. Write a program to display odd no’s, sum of odd no’s, average of odd no’s from 1 to 15.
20. Write a program to display odd no’s in horizontal manner and in next line even no’s
from 1 to 10 as follow
output:
13579
2 4 6 8 10
21. Write a program to display even numbers, sum of even numbers, average of even
numbers, odd numbers, sum of odd numbers, average of odd no’s from 1 to 10 as follow:
output:
even no’s: 2 4 6 8 10
sum of even no’s = 30
36. Write a program to consider no. as 123 and display the digits of no. in reverse
order.
o/p:
n = 123
3
2
1
37. Write a program to read a no. and display the digits of that no. in reverse order.
38. Write a program to read a no. and display the digits of that no. in words.
39. Write a program to read a no. and display the digits of that no. in words (in
reverse order).
40. Write a program to find the length of a given no.
41. Write a program to find the reverse of the number (example n=123, output: 321.)
42. Write a program to read a no. and display the no. in words.
43. Write a program to read the sum of digits of a given number.
44. Write a program to find the sum of even digits for a given no.
45. Write a program to find the sum of odd digits for a given no.
46. Write a program to find the sum and average of even and odd digits for a given
no.
47. Write a program to find the sum of digits of a given no. except first and last digits.
48. Write a program to find the sum of first and last.
49. Write a program to find the no. of even and odd digits for a given no.
50. Write a program to read a no. and find whether the given no. is palindrome or
not.
51. Write a program to find given no. is Armstrong no. or not.
52. WAP to find the digital root of a number. (Example: n=1283; o/p: 5)
53. WAP to check whether given number is strong number or not.
1 10
2 9
3 8
4 7
5 6
6 5
7 4
8 3
9 2
10 1
1. Write a program to display as follow (using simple loop and nested loop).
1) 1 2 3 4 5 2) 1 1 1 1 1 3) 1 2 3 4
12345 11111 123
12345 11111 12
12345 11111 1
4) _ _ _ _ 5 5) 5 4 3 2 1
_ _ _4 5 54321 6) 1 0 1 0 1
__345 54321 0 101
_2345 54321 10 1
12345 01
1
7) 1 9) 4
12 8) 4 3 2 1 43
123 321 432
1234 21 4321
12345 1
123456
19) 1
12 20) 4 3 2 1 21) 5 4 3 2 1
123 321 _4321
1234 21 __321
4321 1 ___21
321 23 ____1
21 234
1 2345
29) 1 2 3 4 5 30) 1 1
28) 1 2345 12 21
23 345 123 321
456 45 1234 4321
7 8 9 10 5 123454321
32) 1 1 1 1 1 1 1 33) 1 2 3 4 5 4 3 2 1
31) 1 22222 1234 4321
21 333 123 321
321 4 12 21
4321 1 1
34) 1 1 1 1 1
11111
11111
5. Write a program to read 6 subject marks and display whether the student has
passed in all subjects or not, if the student has failed then display the total no.
of subjects he had failed (note: don’t create variable for each subject). Stop
reading the values if the marks is not in the range of 0 to 100.