Sunteți pe pagina 1din 5

C++ Programs for class XI

1. Beginners
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. To display the message My first program on the screen. To display your name, and address on the computer screen. To input two numbers and find their sum. To input the values of Principal, Rate, and Time and calculate SI. To input a number and find its square and cube. To input the values of distance and speed and find the time taken to cover the given distance at the given speed. To input the values of radius and height of a cylinder and calculate its CSA and volume. To input the unit price of an item and the quantity of item to be bought. Then calculate the total price. To covert temperature from Fahrenheit to Celsius. WAP to enter the time in seconds and display it in format as: ____________ Seconds = _____ hr ________ min _______ seconds. To input two numbers and swap them using third variable. To input two numbers and swap them without using third variable.

2. Selection (if, if..else, if..else..if, ?:)


1. To input a number. If the number is even, print its square, otherwise print its cube. 2. To input principal amount and time and calculate simple interest and compound interest. If time is more than 10 years, calculate interest at the rate of 8% p.a.. Otherwise calculate it at the rate of 12% p.a. 3. To input choice (1 or 2). If the choice is 1, print the area of a circle otherwise print the circumference of a circle. Accept the radius of the circle from the user. 4. To input the marks of a student and calculate the grade as per the following criteria: Marks Range Grade 90 100 A 75 90 B 60 75 C 50 60 D 40 - 50 E 0 40 F If the marks are out of the range 0 to 100, then the program should give an appropriate message. To input two numbers and find the greater. To input three numbers and find the greatest. To input three numbers and check whether they form a Pythagorean triplet. To input three numbers and check whether a triangle can be formed using these numbers as the lengths of its sides. Menu driven program to calculate the total surface area and volume of a cube, cuboid, or sphere depending upon users choice. To input two numbers and check whether one of these numbers is a multiple of the other. Humidy and probability of rain. To input a character and check whether it is an alphabet, or digit, or some other character. To input an year and check whether it is a leap year. To input a date and check its validity. To input a character. If the character is a lowercase alphabet then display the corresponding upper case alphabet and vice-versa. If the character is not an alphabet then display the character as it is.

5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15.

#1/5

C++ Programs for class XI


3. Iteration (Loops)
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. To display numbers from 1 to 10. To display the alphabets of English language. To find the factorial of a given number. To input 10 numbers and find their sum and average. To input 10 numbers and find the largest and the smallest of the numbers entered. To input a number. If the number is negative, then again input the number. Keep on doing so until the user enters a non-negative number. To input two numbers m and n. Then display first m multiples of n. To display ASCII character table. A menu driven program to calculate the total surface area and volume of a cube, cuboid, or sphere depending upon users choice. The program should continue until the user selects the option to exit the program. To input two numbers and find their LCM. To input two numbers and find their HCF. To input a number and check whether it is a prime or not. To display all the prime numbers between m and n, where m and n have to be input from the user. To input a list of n number and count how many of the entered numbers were primes. To input an integer and find the sum of its digits. To input a number and find whether it is an Armstrong number. To input a number and form another number which is reverse of the entered number. To input a number and check whether it is palindrome or not. To input a list of n number and count how many of the entered numbers were palindrome. To input a number n and display its factorial. To input a number n and display factorials of all the numbers from 1 to n. To display first n terms of Fibonacci series. To find the sum of first n terms of the following series: 1 + (1+2) + (1+2+3) + . . . + (1+2+3+ . . . n) To find the sum of first n terms of the following series: x + x2 + x3 + . . . To find the sum of first n terms of the following series: x - x2 + x3 - . . . To find the sum of first n terms of the following series:

x
27.

x2 x3 ... 2 3

To find the sum of first n terms of the following series:

x2 x3 ... 2 3
x2 x3 ... 2! 3! x2 x3 ... 2! 3!

28. to find the sum of first n terms of the following series:

1 x

29. to find the sum of first n terms of the following series:

1 x

30. to find the sum of first n terms of the following series:

x3 x5 ... 3! 5!

31. to generate n lines of the following pattern on the computer screen: 1

#2/5

C++ Programs for class XI


12 123 . . to generate n lines of the following pattern on the computer screen: 1 12 123 . . to generate n lines of the following pattern on the computer screen: 1 121 12321 1234321 . . to generate 2n+1 lines of the following pattern on the computer screen: * *** ***** ******* ***** *** * to generate 2n+1 lines of the following pattern on the computer screen: * @@@ ***** @@@@@@@ ***** @@@ * to generate 2n+1 lines of the following pattern on the computer screen: * * * * * * * ********* ******* ***** *** * to generate 2n+1 lines of the following pattern on the computer screen: * * * * * * * * * * * * In an off-season sale following schemes of discounts are offered to the customers: a. If the customer buys items for a total marked price of Rs. 1000/- to Rs. 2000 then the discount is 20%. b. If the customer items for a total marked price of Rs. 2001/- to Rs. 5000/- then the discount is 30%. c. If the customer buys items for a total marked price of more than Rs. 5000, then the discount s 40%. A program to input the quantity and the value of each item purchased (not to input the total value or the number of various items purchased) from the user, and then

