Write A Program That Generates Given Sequence Nos

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

1. Write a program that generates given sequence nos.

Sequence nos.
1
2
3
4
5
Algorithm:
N=1
While (N<=5) {
Printf(\n%d,N)
N++;
}

Start

n=1

n>=5

Printf(n)

Stop

2. Write a program that generates the given sequence numbers:


5
4
3
2
1
Algorithm:
For(n=5;n>=1;n-) {
Printf(\n%d,n);
Delay(3000);
}

Start

i=1

i<=5

Stop

3. Write a program that calculates the sum of the given sequence numbers:
1 + 2 + 3 + 4 + 5
Algo rithm:
For(I=1;I<=5;I++) {
Printf(\n%d,I);
Sum= Sum + I;
}
Printf(\n The sum: %d,Sum);

Start

i=1
sum=

i<=5

sum=sum+i

i=i+1

Stop

4. Write a program that computes the factorial value of n (as input) and
displays it.
Algorithm:
Enter a number: (n)
For (I=0;I>=1:I) {
F=F*I;
}
Printf(\n The factorial value: %d,F);
Star

input n

f=1

i=n
i>=1

f=f*
i--

Printf(\n The factorial value: %df)

Stop

You might also like