Introduction to Computer Science

CSCI 152 Introduction to Computer Science
Programming with C - LAB 2 Practice

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
  • NESTED LOOPS

Problem 1 Write a program that reads 2 integers, m and n, and prints the m X n rectangle of stars: m rows and n columns.
For example, for m = 3 and n = 5 the output will be:
*****
*****
*****

Problem 2 a Write a program that reads one integer, n, and prints right triangle of n rows as follows:
*
**
***
.....
***********
Last line has n stars Problem 2 b Write a program that reads one integer, n, and prints right triangle of n rows up - side - down as follows:
First line has n stars
There are n rows in the triangle.
***********
**********
*********
*******
....
**
*

Problem 3 Write a program that reads the 9 distinct integers from 1 to 9 and prints them out in the following way: each integer will be printed the number of times equal to its numeric value. Each such repeated output will be printed on a different line. The nine input integers may be input in any order. You may assume that correct input is always given.
See example below.
Example :
Input: 1 2 3 4 5 6 7 8 9
Output:
1
22
333
4444
55555
666666
7777777
88888888
999999999

Problem 4 Write a program that reads a sequence of positive integers. For EACH input the program determines weather the input is PRIME or NOT and prints an appropriate message.

Problem 5 Additonal problem - test 1 preparation