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
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
Psychology,
6 months ago