32.

33.

34.

35.

36.

37.

38.

#3/5

C++ Programs for class XI


calculate the total marked price, total discount, and gross total. Then apply VAT @4% and display the VAT amount and then the net amount payable by the customer.

Basic string handling


1. To input the name of a student and then display this name. 2. to input a string and then display this string in reverse order. 3. to input a string and count the number of as in the string. 4. to input a string and check whether it is a palindrome or not. 5. to input a string and display a set of characters that appear in this string.

Writing and invoking functions


1. To input a list of n number and count how many of the entered numbers were prime. Checking of prime number should be done using a function. 2. Write a program to find the greatest of three numbers using two functions int max(int, int, int) and max(int, int) 3. Program to swap two numbers using a function. 4. A menu driven program, using user-defined functions, to calculate the total surface area and volume of a cube, cuboid, or sphere depending upon users choice. The program should continue until the user selects the option to exit the program. 5. To display IST n prime numbers using the user defined function for checking a prime number. 6. Define a function to check whether a given date is valid or not, and then use the function to accept a valid date. 7. Define a function for checking whether a given number is Armstrong or not and then use the function to count the number of Armstrong numbers from the n numbers keyed by the user. At the end display the sum and average of non Armstrong numbers. 8. In an off-season sale following schemes of discounts are offered to the customers: a. If the customer buys items for a total marked price of Rs. 1000/- to Rs. 2000 then the discount is 20%. b. If the customer items for a total marked price of Rs. 2001/- to Rs. 5000/- then the discount is 30%. c. If the customer buys items for a total marked price of more than Rs. 5000, then the discount s 40%. Write a program to input the value of Total Marked Price from the user and then calculate the discount, and gross total. Then apply VAT @12.5% on the gross total. The program should display The Total Marked Price, Discount, Gross Amount, VAT, and Net Amount Payable by the customer. The program should continue as long as the user wants. Write and use separate functions to calculate the discount, gross total, VAT, and Net Amount Payable.

Arrays (1 Dimensional)
1. To input a list of 10 numbers and then display this list. 2. To input a list of 10 numbers and then display the list of all those numbers which are greater than the average of this list. 3. To input a list of numbers in an array and then rearrange this array in such a way that all the odd numbers appear in the beginning of the array and all the even numbers appear in the end of the array. E.g., if the input list is 1,4,2,7,6,5,9, then after rearrangement the list should be: 1,7,5,9,4,2,6. 4. To input a string and find the frequency of each alphabet appearing in the string. (Alphabet counting should not be case-sensitive) 5. To input a list of numbers and then reverse this list of numbers without using a second array. E.g. if the original list contains 5,2,3,4,1,9, then after reversal the list should contain 9,1,4,3,2,5.

#4/5

C++ Programs for class XI


6. To input the n (n <= 50) numbers and then input another number x and search the list of n numbers for the presence of x. 7. To input elements in an integer array and pass this array and its size to a function which exchanges the values of first half side elements with the second half side elements of the array. The program then displays the altered array. Example: If an array of eight elements has initial contents as 2,4,1,6,7,9,23,10 The function rearranges the array as 7,9,23,10,2,4,1,6 8. To input elements in an integer array and pass this array and its size to a function SwapArray(int[], int), that rearranges the array in such a way that the values of alternate locations of the array are exchanged (Assume the size of the array to be even) Example: If the array initially contains 2, 5, 9, 14, 17, 8, 19, 16 Then after rearrangement the array should contain 5, 2, 14, 9, 8, 17, 16 9. To input elements in two equi-sized integer arrays (say A and B) and pass these arrays along with their size to a function which combines the contents of these arrays into a third array (say C) using the formula C[i] = 2*A[i]+3*B[i]. The third array is also passed as a parameter to the function. 10. To input a number in digits and print it in words.

Arrays (2 Dimensional)
1. To input elements in a 2-D array and then display this array in matrix form. 2. To input the elements in a 2-D array and then find the sum of all the even elements of the array. 3. To find row-wise sum of a two-dimensional array. 4. To find column-wise sum of a two-dimensional array. 5. To find the sum of both left and right diagonal elements from a two-dimensional array. 6. To input elements in a 2 D array and print the sum of all the values which are either divisible by 3 or are divisible by 5 present in it. 7. To input an integer array and pass this array along with its size to a function which assigns the elements of 1-D array to a 2-D array in the following format: If the array is 1, 2, 3, 4, 5, 6 If the array is 1, 2, 3 The resultant 2-D array is: The resultant 2-D array is 123456 123 123450 120 123400 100 123000 120000 100000. 8. To input 10 strings and then for each string find out whether it is palindrome or not. 9. To input elements in two matrices and then find the sum of these matrices.

Structures
1. To input the co-ordinates of two points in a plane and find the distance between them. 2. To input a two rational numbers and find their sum, difference, and product. 3. To input two complex numbers and find their sum. 4. To input the name and aggregate marks of 10 students of a class and then display this marks list in the alphabetical order of the students names. 5. To input the co-ordinates of three vartices of a triangle and then find its area.

#5/5

S-ar putea să vă placă și