Lab 03 - Reading into Things

Lab 03 - Reading into Things - CIS*1500 Computer Lab #3:...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS*1500 Computer Lab #3: Reading into things. .. Duration : 40-50 minutes Objective : This lab builds upon the material presented the classroom lab. We have introduced the scanf function, and the concept of variables, so let's gain some hands-on experience with these new topics. This lab is in two parts. In the first part, we outline common errors that you may encounter when using scanf and variables. In the second part, we will write a program to calculate the area of shapes using scanf and variables. Part I Duration: Approximately 15 minutes In the classroom, we introduced the following program to read in an int representing the number of students, and a float representing their average. The program is given below: #include <stdio.h> int main(void) { int numberOfStudents; float averageGrade; printf(“\nEnter # of students: “); scanf(“%d”,&numberOfStudents); printf(“\nEnter Average Grade: “); scanf(“%f”,&averageGrade); printf(“\nClass size:%d”,numberOfStudents); printf(“\nAverage:%.2f”,averageGrade); return 0; } Step 1 Create a new project (Win32 Console Application) and enter this program. Run it and verify the behavior to be that shown in the classroom lab. Enter a value of 10 for the number of students and a value of 99.9 for the average grade. Make a note of the original output. 1/5
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Step 2 Remove the & from the line: scanf(“%d”,&numberOfStudents); Build and run the program, enter the values 10 and 99.9 as above, and note the output.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/17/2011 for the course CIS 1500 taught by Professor Kramer during the Fall '06 term at University of Guelph.

Page1 / 5

Lab 03 - Reading into Things - CIS*1500 Computer Lab #3:...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online