+ All Categories
Home > Documents > Practical-8 to 10

Practical-8 to 10

Date post: 06-Jul-2018
Category:
Upload: abdulrehman999
View: 217 times
Download: 0 times
Share this document with a friend

of 18

Transcript
  • 8/17/2019 Practical-8 to 10

    1/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 1

    PRACTICAL 8

    Problem Statement 1:- 

    Write a program that prompts the user to input a decimal number and outputsthe number rounded to the nearest integer.

  • 8/17/2019 Practical-8 to 10

    2/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 2

    Output on screen:

    Problem Statement 2:

    Write a C++ program that prompts the user in seconds. The program then

    outputs the elapsed time in hours, minutes, and seconds. (For example, if the

    elapsed time is 9630 seconds, then the output is 2:40:30).

  • 8/17/2019 Practical-8 to 10

    3/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 3

  • 8/17/2019 Practical-8 to 10

    4/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 4

    Output on screen:

    Problem Statement 3:-

    Write a program that prompts the user to input a length expressed in

    centimeters. The program should then convert the length to inches (to the

    nearest inch) and output the length expressed in yards, feet, and inches, in that

    order. For example, suppose the input for centimeters is 312. To the nearest inch,

    312 centimeters is equal to 123 inches. 123 inches would thus be output as: 3

    yard(s), 1 feet (foot), and 3 inch (es) .

  • 8/17/2019 Practical-8 to 10

    5/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 5

  • 8/17/2019 Practical-8 to 10

    6/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 6

    Output on screen:-

    Problem Statement 4:-

    A milk carton can hold 4.78 litres of milk. Each morning, a dairy farm ships cartons

    of milk to a local grocery store. The cost of producing one litre of milk is $0.41,

    and the profit of each carton of milk is $0.51. Write a program that does the

    following:

    a) Prompts the user to enter the total amount of milk produced in the morning.

    b) Outputs the number of milk cartons needed to hold milk. (Round your answer

    to the nearest integer.)

    c) Outputs the cost of producing milk.

    d) Outputs the profit for producing milk.

  • 8/17/2019 Practical-8 to 10

    7/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 7

  • 8/17/2019 Practical-8 to 10

    8/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 8

    Output on screen:-

  • 8/17/2019 Practical-8 to 10

    9/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 9

    PRACTICAL 9

    Problem Statement 1:

    Newton’s law states that the force, F, between two bodies of masses M1and M2is given by:

    in which k is the gravitational constant and d is the distance between the bodies.

    The value of k is approximately.

    Write a program that prompts the user to input the masses of the bodies and thedistance between the bodies. The program then outputs the force between the

    bodies.

  • 8/17/2019 Practical-8 to 10

    10/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 10

  • 8/17/2019 Practical-8 to 10

    11/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 11

    Output on screen:

    Problem Statement 2:

    One metric ton is approximately 2205 pounds. Write a program that prompts the

    user to input the amount of rice, in pounds, in a bag. The program outputs the

    number of bags needed to store one metric ton of rice.

  • 8/17/2019 Practical-8 to 10

    12/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 12

    Output on screen:-

  • 8/17/2019 Practical-8 to 10

    13/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 13

    Problem Statement 3:

    Write a logic circuit solver program in C++ that solves the following logic circuit.

    Where all the inputs are logic switches (which can be either Turned ON (True, 1)

    or Turned OFF (False, 0)). The program should display the output value.

  • 8/17/2019 Practical-8 to 10

    14/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 14

    Output on screen:-

  • 8/17/2019 Practical-8 to 10

    15/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 15

    PRACTICAL 10:

    Object: Working with Conditional Control Structures of C++.

    TASKS

    Problem Statement 1:

    There are two circular grounds Ground-A and Ground-B. Ground-A is having diameter of 15 meters and

    Ground-B is having diameter of 20 meters. Ashar is running in Ground-A and Abbas is running in Ground-

    B. Write a computer program that asks the user to input the time taken, in seconds, to complete one

    compete round of the ground by both the friends and displays who is running faster.

    Output on screen:-

  • 8/17/2019 Practical-8 to 10

    16/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 16

    Problem Statement 2:

    Write a computer program that asks the user to enter three angles of a triangle.

    The program displays whether the triangle is right-angle, acute-angle, Isosceles or

    obtuse-angle.

  • 8/17/2019 Practical-8 to 10

    17/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 17

    Output on screen:-

    Problem Statement 3:

    Write a computer program that asks the user to enter date of birth and month of

    birth. The program should display the zodiac star.

  • 8/17/2019 Practical-8 to 10

    18/18

    INTRODUCTION TO COMPUTING AND PROGRAMMING

    16EL84 | Abdul Rehman Shah 18

    Output on screen:-

     


Recommended