Professional Documents
Culture Documents
Write A Program That Generates Given Sequence Nos
Write A Program That Generates Given Sequence Nos
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
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--
Stop