Computer Science, asked by panchalshivang438, 6 months ago

write and algorithm and flowchart to print 1 to N numbers

Answers

Answered by nancychaterjeestar29
3

Answer:

Given : Program to print all natural numbers from 1 to n.

Algorithm:

Step 1: Start

Step 2: Assign i=1

Step 3: Read a number, num

Step 4: Repeat step 5&6 until i=num reach

Step 5: Print i

Step 6: Compute i=i+1

Step 7: Stop

a C program to print all natural numbers from 1 to n using for loop.

Code of given problem:

int main()

{

int i=1,n;

printf("Enter the number to print all natural number till that entered number\t");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

printf("%d\t",i);

}

return 0;

}

#SPJ3

Similar questions