Subject: Computer Science Topic: Data Types, Variables & Operators 1 Write a program to print HELLO WORLD on screen. 2 Write a program to display output using a single cout statement. 3 Write a program which accept two numbers and print their sum 4 Write a program which accept temperature in Fahrenheit and print it in centigrade. 5 Write a program which accept principle, rate and time from user and print the simple interest. 6 Write a program which accepts a character and display its ASCII value 7 Write a program to swap the values of two variables 8 Write a program to calculate area of circle 9 Write a program to check whether the given number is positive or negative (using? : ternary operator ) 10 Write a program which accepts amount as integer and display total number of Notes of Rs. 500, 100, 50, 20, 10, 5 and 1.
Topic: Control Structure 1 Any integer is input by the user. Write a program to find out whether it is an odd number or even number 2 Write a program to calculate the total expenses. Quantity and price per item are input by the user and discount of 10% is offered if the expense is more than 5000 3 Any year is input by the user. Write a program to determine whether the year is a leap year or not. 4 In a company an employee is paid as under: If his basic salary is less than Rs. 1500, then HRA = 10% of basic salary and DA = 90% of basic salary.if his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic salary. If the employee's salary is input by the user write a program to find his gross salary. 5 Write a program to calculate the monthly telephone bills as per the following rule: Minimum Rs. 200 for upto 100 calls. Plus Rs. 0.60 per call for next 50 calls. Plus Rs. 0.50 per call for next 50 calls. Plus Rs. 0.40 per call for any call beyond 200 calls 6 Write a program to print number from 1 to 10. 7 Write a program to calculate the sum of first 10 natural number 8 Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another 9 Write a program to reverse any given integer number. 10 Write a program to sum of digits of given integer number 11 Write a program to check given number is prime or not.
12 Write a program to calculate HCF of Two given number 13 Write a program to print all Armstrong numbers between 1 and 500. If sum of cubes of each digit of the number is equal to the number itself, then the number is called an Armstrong number. For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 ) 14 Write a program to print Fibonacci series of n terms where n is input by user 0 1 1 2 3 5 8 13 24... 15 Compute the natural logarithm of 2, by adding up to n terms in the series 1-1/2 + 1/3-1/4 + 1/5 -... 1/n where n is a positive integer and input by user. 16 Write C++ program to print following pattern: i) ii) * ** *** **** ***** iii) * ** *** **** ***** 17 Write a program to compute sinx for given x. The user should supply x and a positive integer n. We compute the sine of x using the series and the computation should use all terms in the series up through the term involving x sin x = x - x 3 /3! + x 5 /5! - x 7 /7!+x 9 /9!...
Topic: User Defined Functions 1 Write a C++ program using function which accept two integers as an argument and return its sum. Call this function from main( ) and print the results in main( ). 2 Write a function to calculate the factorial value of any integer as an argument. Call this function from main( ) and print the results in main( ). 3 Write a function that receives two numbers as an argument and display all prime numbers between these two numbers. Call this function from main( ). 4 Raising a number to a power p is the same as multiplying n by itself p times. Write a function called power that takes two arguments, a double value for n and an int value for p, and return the result as double value. Use default argument of 2 for p, so that if this argument is omitted the number will be squared. Write the main function that gets value from the user to test power function. 5 Write a program that lets the user perform arithmetic operations on two numbers. Your program must be menu driven, allowing the user to select the operation (+, -, *, or /) and input the numbers. Furthermore, your program must consist of following functions: 1. Function showchoice: This function shows the options to the user and explains how to enter data. 2. Function add: This function accepts two number as arguments and returns sum. 3. Function subtract: This function accepts two number as arguments and returns their difference. 4. Function multiply: This function accepts two number as arguments and returns product. 5. Function divide: This function accepts two number as arguments and returns quotient.
Topic: Library Functions 1 Write a program to check character entered is alphabet, digit or special character. 2 Write a program which display a number between 10 to 100 randomly 3 Write a program which accept a letter and display it in uppercase letter 4 Write a C++ program to implement the Number Guessing Game. In this game the computer chooses a random number between 1 and 100, and the player tries to guess the number in as few attempts as possible. Each time the player enters a guess, the computer tells him whether the guess is too high, too low, or right. Once the player guesses the number, the game is over. Topic: Array 1 D 1 Write a C++ program to find the sum and average of one dimensional integer array 2 Write a C++ program to swap first and last element of an integer 1-d array. 3 Write a C++ program to reverse the element of an integer 1-D array. 4 Write a C++ program to find the largest and smallest element of an array 5 Write a menu driven C++ program with following option a. Accept elements of an array b. Display elements of an array c. Sort the array using insertion sort method d. Sort the array using selection sort method e. Sort the array using bubble sort method Write C++ functions for all options. The functions should have two parameters name of the array and number of elements in the array. 6 Suppose a one-dimensional array AR containing integers is arranged in ascending order. Write a user-defined function in C++ to search for an integer from AR with the help of Binary search method, returning an integer 0 to show absence of the number and integer 1 to show presence of the number in the array. Function should have three parameters : (i) array AR (ii) the number to be searched and (iii) the number of elements N in the array. 7 Suppose A, B, C are arrays of integers of size M, N, and M + N respectively. The numbers in array A appear in ascending order while the numbers in array B appear in descending order. Write a user defined function in C++ to produce third array C by merging arrays A and B in ascending order. Use A, B and C as arguments in the function.
Topic: Array 2 D 1 Write a menu driven C++ program to do following operation on two dimensional array A of size m x n. You should use user-defined functions which accept 2-D array A, and its size m and n as arguments. The options are: To input elements into matrix of size m x n To display elements of matrix of size m x n Sum of all elements of matrix of size m x n To display row-wise sum of matrix of size m x n To display column-wise sum of matrix of size m x n To create transpose of matrix B of size n x m 2 Write user defined functions for square matrix to calculate 1. Left diagonal sum 2. Right diagonal sum 3 Write a user defined function named Upper-half() which takes a two dimensional array A, with size N rows and N columns as argument and prints the upper half of the array. 4 Write a program to add two array A and B of size m x n. Topic: Structure 1 Declare a structure to represent a complex number (a number having a real part and imaginary part). Write C++ functions to add, subtract, multiply and divide two complex numbers. 2 An array stores details of 25 students (rollno, name, marks in three subject). Write a program to create such an array and print out a list of students who have failed in more than one subject.