Answer to Question #262778 in C++ for Urooj

Question #262778

 Some counting

Use your newly acquired knowledge of the for loop to complete the following tasks. Print all values to console in each case.

• Write a program that counts up from 0 to 50 in increments of 1.

• Write a program that counts down from 50 to 0 in decrements of 1.

• Write a program that counts up from 30 to 50 in increments of 1.

• Write a program that counts down from 50 to 10 in decrements of 2.

• Write a program that counts up from 100 to 200 in increments of 5.


1
Expert's answer
2021-11-08T17:36:59-0500
#include<iostream>
using namespace std;
int main(){
	for(int i=0; i<=50; i++){
		cout<<i<<"  ";
	}
}

#include<iostream>
using namespace std;
int main(){
	for(int i=50; i>=0; i--){
		cout<<i<<"  ";
	}
}
#include<iostream>
using namespace std;
int main(){
	for(int i=30; i<=50; i++){
		cout<<i<<"  ";
	}
}

#include<iostream>
using namespace std;
int main(){
	
	int i=50;
	while(i>=10){
		cout<<i<<"  ";
		i -= 2;
	}


}

#include<iostream>
using namespace std;
int main(){
	
	int i=100;
	while(i<=200){
		cout<<i<<"  ";
		i += 5;
	}


}





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS