c++ programms task

Upload: nabh-agrawal

Post on 28-Feb-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 C++ Programms Task

    1/2

    Prepared By: Nabh Agrawal C++ Programs P a g e | 1

    C++ PROGRAMS (Practical Lab)

    1. Write a program to calculate the sum, subtraction, multiplication and division of two numbers.2. Write a program that accepts radius of a circle and prints its area and perimeter.3.

    Write a program that accepts marks in 5 subjects and outputs average marks.4. Write a program that reads temperature in Celsius and displays it in Fahrenheit. (F = (1.8*C)+32 )5. Write a program that inputs a students marks in three subjects and print the percentage of marks.

    6.

    Write a program to input an integer and display its first three multiples.7. Write a program to compute the area of a square.8.

    Write a program that accepts a character and prints next 4 characters.9. Write a program to find the area of a triangle.10.Write a program to read two numbers and print their quotient and remainder.11.

    Write a program to compute simple interest.12.Write a program that accepts height in centimeters and then converts height to feet and inches.

    (1foot=12inches, 1 inch=2.54cm).13.

    A computer programming contest requires teams of 5 members each. Write a program that acceptsnumbers of players, and then give the number of teams and number of players left over.

    14.Write a program which will raise any number x to a positive power n. Accept values of x and n

    from user.15.Write a program to input principal amount and time. If time is more than 10 years, calculate the

    simple interest with rate 8%, otherwise calculate it with rate 12% per annum.16.Write a program to input a number. If the number is even, print its square otherwise print its cube.17.Write a program to input three integers and print the largest of three.18.

    Write a program to accept two numbers and an operator. The program performs the arithmeticaloperation and display the result.

    19.Write a program to print whether a given character is an uppercase or a lowercase character or adigit or any other character. (using if-else)

    Characters ASCII Range

    0 to 9 48-57

    A to Z 65-90

    a to z 97-122other characters 0-255 other than above

    20.Write a program to calculate area of circle, area of a rectangle or a triangle depending upon userschoice. (using switch case)

    21.

    Write a program to print first n natural numbers and their sum.22.Write a program to calculate the factorial of an integer.23.Write a program to calculate and print the sum of even and odd integers of the first n natural

    numbers.24.Write a program to check whether a number prime or not.25.

    Write a program to check whether a number is palindrome or not.26.

    Write a program to print table of a given number.

    27.

    Write a program to find whether a year is a leap year or not.28.Write a program to print Fibonacci series i.e. 0 1 1 2 3 5 8 13 21.29.

    Write a program to accept a list of numbers and print largest even number and largest odd number.30.Write a program to produce the following designs:

    AA B

    A B C

    A B C DA B C D E

    *

    * *

    * * *

    * * * *

    * * * * *31.

    Write a program to count number of spaces in a string. (using library function)32.Write a program to count number of lowercase and uppercase characters in a string. (using library

    function)33.

    Write a program to compare length of two strings.34.Write a program that checks whether the given character is alphanumeric or an alphabet or a digit.

    (using library function)35.Write a program that reads a string and convert it into uppercase. (using library function)

  • 7/25/2019 C++ Programms Task

    2/2

    Prepared By: Nabh Agrawal C++ Programs P a g e | 2

    36.

    Write a program that reads two strings and appends (join) the first string to the second. (usinglibrary function)

    37.Write a program that reads two strings and copies the smaller string into bigger string. (usinglibrary function)

    38.Write a program to print cube and square root of a given number using a function.39.Write a program to swap two numbers using call by value and call by reference method.40.

    Write a function to take an integer argument and return 0 if the given number prime otherwisereturn -1.

    41.

    Write a program to read price of 20 items in an array and then display sum, product and average ofall the prices.

    42.Write a program to check if a string is palindrome or not.43.

    Write a program to replace every space in a string with a hyphen (-).44.Write a program to convert a string to proper case. (Capitalize first letter of each word)45.Write a program to print the sum of each column of a two dimensional array.46.Write a user defined function to display those elements of a 2-D array, which are divisible by 10.47.Write a program to reverse a string.48.Write a function that takes a double array name and an array size as arguments and that swaps the

    first and last value in that array.49.Write a function Change(int P[], int N) which should change all the multiples of 10 in the 1-D array to

    10 and rest of the elements as 1.50.Write a program to record score of a cricket match. One array stores information of batting team

    such as batsmans name, runs scored, total over and extras. The other array stores informationabout bowling team such as bowlers name, over bowled, maiden over, runs given and wickettaken. Depending upon the users choice, the program displays either the batting team informationor the bowling team information.

    $***Best Wishes***$