0% found this document useful (0 votes)
24 views4 pages

Practice Questions

The document contains a set of practice problems for a B.Tech course in C++ programming at the Indian Institute of Space Science and Technology. It includes 33 programming tasks that cover various fundamental concepts such as data types, calculations, input/output, and string manipulation. Each problem is designed to enhance the programming skills of the students by applying C++ concepts in practical scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views4 pages

Practice Questions

The document contains a set of practice problems for a B.Tech course in C++ programming at the Indian Institute of Space Science and Technology. It includes 33 programming tasks that cover various fundamental concepts such as data types, calculations, input/output, and string manipulation. Each problem is designed to enhance the programming skills of the students by applying C++ concepts in practical scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Indian Institute of Space Science and Technology

Thiruvananthapuram - 695 547


Practice Problems
B.Tech - II Semester
MA122V - Fundamentals of C++ Programming
Date : 21/02/2025 Time: 01.45 pm to 04.30 pm

Attempt all questions

1. Write a program that stores the integers 50 and 100 in variables, and stores the
sum of these two in a variable named total.
2. Write a program that computes the tax and tip on a restaurant bill for a customer
with a |250.67 meal charge. The tax should be 6.75 percent of the meal cost. The
tip should be 20 percent of the total after adding the tax. Display the meal cost,
tax amount, tip amount, and total bill on the screen.
3. You have been given a job as a programmer in Infosys software company. In
order to accomplish some calculations, you need to know how many bytes
the following data types use: char, int, float, and double. You do not have any
manuals, so you can’t look this information up. Write a C++ program that will
determine the amount of memory used by these types and display the information
on the screen.
4. A car with a 60 litres petrol tank averages 12.5 km per litre when driven in the
city and 16.5 km per litre when driven on the highway. Write a program that
calculates and displays the distance the car can travel on one tank of petrol
when driven in the city and when driven on the highway.
5. Write a program to implement cin object to take input for an integer.
6. Write a program for adding two numbers and printing the result.
7. Write a program to swap the values of given two numbers using another variable
to temporarily store the value as we swap the variables data.
8. Write a program to convert Fahrenheit to Celcius. On the Celcius scale, water
freezes at 0◦ C and boils at 100◦ C. On the Fahrenheit scale, water freezes at 32◦ F
and boils at 212◦ F.
9. Write a program to calculate Simple and Compound Interest. Take inputs for
Principal, Rate of Interest and Number of years. Print the Simple and Compound
interest.

1
10. Write a program that asks the user for an angle, entered in radians. The program
should then display the sine, cosine, and tangent of the angle. (Use the sin,
cos, and tan library functions to determine these values.) The output should be
displayed in fixed-point notation, rounded to four decimal places of precision.
11. There are three seating categories at a stadium. For a softball game, Class A
seats cost |120 , Class B seats cost |90, and Class C seats cost |60. Write a
program that asks how many Stadium tickets for each class of seats were sold,
then displays the amount of income generated from ticket sales. Format your
rupees amount in a fixed-point notation with two decimal points and make
sure the decimal point is always displayed.
12. Write a program to take a number as input from the user and compute the
factorial of the given number.
13. Write a program to take a number as input from the user and print the sum of
digits present in that number as output.
14. Write a program to take input for the number for the length of Fibonacci sequence.
Print all the Fibonacci sequence till the number.
15. Write a program to take a number n as input from the user and calculate the
1 1 1
series + + · · · + .
2! 4! n!
16. Write a program to print all the numbers which are divisible by 4 in the range
from 4 to 100. For example, the program should print 4, 8, 12, 16, · · · , 100.
17. Write a program to take number of rows as input from the user and to print the
following vertically symmetric pattern on the computer screen.

*
* *
* * *
* *
*

2
18. Write a program to take number of rows as input from the user and to print the
following symmetric pattern on the computer screen.

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

19. Write a program to take a number as input from the user and to check if it is an
Armstrong number.
Note: Armstrong number is a number whose sum of cube of digits is same as
the number itself.
For example take 153, 13 + 53 + 33 = 153 itself.
20. Write a program to find sum and average of n numbers using array of n elements.
21. Write a program to find minimum value in the array. Take an input for the size
of the array and read the elements into the array.
22. Write a program to arrange n numbers in the ascending order. Take an input
for array size n and read the elements into the array.
23. Write a program to calculate length of the string using character array.
24. Write a program to compute the reverse of a string.
25. Write a program to calculate the multiplication of matrices using arrays.
26. Write a program which accepts any digit number as input from the user and
print the number in the word format.
For example, if the user inputs as 1265, the output of the program must be one
Two Six Five.
27. Write a program to read an array of n integers to reverse the order of elements
in the array without using any temporary array.
28. Write a program to accept two strings as input from the user and to perform
concatenation of two strings. For example, if the user enters the first string as
Narendra and the second string as Modi the result of the program should be
NarendraModi. Store the concatenated string in a character array named c.

3
29. Write a prgram to calculate the result of following expression if X and Y are two
collections each containing n integers.
v¯ ¯
n n
u¯ n
X X u¯ X ¯¯
X i + Yi − t¯ X i ¯
i =1 i =1
¯i =1 ¯

30. Write a program to take an array as input from the user and to rotate the elements
of the array in the right direction by accepting the rotation factor as input from
the user.
Suppose, the original array given as input to the program is as follows:

10 20 30 40 50
Array a
0 1 2 3 4
If we apply a right rotation to the array, the state of the array after one cycle of
rotation will be:

Array a 20 30 40 50 10
After two cycle of rotation,
Array a 30 40 50 10 20

31. Write a program to take a string as input from the user and to convert the string
into uppercase. For example, if the user enters the string as hello123 the output
must be HELLO123. Note that the numerical part in the string should not be
affected; only the lowercase alphabets must be translated to uppercase.
32. Write a program to take a sentence as input from the user and to determine
the frequency of a particular character in a sentence. The program should take
a sentence as well as a charactrer as input from the user and should print the
count of times the character occurs in a sentence. Count of character includes
upper or lowercase.
33. Write a program to take a sentence as input from user and to reverse the occurence
of words in the sentence. For example, if user enters the string as "I like Computer
Programming" it should print
"Programming Computer like I".

***END***

You might also like