Introduction to Computer Science - Fall 2009
CSCI 151
Lab 9

  
Objectives:
increment and decrement operators
assignment operators for abbreviating assignment expressions
loop for
types int, float, double
logic operators
compiling and executing C code.   

Only Lab PRACTICE Today!

You have to show me result for each problem

  • Create a new directory lab9 under your CSCI151 directory
  • Save all your work in the directory lab9
    1. Program 1:
      • Write a C program that prompt the user to enter 6 integers. The program will determine and print the maximum and minimum among the input numbers and their average. Your program should use loop for. Call your program MinMaxAverage.c
      • Compile and run your program with different inputs to test your results.
    2. Program 2
      • Write a C program that prompts the user to enter one integer, reads an input and then print your first and last names on the different lines amount of times that equals to the input number. If the input number was negative or zero your program should print the appropriate error message. Save your program in file printName.c Use loop for to solve this problem.

        For example, if the input was 3 and my name is Yana Kortsarts, the program should output
        Yana Kortsarts
        Yana Kortsarts
        Yana Kortsarts

        Fore example if the input was -2 the program should output: negative input, nothing to print.

        For example, if the input was 0, the program should output: zero input, nothing to print.

      • Compile and run your program with different inputs to make sure that your program produce a right output
      • Show me the result
    3. Program 3
      • Write a program NegativeOdd.c that first reads one positive integer that will indicate an amount of input integer number that will come after that. The program will read the series of the integer numbers (amount of integer numbers will be equal to the first input number) and will find the sum of the negative odd input numbers and their average. Your program should use loop for

    4. Program 4
      • Write a program Negative.c The program will read the series of 10 integer numbers and will find the sum of the negative input numbers, the amount of negative inputs among the input values and their average. Use loop for to solve this problem. Compile and run your program. Show me the result

    5. Program 5
      • Write a program oddDivisors.c that reads one positive integer and finds the amount of the odd divisors of the input number and their average. If the input is negative or zero, the program prints an error message. Use loop FOR to solve this problem.
      Have a good evening.