Quiz on Loops in C++
Almost all programming languages use loops at some point. It’s an integral part of any programming language. Similarly, in C++, we can create iterations by using loops. In programming, loops are used to repeat a set of statements repeatedly. During the upcoming quiz, we will test your understanding of the C++ loops.
All the best!
0 of 15 Questions completed Questions: You have already completed the quiz before. Hence you can not start it again. Quiz is loading… You must sign in or sign up to start the quiz. You must first complete the following: 0 of 15 Questions answered correctly Your time: Time has elapsed You have reached 0 of 0 point(s), (0) Earned Point(s): 0 of 0, (0) #include <iostream> using namespace std; int main() { int i; for(i=0;i<5;i++) cout<<“QuizOrbit.com”<<endl; return 0; } #include <iostream> using namespace std; int main() { int i=0; label: cout<<“QuizOrbit.com”<<endl; i++; if(i<6) { goto label; } return 0; } #include <iostream> using namespace std; int main() { int i,j; for(i=0;i<5;i++) for(j=0;j<i;j++) cout<<“QuizOrbit.com”<<endl; return 0; } #include <iostream> using namespace std; int main() { int i = 0, j = 0; do { if(i % 2 == 0) { cout<<j; j++; } ++i; }while(i<10); cout<<j; return 0; } #include <iostream> using namespace std; int main() { int i,j; for(i=0;i<5;i++) { while(j<i) { cout<<“QuizOrbit.com”<<endl; j++; } } return 0; } #include <iostream> using namespace std; int main() { int i,j=0; for(i=10;i>0;i/=2) { j++; cout<<j; } cout<<j; return 0; } #include <iostream> using namespace std; int main() { int i=10,j=0; while(1) { if(j<i) j++; cout<<j; } return 0; } #include <iostream> using namespace std; int main() { int x = 9; while (x<9); x++; cout<<x; return 0; } #include<iostream> #include<algorithm> using namespace std; void displayx2(int x) { cout << x * 2 << ” “; } class Multiply2 { void operator() (int x) { cout << x * 3 << ” “; } }; int main() { // initializing array int arr[5] = { 1, 5, 2, 4, 3 }; for_each(arr, arr + 5, displayx2); return 0; } #include<iostream> #include<vector> #include<algorithm> using namespace std; void displayx2(int x) { cout << x * 2 << ” “; } class Multiply2 { void operator() (int x) { cout << x * 3 << ” “; } }; int main() { vector<int> arr1 = { 1, 5, 4, 2, 3 }; for_each(arr1.begin(), arr1.end(), displayx2); return 0; } #include <iostream> using namespace std; inline int display(int a, int b) { return a*b; } int main() { int i,a=10,b=5; for(i=1;i<display(a,b);i=i*2) cout<<i<<” “; return 0; } #include <iostream> using namespace std; int main() { int i = 100; for (; i; i >>= 1) cout<<“QuizOrbit”<<endl; return 0; } #include <iostream> using namespace std; #define DISPLAY(i, limit) do { if (i++ < limit) { cout<<“QuizOrbit”<<endl; continue; } }while(i<limit) int main() { int i = 0; DISPLAY(i, 4); return 0; } Quiz Summary
Information
Results
Results
0 Essay(s) Pending (Possible Point(s): 0) Categories
1. Question
2. Question
3. Question
4. Question
5. Question
6. Question
7. Question
8. Question
9. Question
10. Question
11. Question
12. Question
13. Question
14. Question
15. Question
Summary
Hopefully, you now understand the concepts involved with loops in C++. When you have completely understood all the concepts involved with loops in C++, you are encouraged to move to the next section. Learn well!