Programs

Simple programs

Using operators

Using branching constructs
Marks                                                              Grade
90-100%                                                          Print ‘A’
80-90%                                                            Print ‘B’
60-80%                                                            Print ‘C’
Below 60%                                                      Print ‘D’

21.  An electric power distribution company charges its domestic consumers as follows:
Consumption units                                  Rate of Charge
0-200                                                       Rs 0.50 per unit
201-400                                                   Rs 100 + Rs 0.65/unit excess of 200
401-600                                                   Rs 230 + Rs 0.80/unit excess of 400
601& above                                             Rs 390 + Rs 1.00/unit excess of 600

 
Using looping construct
26.  WAP to print the sum of all numbers up to a given number.
a.              Using while
b.              Using do-while
c.              Using for

36.  WAP to convert binary number into decimal number and vice versa.

S= 1 + 1/2! + 1/3! + 1/4! + ...

*
**
***
****
*****

1
12
123
1234
12345

54321
4321
321 
21
1

A
BA
ABA
BABA
ABABA

    *
   ***
  *****
 *******
*********

1234554321
1234    4321
123        321
12            21
1                1

45.  WAP to print the following pattern:
0
12
345
6789

46.  WAP to print Pascal’s triangle.

Arrays
55.  WAP to find the second largest number in the array.

Character Arrays / Strings
65.  WAP to find the frequency of characters in a string.
70.  WAP to reverse the given string.
71.  WAP to check whether the given string is Palindrome or not (using string-handling functions).
72.  WAP to check whether the given string is Palindrome or not (without functions).
73.  WAP to remove all the blank spaces in the character string.
74.  WAP to sort list of names of students in an ascending order.

Functions
81.  WAP to implement strlen (), strcat (),strcpy () using the concept of Functions.

Recursion

Pointers

Structures
92.  Define a structure data type TRAIN_INFO. The type contain
a.       Train No.:      integer type
b.      Train name:     string
c.       Departure Time:  aggregate type TIME
d.      Arrival Time : aggregate type TIME
e.       Start station: string     
f.       End station : string
g.      The structure type Time contains two integer members: hour and minute. Maintain a train timetable and implement the following operations:
1.      List all the trains (sorted according to train number) that depart from a particular section.
2.      List all the trains that depart from a particular station at a particular time.
3.      List all he trains that depart from a particular station within the next one hour of a given time.
4.      List all the trains between a pair of start station and end station.

Union
94.  WAP to find the record of a student having maximum marks from the list of 10 records. Each record has roll no, name, class and marks fields.

File Handling
98.  WAP to compare the contents of two files and determine whether they are same or not.
99.  WAP to check whether a given word exists in a file or not. If yes then find the number of times it occurs.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.