C Assignmet.docx
C Assignmet.docx
11.Write a program to obtain the sum of first and last digit in a 4-digit number.
12.
13.
15.
16.
18.
19.Write a program to show the bits of an integer.
20.
The information about colors is to be stored in bits of a char variable called color. The
bit number 0 to 6, each represent 7 colors of a rainbow, i.e. bit 0 represents violet, 1
represents indigo, and so on as given below. Write a program that asks the user to
enter a number and based on this number it reports which colors in the rainbow does
the number represents.
Red Orange Yellow Green Blue Indigo Violet
21.
In an inter-college competition, various sports and games are played between different
colleges like cricket, basketball, football, hockey, lawn tennis, table tennis, carom and
chess. The information regarding the games won by a particular college is stored in bit
numbers 0, 1, 2, 3, 4, 5, 6, 7 respectively of an integer variable called game. The college
that wins in 5 or more than 5 games is awarded the Champion of Champions trophy. If a
number is entered through the keyboard, then write a program to find out whether the
college won the Champion of the Champions trophy or not.
22. The time field in the directory entry is 2 bytes long. Distribution of different bits
which account for hours, minutes and seconds is given below. Write a program which
would receive the two-byte time entry in form of number and print the hours, minutes
and seconds.
HHHHHMMMMMMSSSSS
25.Write a program to determine whether the year is leap or not.
26.Write a program to determine the first day of the year
37.Write a program to determine whether the given character is in caps or not, digit or
a symbol.
38. An Insurance company follows following rules to calculate premium. (1) If a person’s
health is excellent and the person is between 25 and 35 years of age and lives in a city
and is a male then the premium is Rs. 4 per thousand and his policy amount cannot
exceed Rs. 2 lakhs. (2) If a person satisfies all the above conditions except that the sex
is female then the premium is Rs. 3 per thousand and her policy amount cannot exceed
Rs. 1 lakh. (3) If a person’s health is poor and the person is between 25 and 35 years of
age and lives in a village and is a male then the premium is Rs. 6 per thousand and his
policy cannot exceed Rs. 10,000. (4) In all other cases the person is not insured.
39.
44.
54.
56.
57.
58.
59.
60.
61.
62.
63.
64.
66.
67.
68.
69.
70.
71.
72.
//In these questions,handle the upper half and lower half seperately.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.