Introduction to Computer Science

CSCI 152 Introduction to Computer Science
Programming with C - LAB 3

Skill set for this assignment:

  • Use if, if-else, if - else - if, and while statements; int, double and float variable types.
  • Use an appropriate variable types and casting
  • Understand and implement the Program Development Cycle
  • Write Lab Report for Each Program

Problem 1
Write a program that reads 7 real numbers. Each number indicates the Fahrenheit temperature for one day. The program finds and prints the average Celsius temperature for these 7 days. Use the following formula to convert Fahrenheit to Celsius: Celsius = (5/9)*(Fahrenheit-32)

Example 1:
Input: 44.76 -67 87.5 0 12 86.89 90
Output: The average Celsius temperature is: 2.392857

Example 2:
Input: 45 45 45 45 45 45 45
Output: The average Celsius temperature is: 7.222222

Example 3:
Input: 32 32 32 32 32 32 32
Output: The average Celsius temperature is: 0.0

Example 4:
Input: 87 90 98 87 85 85 90
Output: The average Celsius temperature is: 31.5873

Problem 2 Write a program that first reads one integer. If the FIRST integer is POSITIVE and EVEN the program reads 5 integers and finds the sum of the negative input numbers, the amount of negative inputs among the input values and their average. YOU HAVE TO USE LOOP FOR IN THIS PART.

If the FIRST integer is NEGATIVE and ODD, the program reads a sequence of positive integers, the first non-positive (zero or negative) number will terminate the input. The program finds the number of inputs between 8 and 25 inclusively that are divisible by 7 and their average. YOU HAVE TO USE LOOP WHILE IN THIS PART

If the FIRST integer is negative even or positive odd, the program reads 10 integers. The program finds and prints the maximum and minimum among the input numbers. YOU CAN USE THE LOOP OF YOUR CHOICE FOR THIS PART