Você está na página 1de 2

ECE 152 Programming for Engineers

Laboratory 1

NOTE:
- Submit only C++ source files (*.cpp) through the Blackboard Vista. -
Put your name, project description, and date on the top of your file as a
comment.
- PLEASE WORK ALONE. If cheating is found, you will get ZERO.

1. Go through the Visual C++ 2010 or 2012 Tutorial, make sure you can
compile and run the “Hello World” program successfully. (Do not submit
the Hello World file to Blackboard.)

2. (Lastname_Lab1_p1.cpp) Write a program that prints the following verse

Birch Wood

Snow flows over a quite village; Doves


fly across a gloomy sky.

Two names are carved deep on a birch;


They promised to stay in love all their life.

3. (Lastname_Lab1_p2.cpp) Write a program that displays the results of the


expressions
16/5
26%5
6*4-(5*3)
6*4/(5*3)
7.0*4/(5*3)
3.8/(5.3*6)
15.1*3.7-6.2
Calculate the value of each expression manually to verify that the displayed
values are correct.
4. (Lastname_Lab1_p3.cpp) Write a program that stores the integer value 50
in the variable length, the integer value 20 in the variable width
and the integer value 30 in the variable height. Have your program
calculate the value assigned to the variable volume, using the assignment
statement
Volume = length * width * height;
And print out the value stored in the variable volume. Be sure to declare all
the variables as integers at the beginning of the main()function.

5. (Lastname_Lab1_p4.cpp) Write a program that stores the number 98.653


in the variable firstnum, 53.59 in the variable secnum, and 102.7 in
the variable thirdnum. (Be sure to declare the variables first as either
float or double). Have your program calculate the total of the three
numbers and their average. The total should be stored in the variable
total and the average in the variable average. (Use the statement
average = total/3.0; to calculate the average.) Use cout to
display the total and average.

Você também pode gostar