Question
Download Solution PDFWhat is the output of following C program?
#include <stdio.h>
main()
{
int i, j, x = 0
for (i = 0; i < 5; ++i)
for (j = 0; j < i; ++j)
{
x + =(i + j – 1);
break;
}
Printf (“%d”, x);
Answer (Detailed Solution Below)
Detailed Solution
Download Solution PDFLoop evaluation
for i = 0 |
j = 0 |
j not less i, inner for loop terminates |
for i = 1 |
j = 0 |
x = 0 + 1 + 0 – 1 = 0 |
for i = 2 |
j = 0 |
x = 0 + 2 + 0 – 1 = 1 break statement encountered, inner loop terminates |
for i = 3 |
j = 0 |
x = 1 + 3 + 0 – 1 = 3 break statement encountered, inner loop terminates |
for i = 4 |
j = 0 |
x = 3 + 4 + 0 – 1 = 6 break statement encountered, inner loop terminates |
for i = 5 |
i not less 5, outer loop terminates |
Last updated on Jun 6, 2025
-> The UGC NET Exam Schedule 2025 for June has been released on its official website.
-> The UGC NET Application Correction Window 2025 is available from 14th May to 15th May 2025.
-> The UGC NET 2025 online application form submission closed on 12th May 2025.
-> The June 2025 Exam will be conducted from 21st June to 30th June 2025
-> The UGC-NET exam takes place for 85 subjects, to determine the eligibility for 'Junior Research Fellowship’ and ‘Assistant Professor’ posts, as well as for PhD. admissions.
-> The exam is conducted bi-annually - in June and December cycles.
-> The exam comprises two papers - Paper I and Paper II. Paper I consists of 50 questions and Paper II consists of 100 questions.
-> The candidates who are preparing for the exam can check the UGC NET Previous Year Papers and UGC NET Test Series to boost their preparations.