What will be the output of the following code?          int i = 1;while(i<10){  if (i / 2 == 2)     cout << i << “ ”;i++;}

Question

What will be the output of the following code?          int i = 1;while(i<10){  if (i / 2 == 2)     cout << i << “ ”;i++;}
🧐 Not the exact question you are looking for?Go ask a question

Solution 1

The output of the given code will be "4". Here's the step by step explanation:

  1. The code starts with an integer i initialized to 1.
  2. Then it enters a while loop which will continue to execute as long as i is less than 10.
  3. Inside the loop, there's an if condition that checks if i divide Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study prob
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solv

This problem has been solved

Similar Questions

What will be the output of the following code?          int i = 1;while(i<10){  if (i / 2 == 2)     cout << i << “ ”;i++;}

What will be the output of the following code?    int i = 0;    while(i!=15){      cout << i << " ";      i = i + 5;    }

What will be the output of the following code?int num = 2;int count=0;while(num!= 0){if ( num & 01)count ++;num >>=1;}cout<< count;return 0;

What is the output of the following piece of code?int i;i = 10;while (i < 20){ printf("%d", i % 2); i++;}

What will be the output of the following C++ code?int arr[] = {1, 2, 3, 4, 5};cout << arr[2];1234

1/3