You are on page 1of 11

Assignment-1

1. Write a program in C++ to perform the following.

a) Area of a circle b) Circumference of a circle c) Area of a triangle

d) Area of a rectangle

2. Write a program in C++ to find the simple interest for a given principal, rate of
interest and number of years.
3. Write a program in C++ to enter a character and print the next four letter of the
alphabet.

4. Write a program in C++ to solve a quadratic equation.

5. Develop a program in C++ to read a set of five real numbers from the keyboard and
to find out their sum and average.

6. Write a program in C++ to read the name, age, height and weight of a student and to
display with proper heading for each variable.

7. Write a program in C++ to accept a single character from the keyboard. Using cout to
display the character or keystroke and its decimal, hexadecimal and octal values.

Display in the following format:

CHARACTER DECIMAL HEXADECIMAL OCTAL

------ ------ ------ ------

----- ------ ------ ------


Assignment-2

1. Write a program in C++ to find the square and cubes of the numbers from 1 to 100
using
(i) if-then-else (ii) for loop

(iii) while loop (iv)do-while loop

The output should be as follows:

Number Square Cubes

-----------------------------

-----------------------------

2. Write a program in C++ that print the following format:-

&&&&&&&&

&&&&&&

&&&&

&&

0
101
21012
3210123
432101234
54321012345

6543210123456

A
B C
D E F
G H I J
K L M N O

3. Write a program in C++ that will print all the numbers less than 2000 that are evenly
divisible by 10 using

(i) if-then –else and go to statement (ii) for loop

(iii) while loop (iv) do-while loop

The output should be like 10 20 30… fulfilling sincerely

4. Write a program in C++ to find the sum of the following series using

(i)for loop (ii) while loop (iii) do-while loop


(iv) goto statement (v) continue statement

1. Sum = 1+2+3+…+n
2. Sum = 1+3+5+…+n
3. Sum = 1+2+4+… +n
4. sum = 1+ 1/1! + 2/ 2! +3/3! …n/n!
5. sum = x + x2/2! + x4/4! + x6/6! +…xn/n!
6. sum = x- x3/3! +x5/5!– x7/7! +… xn/n!
7. sum = 12 + 22 + 32 + 42 + …..n2
8. sum = 13-23+ 33-43+ ….-n2
9. sum =1+22 + 42 + ……n2
10.sum =1-32 + 52- ……+n2

Assignment-3
1. Write a program In C++ to generate the following series of numbers:
(i)
11
2112
321123
43211234
5432112345
654321123456
76543211234567
8765432112345678
987654321123456789
(ii)
987654321123456789
8765432112345678
76543211234567
654321123456
5432112345
43211234
321123
2112
11
2. Write a program in C++ that prints the factorial of a given numbers using
(i) for loop (ii) while loop (iii) do-while loop
3. Write a program in C++ to read any five real no. and print the average.
4. Write a program in C++ to generate a Fibonacci series of n numbers, where n is defined
by a programmer.
5. Write a program in C++ to read a no n from the standard input device, i.e.
Keyboard, and again read a digit and check whether the digit is present in the no. n , if it
is so , count how many times it is repeated in the no. n.
N= 12576
Digit to be checked 5
The digit is present once.
6. Write a program in C++ to read a number n , and digit d , and check whether d is present
in the no. n if it is so , find out the position of d in the number n. for ex., n = 75689 d=
5 digit d , i.e. 5 is present at the position 4 from left to right.
7. Write a program in C++ to read a number n and find out the sum of the integers from 1 to
2 then from 1 to 3 , then from 1 to 4 and so fourth and to display the sum of the integers
from 1 to n.
For example.
From 1 to 2 =1
From 1 to 3 = 3
From 1 to 4 = 6
From 1 to 5 = 10
From 1 to 6 = 18
8. Write a program in C++ to read a positive no. n and to generate the following no. series
using (i) for loop (ii) while loop (iii) do-while loop
Number = 1 2 3 4 ….n
Number = 0 2 4 6…..n
Number = 1 3 5 7…..n
Number = 1 22 32 42…n2
Number = 1 23 33 43 ….n3
9. Write a program in C++ to read a positive integer number n and to generate the numbers
in the following form.
Enter a no. : 5
Output 5 4 3 2 1 0 1 2 3 4 5
Enter a no. : 7
Output 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7
10. Write a program in C++ to convert a decimal number to a binary number.
Assignment-4( Lab)
1. Write a program in C++ to read a set of real no. from a standard input device and check
whether any 0 is entered . if it is , using break statement, just stop the execution and to
display a message “ zero entered”.
2. Write a program in C++ to read a set of integer no. from standard input device and to
check whether 0 is entered . if it is so , using continue statement , please repeat the
process up to n no. , where n is entered as the last no.
3. Write a program in C++ to read a positive integer no. n and to generate the following no.
up to n using goto statement
Number = 1 2 3 4 ….n
Number = 0 2 4 6…..n
Number = 1 3 5 7…..n
Number = 1 22 32 42…n2
4. Write a program in C++ to read a positive integer no n from a standard input device to
display the no. and digit for example, n = 5678
Output
5
6
7
and also count the sum of digits.

