What is the output of the following code?
int i = 1 ;
while ( i <= 10 )
printf ( "%d\n", i );

This question was previously asked in
RRB JE ECE 22 Apr 2025 Shift 2 CBT 2 Official Paper
View all RRB JE Papers >
  1. 10 9 8 7 6 5 4 3 2 1
  2. 1 2 3 4 5 6 7 8 9 10
  3. 0 1 2 3 4 5 6 7 8 9
  4. Infinite loop

Answer (Detailed Solution Below)

Option 4 : Infinite loop
Free
General Science for All Railway Exams Mock Test
2.1 Lakh Users
20 Questions 20 Marks 15 Mins

Detailed Solution

Download Solution PDF

The correct option is 4

Concept:

Here’s the given code:

int i = 1;
while (i <= 10)
    printf("%d\n", i);
The condition i <= 10 is true for i = 1.

The printf() statement runs and prints 1.

But there is no increment (i++) inside the loop.

The variable i is initialized to 1. The while loop continues if the condition i <= 10 is true.

However, no statement within the loop increments the value of i.

Therefore, the value of i will always remain 1, and the condition i <= 10 will always be true, causing the printf statement to execute repeatedly without ever reaching a termination condition. It will continuously print "1" followed by a newline character.

Latest RRB JE Updates

Last updated on Jun 7, 2025

-> RRB JE CBT 2 answer key 2025 for June 4 exam has been released at the official website.

-> Check Your Marks via RRB JE CBT 2 Rank Calculator 2025

-> RRB JE CBT 2 admit card 2025 has been released. 

-> RRB JE CBT 2 city intimation slip 2025 for June 4 exam has been released at the official website.

-> RRB JE CBT 2 Cancelled Shift Exam 2025 will be conducted on June 4, 2025 in offline mode. 

-> RRB JE CBT 2 Exam Analysis 2025 is Out, Candidates analysis their exam according to Shift 1 and 2 Questions and Answers.

-> The RRB JE Notification 2024 was released for 7951 vacancies for various posts of Junior Engineer, Depot Material Superintendent, Chemical & Metallurgical Assistant, Chemical Supervisor (Research) and Metallurgical Supervisor (Research). 

-> The selection process includes CBT 1, CBT 2, and Document Verification & Medical Test.

-> The candidates who will be selected will get an approximate salary range between Rs. 13,500 to Rs. 38,425.

-> Attempt RRB JE Free Current Affairs Mock Test here

-> Enhance your preparation with the RRB JE Previous Year Papers

More While Loop Questions

Get Free Access Now
Hot Links: teen patti sweet teen patti master apk download teen patti star teen patti master 2024 teen patti 50 bonus