
Introduction to Computer Science - Fall
2009
CSCI 151
Lab 6 Part II(for Wed class)
Objectives:
loop while
types int, float, double
compiling
and executing C code.
Important:
Start each of your programs with comment part that includes:
your first and last names
your e-mail
today's day
the name of the program ( the name of the file)
the short description what this program is doing
list of the variables with the short description for each variable -
name, type, purpose (this information could be written in the declaration
of the variable section of your program)
Change to Lab6 and save all Lab assignment problems in Lab6 directory
Lab Practice:
Program 1
-
Write a C program that prompts the user to enter two integers. If the
sum of the input numbers is divisible by 6, your program prints
"Hello" 10 times, otherwise your program finds and prints the average (the
real average value, not an integer part!! we already learned how to work
with real numbers) of the input numbers. Use loop while to print "Hello"
10 times.
- Submit the printout of the program
Program 2
- Write a program that reads two integers. If both input numbers are
odd, the program prints the average of the input numbers 5 times on
different lines (use loop while to do this), if both input numbers are
even, the program prints the sum and the product of the input numbers 5
times on one line with tab space between the numbers
(use loop while to do this), and if one of
the input numbers is even and one is odd the program prints the
average of the last
digits of the input numbers 5 times on one line with space between the
numbers (use loop while to do this).
- Submit the printout of the program
Program 3
- Write a program that inputs a series of 10 integers, and
determines the sum and the product of the input numbers. Hint: scanf
statement should be
inside the loop. The calculation of the sum and product should be inside
the loop. See
example 6 the Loop While handout.
- Submit the printout of the program
Program 4
- Write a program that inputs a series of 10 integers, and
finds the average of the input numbers. Hint: scanf statement should be
inside the loop. The calculation of the sum should be inside the loop.
The calculation of the average should be OUTSIDE the loop. See
example 6 in the Lool While handout.
- Submit the printout of the program