Computer Science, asked by Vivm, 1 year ago

c).Rewrite the below given program using for loop.​​​​[3]
​​# include
​​ void main ( )
​​ {
​​​int i=1,sum =0 ;
​​​while (i<=10)
​​​{
​​​​sum =sum + i ;
​​​​i++ ;
​​​}
​​​cout << sum ;

Answers

Answered by vaibhavsrivastava
0

The Appropriate for loop is:-

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int sum=0;

   for(int i=1;i<=10;i++)

   {

    sum=sum+i;

   }

cout<<sum;

getch();

}

Similar questions