Wednesday, November 29, 2006

Activity No. 3....Iterative Statements

Directions:
Listen carefully to the instructions given by your instructor. Deadline of this activity is on December 20, 2006.

1.Write a program that will ask the user to enter a number n and display all the numbers from 1 to n on a single line.


2.Write a program that will ask the user to enter a number n and display the sum of all numbers from 1 to n.


3.Write a program that asks the user to enter a number n and display the first n even numbers. Example: if n=5, the first 5 even numbers are 2, 4, 6, 8 and 10.


4.Write a program that asks to enter a number n and display the first n even numbers. Example: if n=5, the first 5 odd numbers are 1, 3, 5, 7 and 9.


5.Write a program that will compute for n! (n factorial) which is the product of all numbers a from 1 to n.


6.Write a program that will compute for and display the sum of all numbers divisible by 3 from 1 to 1000.


7.Write a program that will ask the user to enter a number and display all the factor of the number.


8.Write a program that will accept a number n and display the sum of all even numbers and the sum of all odd numbers from 1 to n.

9.Write a program that will display the following pattern, given the value of n.
Example: If n=4, output

*
* *
* * *
* * * *

10.Write a program that will display the following pattern, given the value of n.
Example: If n=4, output

* * * *
* * *
* *
*

11.Write a program that will display the following pattern, given the value of n.
Example: If n=4, output

* * * *
* * * *
* * * *
* * * *

12.Write a program that will display the following pattern, given the value of n.
Example: If n=4, output

* * * *
* * * *
* * * *
* * * *

13.Write a program that will display the following pattern, given the value of n.
Example: If n=4, output

4321
321
21
1

14.Write a program that will display the following pattern, given the value of n.
Example: If n=4, output

1234
123
12
1

15.Write a program that will display the following pattern, given the value of n and m. Example: If n=5 and m=6 , output

* * * *
* * * *
* * * *

16.Write a program that will display the following pattern, given the value of n and m. Example: If n=5 and m=6 , output

* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *

17.Write a program that will display the following pattern, given the value of n. Example: If n=5 , output

* * * * * * * *
* * * * * * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *

18.Write a program that will display the following pattern, given the value of n. Example: If n=5, output

* * * * * * * * *
* * * * * * * **
* * * * * * ***
* * * * * ****
* * * * *****

1 Comments:

At April 11, 2013 at 1:48 AM, Anonymous Anonymous said...

Κim is passionate about being herself, and finds equal pleasure in helping other women
do the samе. Τhe possibility of a sale. It can аlso be done busіneѕs for
ωhеre yοu're at now and where you are. Either way, we'll be business glad to be affiliatеd with.


Also ѵisіt mу blоg :: internet marketing images

 

Post a Comment

<< Home