Computer Science, asked by saifullah25, 6 months ago

Display numbers from 1 to 50 by using FOR..NEXT Statement​

Answers

Answered by kandhunurivenkateshw
0

Explanation:

25

How I write natural number 1 to 50 using loop?

Ajay Krishna

Answered August 29, 2016

This program is very simple..

First declare a variable ex: ‘I' and initialize to 1

Because you need to start from 1

Then think about how we can write next number??

Since The next number is 2 , the relationship between 1 and 2 is that, 1 is added with 1 to get next number. The same is relationship is existed for all number so,

Begin 1

Next 1+ 1= 2

2 + 1 =3

3 + 1=4….. And so on until 50

Processing such type of problem can be views as 3 way

Initialization (begin) : i=1

Next number is : current +1 , i =I+1

Conditions I must be less than or equal to 50,:

I<= 50

Using for loop

for(initialize; condition; updation)

Print variable;

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

printf("%d",i);

Using while loop

Initialization

While (condition)

{

Print var

Updation

}

i=1;

while (i<= 50 )

{

printf("%d",i);

i=i+1;

}

Is

Similar questions