[go: up one dir, main page]

0% found this document useful (0 votes)
10 views2 pages

Programs (2)

The document outlines a series of programming tasks across three units, including displaying output, reading and comparing numbers, performing calculations, and implementing classes and functions. Key tasks involve creating programs for matrix handling, bank account management, and inventory systems for a bookshop. Each task emphasizes fundamental programming concepts such as loops, functions, classes, and memory management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Programs (2)

The document outlines a series of programming tasks across three units, including displaying output, reading and comparing numbers, performing calculations, and implementing classes and functions. Key tasks involve creating programs for matrix handling, bank account management, and inventory systems for a bookshop. Each task emphasizes fundamental programming concepts such as loops, functions, classes, and memory management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Write a program to display the following output using a single cout


statement Maths = 90
Physics = 77
Chemistry = 69
2. Write a program to read two numbers from the keyboard and display the larger value on
the screen.
3. Write a program to read the values a, b and c and display x, where x = a / b 3c. Test the
program for the following values: (a) a = 250, b = 85, c = 25 (b) a = 300, b = 70, c = 70
4. Write a function using reference variables as arguments to swap the values of a pair of integers.
5. Write a program to print the following outputs using for
loops 1
22
333
4444
5555
6. An election is contested by five candidates. The candidates are numbered 1 to 5 and the voting
is done by marking the candidate number on the ballot paper. Write a program to read the
ballots and count the vote cast for each candidate using an array variable count. In case, a
number read is outside the range 1 to 5, the ballot should be considered as a <spoilt ballot=
and the program should also count the numbers of <spoilt ballots
7. An electricity board charges the following rates to domestic users to discourage large
consumption of energy:
For the first 100 units 3 60P per unit
For the first 200 units 3 80P per unit
For the first 300 units 3 90P per unit All users are charged a minimum of Rs. 50.00.
If the total amount is more than Rs. 300.00 then an additional surcharge of 15% is added. Write a
program to read the names of users and number of units consumed and print out the charges with names

UNIT-2
1. Write a program to read a matrix of size m*n from the keyboard and display the same on the
screen using function
2. Write a function power() to raise a number m to power n. The function takes a double
value for m and int value for n and returns the result correctly. Use a default value of 2 for n
to make the function to calculate the squares when this argument is omitted. Write a main
that gets the values of m and n from the user to test the function.
3. Define a class to represent a bank account. Include the following members:
Data members: 1. Name of the depositor. 2. Account number. 3. Type of account. 4. Balance
amount in the account.
Member functions: 1. To assign initial values. 2. To deposit an amount. 3. To withdraw an
amount after checking the balance. 4. To display the name and balance. Write a main
program to test the program.
4. Write a class to represent a vector (a series of float
values). Include member functions to perform the
following tasks:
(a) To create the vector.
(b) To modify the value of a given element.
(c) To multiply by a scalar value.
(d) To display the vector in the form (10, 20, 30 …) Write a program to test your class.
5. Create two classes DM and DB which store the value of distances. DM stores distances in
meters and centimeters and DB in feet and inches. Write a program that can read values
for the class objects and add one object of DM with another object of DB. Use a friend
function to carry out the addition operation. The object that stores the results may be a DM
object or DB object, depending on the units in which the results are required. The display
should be in the
format of feet and inches or meters and centimeters depending on the object on display.
UNIT-3
1. A book shop maintains the inventory of books that are being sold at the shop. The list includes
details such as author, title, price, publisher and stock position. Whenever a customer wants a
book, the sales person inputs the title and author and the system searches the list and displays
whether it is available or not. If it is not, an appropriate message is displayed. If it is, then the
system displays the book details and requests for the number of copies required. If the
requested copies are available, the total cost of the requested copies is displayed; otherwise
<Required copies not in stock= is displayed. Design a system using a class called books with
suitable member functions and constructors. Use new operator in constructors to allocate
memory space required

You might also like