ARMY PUBLIC COLLEGE OF MANAGEMENT AND SCIENCES


    WELCOME TO BE(TE) 8


Fundamentals of Programming

LAB TASK # 1                                                                                             Class: BETE-8

Q1)  Write a complete C++ program that declares two integer variables named gallons
         and liters, and give no. of gallons any user defined value as an input and convert it into  
         liters using the following formula:

Liters = gallons * 4

 

        The program should display the output in the following format (if gallons entered =4):

 

4 gallons is equal to 16 liters.

 

Q2) Modify the above program by using floating point numbers.

 

Q3) Write a complete C++ program that declares two variables of type char and int
        respectively. Then give them any value as an input  in integer variable and assign that variable to   
        char  variable and display that char variable in the following format ( if user entered 97 in int
        variable then after assigning integer  variable to char variable output would be like this )

 

The value of character is a.

 

Note: Before writing program write down its algorithm in C++ file in comments (/* and */) at the top.

 

Q4) Write a complete C++ program that give variable num any integer value and then
        calculates its double and display output in the following format (if user enters 702)

 

The value you entered is 702 and its double is 1404.

 

Note: Before writing program write down its algorithm in C++ file in comments (/* and */) at the top.

 

Q5) Write a complete C++ program to enter Roll No, Marks of three subjects Math, Physics
        and Chemistry and then after clearing output screen display the result sheet in the
        following format. Use setw manipulator.

 

************

Result Sheet

************

 

Student’s Roll No.                      Math               Physics           Chemistry        Total

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

 

          2357                                     99                       85                       97                281

 

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

 

Lab task 2                                                                                                            BETE-8

 

Q1) Write Algorithm and then a complete C++ program that will calculate the total rate of receiving dollars for each bushel. You have to take total number of dollars you have received and total number of bushels for  which you get dollars as inputs from user, and then display the result up to two decimal places in following format:

 

For Example:

You have received “$ 12.53 “for each bushel ……

 

Note: Select Appropriate data types and names.

Hint: rate=dollars/bushels

Bushel is the British unit of volume for dry objects, like bushels of corn, bushels of wheat etc.

 

Q2) Write and algorithm and then a complete C++ program that ask user to enter any positive integer and then calculates its 4th power and display the result as (if user entered 3)

 

4th power of 3 = 3*3*3*3 = 81

 

Q3) Use showpoint manipulator before displaying output in above question.

 

Q4) Write a program which inputs a date in the format dd/mm/yy. For example, 25/12/61

 

Q5) Write and algorithm and then a complete C++ program that calculates the product of any three integer values input by user using a single cin statement and display their product by using appropriate message.

 

Q6) What will be the value of each of the following variables after its initialization?

 

double  d = 2 * int(3.14);

long    k = 3.14 - 3;

char c = 'a' + 2;

char c = 'p' + 'A' - 'a';

 

 

 Q7) Write sample program of fixed and showpoint manipulator you have done in class.

Lab Task 3                                                                                                                BETE-8

 

Question 1:

 

Write an algorithm and then a C++ program that asks the user to enter temperature of type double and if the temperature entered is greater than the normal temperature (given by the programmer) then the program must calculate the degrees of fever by subtracting normal temperature from the temperature given by user.

 

Question 2:

 

Draw the flow Chart on a paper before writing program.

Write a complete C++ program of the following illustrations.

 

A user purchased certain items; if the items purchased are greater than zero then average cost of the item will be calculated and displayed with appropriate message otherwise appropriate error message must be displayed.

The program will contain three variables num_Items, average_Cost and

total_Cost of type integer and real respectively. Assign appropriate values to num_Items and total_Cost and then perform the task given above.

 

Question3:

 

What is wrong with the following if statement (there are at least 3 errors). The indentation indicates the desired behavior. (Check it either manually or by writing the whole code in a C++ source file in a complete C++ program)

 

if numNeighbors >= 3 || numNeighbors = 4

++numNeighbors;

cout << "You are dead!" << endl;

else

--numNeighbors;

 

Question4:

 

Write if statements to do the following:

 

Ø      If character variable tax Code is ’T’, increase price by adding the taxRate per-centage of price to it.

 

Ø      If integer variable opCode has the value 1, read in or input double values for X and Y and

      calculate and print their sum.

 

Ø      If integer variable test is even or odd.

 

Ø      If integer variable current Number is odd, change its value so that it is now 3

       times currentNumber plus 1, otherwise change its value so that it is now half of

       currentNumber

 

Ø      If integer variable Number is multiple of 3 or not

 

Ø      Assign 1 to the integer variable leapyYear if the integer variable year is a

       leap year. (A leap year is a multiple of 4, and if it is a multiple of 100, it must

      also be a multiple of 400.)

 

Ø      Assign a value to double variable cost depending on the value of integer variable

      distance as follows:

       Distance                                                 Cost

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

0 through 100                                          5.00

More than 100 but not more than 500       8.00

More than 500 but less than 1,000            10.00

1,000 or more                                         12.00

 

WELCOME TO BE(TE)8..................HERE YOU WILL FIND ALOT OF HELPFUL MATERIAL REGARDING UR STUDY........PAST PAPERS........NOTES......LABTASKS.......SOLUTION MANUAL.........ETC............


MORE STUFF COMING SOON

PLEASE VISIT SOON