Aspire Faculty ID #19024 · Topic: UGC NET Computer Science Dec 2019 (Paper II) · Just now
UGC NET Computer Science Dec 2019 (Paper II)

What 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);
}

Solution

Outer loop runs for:

$i=0,1,2,3,4$

Inner loop runs only when $j<i$.

But inside inner loop, there is a $break$ statement, so inner loop executes only one time for each valid value of $i$.

For $i=0$:

$j<0$ is false, so inner loop does not execute.

For $i=1$:

$x=x+(1+0-1)=0+0=0$

For $i=2$:

$x=x+(2+0-1)=0+1=1$

For $i=3$:

$x=x+(3+0-1)=1+2=3$

For $i=4$:

$x=x+(4+0-1)=3+3=6$

So, final value of $x$ is:

$x=6$

Previous 10 Questions — UGC NET Computer Science Dec 2019 (Paper II)

Nearest first
1
The following program is stored in the memory unit of the basic computer. Give the content of accumulator register in h…
Topic: UGC NET Computer Science Dec 2019 (Paper II)
2
$(142)b+(112){b-2}=(75)_8$, find base $b$.
Topic: UGC NET Computer Science Dec 2019 (Paper II)
3
A micro instruction format has microoperation field which is divided into $2$ subfields $F1$ and $F2$, each having $15$…
Topic: UGC NET Computer Science Dec 2019 (Paper II)
4
A computer uses a memory unit of $512K$ words of $32$ bits each. A binary instruction code is stored in one word of the…
Topic: UGC NET Computer Science Dec 2019 (Paper II)
5
A non-pipelined system takes $30\ ns$ to process a task. The same task can be processed in a four-segment pipeline with…
Topic: UGC NET Computer Science Dec 2019 (Paper II)
6
How many reflexive relations are there on a set with $4$ elements?
Topic: UGC NET Computer Science Dec 2019 (Paper II)
7
A tree has $2n$ vertices of degree $1$, $3n$ vertices of degree $2$, $n$ vertices of degree $3$. Determine the number o…
Topic: UGC NET Computer Science Dec 2019 (Paper II)
8
The weight of minimum spanning tree in graph $G$, calculated using Kruskal's algorithm is:
Topic: UGC NET Computer Science Dec 2019 (Paper II)
9
Let $P$ be the set of all people. Let $R$ be a binary relation on $P$ such that $(a,b)\in R$ if $a$ is a brother of $b$…
Topic: UGC NET Computer Science Dec 2019 (Paper II)
10
What are the greatest lower bound $($GLB$)$ and the least upper bound $($LUB$)$ of the sets $A={3,9,12}$ and $B={1,2,4,…
Topic: UGC NET Computer Science Dec 2019 (Paper II)

Next 10 Questions — UGC NET Computer Science Dec 2019 (Paper II)

Ascending by ID
1
Let $A$ be the base class in $C++$ and $B$ be the derived class from $A$ with protected inheritance. Which of the follo…
Topic: UGC NET Computer Science Dec 2019 (Paper II)
2
Which tag is used to enclose any number of javascript statements in HTML document?
Topic: UGC NET Computer Science Dec 2019 (Paper II)
3
A rectangle is bound by the lines $x=0,\ y=0,\ x=5$ and $y=3$. The line segment joining $(-1,0)$ and $(4,5)$, if clippe…
Topic: UGC NET Computer Science Dec 2019 (Paper II)
4
Which of the following algorithms is not used for line clipping?
Topic: UGC NET Computer Science Dec 2019 (Paper II)
5
If we want to resize a $1024 \times 768$ pixels image to one that is $640$ pixels wide with the same aspect ratio, what…
Topic: UGC NET Computer Science Dec 2019 (Paper II)
6
&nbsp;Which of the component module of DBMS does rearrangement and possible ordering of operations, eliminate redundanc…
Topic: UGC NET Computer Science Dec 2019 (Paper II)
7
Given two tables $R1(x,y)$ and $R2(y,z)$ with $50$ and $30$ numbers of tuples respectively. Find the maximum number of …
Topic: UGC NET Computer Science Dec 2019 (Paper II)
8
Given two tables $EMPLOYEE(EID,ENAME,DEPTNO)$ and $DEPARTMENT(DEPTNO,DEPTNAME)$. Find the most appropriate statement of…
Topic: UGC NET Computer Science Dec 2019 (Paper II)
9
Find the minimum number of tables required for converting the following entity relationship diagram into a relational d…
Topic: UGC NET Computer Science Dec 2019 (Paper II)
10
A counting semaphore is initialized to $8$. $3$ wait $()$ operations and $4$ signal $()$ operations are applied. Find t…
Topic: UGC NET Computer Science Dec 2019 (Paper II)
Ask Your Question or Put Your Review.

loading...