Lab 4: Programming Exercises: Task 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Lab 4: Programming Exercises

---------------------------------------------------------------------------------------------------------------Instructions: This lab is divided into 6 programming tasks. Make each program and execute it. At the completion of each task, copy .cpp file only, from path C:\Users\yourName\Documents\Visual Studio 2008\Projects to a folder named yourName_RegNo_BEE6A_Lab4. Name each file as Task1.cpp, Task2.cpp and so on. Zip the folder and submit it on LMS. ------------------------------------------------------------------------------------------------------------------------------------------------------

Task 1 Write a program that takes two numbers as input from the user and calculates their Sum, Product, Difference, Quotient and Remainder. See the following code for your help.

//Keeps console window open so user can see output of the program

Figure 1
Task 2 Write a program which calculates the circumference of a circle. See the following code from your help.

Figure 2

Task 3 Make a program with the following code and state the output. Note character is enclosed in single quotes. (Visit msdn.microsoft.com website to see the header file for _getche() and then write down a comment and state what the function does.) What difference do you find between _getche() and _getch? What does endl do in the given code?

Figure 3
Task 4 (Increment and Decrement Operator) Familiarize yourself with increment (++) and decrement (--) operator by implementing the following code. State the output. What difference do you find between myAge++ and ++myAge?

Figure 4
Task 5 Make a program that calculates grades of students when their marks are input by the user. Grading criteria is mentioned as follows: Marks 80 and above 70 - 80 50 - 70 40 - 50 Below 40 Grade A B C D F

Note that marks cannot exceed 100 and cannot be negative. (Hint: use if-else statements like this if (marks > 80 && marks <= 100) cout << Grade is A;

Task 6 Write a program that takes 3 numbers from the user as input and then calculates their average , smallest and largest of the three numbers. (Use if-else structure).

--------------------------------------------------------------------------------------------------------------------------Lab Handout Prepared by: Hassan Farouk TA for Computer Fundamentals Course ---------------------------------------------------------------------------------------------------------------------------

You might also like