Question: PROGRAMMING FUNDAMENTALS CS 213 Autum 2016 LAB Handout 2 OBJECTIVE 1) To introduce variables and named constants 2) To introduce various data types: a. Integer
PROGRAMMING FUNDAMENTALS CS 213 Autum 2016 LAB Handout 2 OBJECTIVE 1) To introduce variables and named constants 2) To introduce various data types: a. Integer b. Character c. Floating point d. double 3) To demonstrate the use of arithmetic operators PRE-LAB READING ASSIGNMENT Before starting this lab students should read/revise at-least handouts given on topics presented in the class. Students can find these handouts from course webpage on moodle. For additional understanding about concepts presented in the class, read the following chapter 1) Chapter 1 from book "Beginning C++" by Ivor Horton EXPERIMENTS 1) Read the following C++ program for understanding. Add some suitable declarations to complete the program and run it. # using namespace std; void main() { ....... units = 5; price = 12.5; idnumber = 12583; cost = price*units; cout << idnumber << " " << units << " " << price << " " << cost << endl; tax = cost*0.06; total = cost + tax; cout << tax << " " << total << endl; } 2) Run the following program to check the output: # using namespace std; void main( ) { const float PI=3.14159; float radius = 5; float area; area = radius * radius * 3.14159; // Circle area calculation cout << "The area is " << area << " with a radius of 5. "; radius = 20; // Compute area with new radius. area = radius * radius * 3.14159; cout << "The area is " << area << " with a radius of 20. "; } 3) Write a program to check the result of each of the following expression a. 1 + 2 * 4 / 2 b. (1 + 2) * 4 / 2 c. 1 + 2 * (4 / 2) d. 9 % 2 + 1 e. (1 + (10 - (2 + 2))) 4) Run the following programs and explain their results. a. void main() { short i = -3; unsigned short u; cout<< sizeof(i)<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
