aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • C++ Based Questions
  • What is the output of the following code? int a=0; for(in...
Multiple choice

What is the output of the following code? int a=0; for(int I=1;I<=a;I++) cout<<I;

  1. 0

  2. 1

  3. Nothing will get displayed

  4. Error

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The loop condition is I <= a. Since a is initialized to 0 and I is initialized to 1, the condition 1 <= 0 is false from the start. Therefore, the loop body never executes.

Keep practicing — related questions

  • What will be the output for the following? int i=2; if(i) cout<<i++; else cout<< --i;
  • What is the output of the following C++ code? #include <iostream> using namespace std; int main () { int a;...
  • What is the output of the following code: int v() { int m=0; return m++; } int main() { cout<
  • What is the output of the following program? void main(); { int a=5,b=5; cout<<a++; cout<< -> ; cout<<++a; ...
  • What is the output of the following code snippet? #include <iostream> using namespace std; int main () { in...
  • What is the output of the following code: int v() { int m=0; return m++; } int main() { cout<
  • What is the output of the following program?#include void main() { int x=7,y=6,z; z=x-- -y; cout< }
  • What does the following code do: int c=0; cout<
Play the full quiz 🎤 Practise this topic out loud

Practice this topic

  • Programming Output Evaluation (1721 questions)
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy