You are on page 1of 5

Mariano, Claire Ann M.

A-102

Assignment: COMPRO

1. Write a program that prints the numbers 1 to 4 on the same line for two (2)
times. Write the program using the following methods:
a. Using one printf command (first line of output).

#include <stdio.h>;

main()

printf ("%d",1234);

getch();

b. Using four printf commands (Second line of output).

#include <stdio.h>;

main()

printf ("%d",1);

printf ("%d",2);

printf ("%d",3);

printf ("%d",4);

getch();

}
2. Write a program that prints a box, an oval, an arrow and a diamond.
a. Box

#include <stdio.h>;

main()

printf (“………\n. .\n. .\n. .\n. .\n. .\n. .\n. .\n………");

getch();

b. OVAL

#include <stdio.h>;

main()

printf (" ... \n . .\n. .\n. .\n. .\n. .\n. .\n ... ");

getch();

c. Arrow

#include <stdio.h>;

main()

printf (" . \n … \n…..\n . \n . \n . \n . \n . \n .");


getch();

d. Diamond

#include <stdio.h>;

main()

printf (" . \n . . \n . . \n . . \n. .\n . .\n . . \n. .\n . .\n.");

getch();

3. Print your initials in block letters.

a. C

#include <stdio.h>;

main()

printf (" CCCC \nC C\nC\n\n\n C\n CCC");

getch();

b. A

#include <stdio.h>;

main()
{

printf (" A \n A A\n A A\n AAAAAA \n A A \n A A");

getch();

c. M

#include <stdio.h>;

main()

printf ("MM MM\nM M M M\nM M M\nM M\nM M\nM M");

getch();

4.

a. Eight Printf statements/commands

#include <stdio.h>;

main()

printf ("* * * * * * * *");

printf (" * * * * * * * *");

printf (" * * * * * * * *");

printf (" * * * * * * * *");


printf (" * * * * * * * *");

printf (" * * * * * * * *");

printf (" * * * * * * * *");

printf (" * * * * * * * *");

getch();

b. Few Printf statements

#include <stdio.h>;

main()

printf ("* * * * * * * *\n * * * * * * * *\n * * * * * * * *\n * * * * * * * *");

");

printf (" * * * * * * * *\n * * * * * * * *\n * * * * * * * *\n * * * * * * * *");

You might also like