Convert the following FOR statement to WHILE statement: (5 MARKS)
#include <iostream>
using namespace std; #include <iostream>
using namespace std;
int main()
{
for (int counter = 1; counter <= 10; counter++)
cout << “Counter is: ” << counter << endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int counter = 1;
while(counter <= 10){
cout << "Counter is: " << counter << endl;
counter++;
}
cin>>counter;
return 0;
}
Comments
Leave a comment