Assignment-5
1. write a program in C++ to read an integer number and find out the sum of all the digits
till it reduces to a single digit using an array. For example,
(i) n = 1256
Sum = 1+2+5+6 = 14
Sum = 1+ 4 = 5
(ii) n = 7896
Sum = 7+ 8+ 9+6 = 30
Sum = 3+ 0 = 3
2. Write a program in C++ to read a no. n and print out digit by digit , expressing it in
words. For example the no. 756 should be printed as “seven five six”.
3. Write a program in C++ to read a set of no. up to n (where n is defined by the
programer ) and print the contents of the array in reverse order .
For example , n = 4 , let the set be
26 56 51 123 Which should be printed as 123 51 56 26
4. Write a program to read a student’s name and his average mark. If a student gets less than
40 then declare that he has failed or else passed. Prepare a computer list to give the list of
names in alphabetical order separately for passed and failed students.
5. Write a program to read the names of books, authors and accession number is present in
the array, if it is not , print the name of the book and the author’s name.
6. Write a program to read a set of lines from stdin and store them in an array A. again read
a string Sfrom the stdin and check whether the given string S is in the array A. if it is so ,
print that line and also how many times the string is repeated in the array A.

Assignment – 6
1. Write a program in C++ to read n no. ( where n is defined by the progrmer ) and find the
average of the non-negative integers no. find also the deviation of the no.
2. Write a program in C++ to read a set of no. and store it in an one dimensional array ;
again read a number ‘d’ and check whether the number ‘d’ is present in the array. If it is so,
print out how many times the number d is repeated in the array.
3. Write a program in C++ to read a set of no. and store it in an one dimensional array ;
again read a number n , and check whether it is present in the array . if it is so , print out the
position of n in the array and also check whether it repeated in the array.
4. Write a program in C++ to read a set of no. and store it in an one dimensional array ; To
find the largest and the smallest no. and find also the difference between the two no. using
the difference , find the deviation of the no. of the array.
5. Write a program in C++ to read a set of no. and store it in an one dimensional array ; A
copy the elements in an other array B in the reverse direction , find the sum of the
individual elements of the array A& B store the result in another array C. and display all the
three arrays.

Assignment- 7

1. Write a program in C++ to read a set of characters using a pointer and to print in the
reverse orser.
Input : ravic
Output : civar
2. Write a program in C++ to find a given string in a line of text using a pointer.
3. Write a program in C++ to compare the two given string using a pointer.
4. Write a program in C++ to check whether a given string is a palindrome or not using the
pointer method.
5. Write a program in C++ to find the no of words in a set of lines using a pointer.

You might also like