Lecture Slides on Repetition: Conditional - While Loop | CSCE 150A, Lab Reports of Computer Science

Material Type: Lab; Class: PRBLM SOLVNG:COMPUTR; Subject: Computer Science and Engineering ; University: University of Nebraska - Lincoln; Term: Spring 2009;

Typology: Lab Reports

Pre 2010

Uploaded on 08/30/2009

koofers-user-r6z
koofers-user-r6z 🇺🇸

10 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSCE150A
While
do-while
for
Computer Science & Engineering 150A
Problem Solving Using Computers Laboratory
Lecture 05 Loops
Derrick Stolee
Spring 2009
1/5
pf3
pf4
pf5

Partial preview of the text

Download Lecture Slides on Repetition: Conditional - While Loop | CSCE 150A and more Lab Reports Computer Science in PDF only on Docsity!

CSCE150A

While do-while for

Computer Science & Engineering 150A

Problem Solving Using Computers – Laboratory

Lecture 05 – Loops

Derrick Stolee

Spring 2009

1 / 5^ [email protected]

CSCE150A

While do-while for

Repetition: Conditional - while loop

General format while ( check condition ) { executable1; executable2; change variable in conditional statement } Must make a change in conditional variable within the loop! Compile sam3.c and run.

CSCE150A

While do-while for

Repetition: For a fixed number of times - for loop

General format for ( x = 0; x < maxValue; x++) { executable1; executable2; } Should NOT make a change in conditional variable! Compile sample6.c and run.

CSCE150A

While do-while for

Practice problem

(^1) Write a program that will find the smallest, largest, and average values in a collection of N numbers. The number N will be given to the program by the user. Also compute and display the range of values in the data collection (the minimum and maximum numbers entered), and the standard deviation of the data collection. To compute the standard deviation, accumulate the sum of the squares of the data values (sum squares) in the main loop. After loop exit, use the formula

standarddeviation =

sum squares N − average^2