- Quiz will start as soon as you click the ‘Start Quiz‘ button below.
- Question will come one by one click on next for next question
- There are 30 questions in this quiz, you will get 30 Minutes to attempt.
- 2 Marks is determined for the correct answer for each question. There is no negative marking for incorrect answer.
- After the quiz is over, in order to know your rank in the Ranking List / Leader-board below, you should enter your name and email address, otherwise you will be deprived of it.
- After completing click on finish Quiz
- To see correct answers click on view Question
- जैसे ही आप नीचे दिए गए ‘स्टार्ट क्विज़’ बटन पर क्लिक करेंगे, क्विज़ शुरू हो जाएगा।
प्रश्न अगले प्रश्न के लिए अगले एक क्लिक पर आएगा
इस क्विज में 30 प्रश्न हैं, आपको प्रयास करने के लिए 30 मिनट मिलेंगे।
प्रत्येक प्रश्न के सही उत्तर के लिए 2 अंक निर्धारित किए गए हैं। गलत उत्तर के लिए कोई नकारात्मक अंकन नहीं है।
प्रश्नोत्तरी समाप्त होने के बाद, नीचे दी गई रैंकिंग सूची / लीडर-बोर्ड में अपनी रैंक जानने के लिए, आपको अपना नाम और ईमेल पता दर्ज करना चाहिए, अन्यथा आप इससे वंचित रह जाएंगे।
फिनिश क्विज़ पर क्लिक करने के बाद
सही उत्तर देखने के लिए प्रश्न पर क्लिक करें
Paper 2 CS Programming Languages Comp Graphics Part 6
Quiz-summary
0 of 30 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
Information
Paper 1 Quiz helps u to Excel in NET JRF
Paper 1 All questions 2 Marks each
- Navdeep Kaur
- All the Best
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 30 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
-
Average marks Improve next time All the Best
-
Nice Keep it up, Stay Blessed
-
Awesome Great Marks, Keep doing
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- Answered
- Review
-
Question 1 of 30
1. Question
2 points“Which of the following statements is/are True regarding the solution to the visibility problem in 3D graphics ?
S1 : The Painter’s algorithm sorts polygons by depth and then paints (scan – converts) each Polygon onto the screen starting with the most nearest polygon. S2 : Backface Culling refers to eliminating geometry with back facing normals. Code :”
Correct
“Visibility problem in 3D graphics
1. Painter’s algorithm
– A depth sorting method
– Surfaces are sorted in the order of decreasing depth
– Surfaces are drawn in the sorted order, and overwrite the pixels in the frame buffer – Subtle difference from depth buffer approach: entire face drawn
– Two problems:
• It can be nontrivial to sort the surfaces
• There can be no solution for the sorting order
2. Back Face Culling
– Back faces: faces of opaque object which are “pointing away” from viewer
– Back face culling – remove back faces (supported by OpenGL)
How to detect back faces
– If we find backface, do not draw, save rendering resources
– There must be other forward face(s) closer to eye
– F is face of object we want to test if backface
– P is a point on F
– Form view vector, V as (eye – P)
– N is normal to face F
3. View-Frustum Culling
– Remove objects that are outside the viewing frustum
– Done by 3D clipping algorithm (e.g. Liang-Barsky)
4. Ray Tracing
– Ray tracing is another example of image space method
– Ray tracing: Cast a ray from eye through each pixel to the world
5. Z(Depth buffer algorithm)
Reference: https://web.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture08_p2.pdf“Incorrect
“Visibility problem in 3D graphics
1. Painter’s algorithm
– A depth sorting method
– Surfaces are sorted in the order of decreasing depth
– Surfaces are drawn in the sorted order, and overwrite the pixels in the frame buffer – Subtle difference from depth buffer approach: entire face drawn
– Two problems:
• It can be nontrivial to sort the surfaces
• There can be no solution for the sorting order
2. Back Face Culling
– Back faces: faces of opaque object which are “pointing away” from viewer
– Back face culling – remove back faces (supported by OpenGL)
How to detect back faces
– If we find backface, do not draw, save rendering resources
– There must be other forward face(s) closer to eye
– F is face of object we want to test if backface
– P is a point on F
– Form view vector, V as (eye – P)
– N is normal to face F
3. View-Frustum Culling
– Remove objects that are outside the viewing frustum
– Done by 3D clipping algorithm (e.g. Liang-Barsky)
4. Ray Tracing
– Ray tracing is another example of image space method
– Ray tracing: Cast a ray from eye through each pixel to the world
5. Z(Depth buffer algorithm)
Reference: https://web.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture08_p2.pdf“ -
Question 2 of 30
2. Question
2 pointsCorrect
“→ The above iterative code is computes the GCD of two numbers using euclidean algorithm.
→ The procedure is to subtract smaller number from larger. So that we can reduce larger number then doesn’t change the value of GCD.
→ if we performing number of iterations based on condition the larger of two numbers will end up with GCD.”Incorrect
“→ The above iterative code is computes the GCD of two numbers using euclidean algorithm.
→ The procedure is to subtract smaller number from larger. So that we can reduce larger number then doesn’t change the value of GCD.
→ if we performing number of iterations based on condition the larger of two numbers will end up with GCD.” -
Question 3 of 30
3. Question
2 pointsCorrect
Incorrect
-
Question 4 of 30
4. Question
2 pointsCorrect
Incorrect
-
Question 5 of 30
5. Question
2 pointsCorrect
“*(kd -> name +2) /* this is wrong statement */
We have to write *((*kd).name+2).
Note: They are specifically asked about a value stored at that location of the string by using “”*”” outside the brackets. Otherwise, option A and B would be correct.”Incorrect
“*(kd -> name +2) /* this is wrong statement */
We have to write *((*kd).name+2).
Note: They are specifically asked about a value stored at that location of the string by using “”*”” outside the brackets. Otherwise, option A and B would be correct.” -
Question 6 of 30
6. Question
2 pointsCorrect
Incorrect
-
Question 7 of 30
7. Question
2 pointsCorrect
“Step-1: In main function, number variable has been initialized to 30.
Step-2: We pass address of number as parameters in the square function. As per the concept of function overloading in C++ the second square function will be executed.
Step-3: –(*y) will be executed first since decrement operator has the higher precedence than multiplication.
*x = (*x) * –(*y);
*x = 30 * 29;
*x = 870
Note: x is a pointer variable and it holds the address of the variable number.”Incorrect
“Step-1: In main function, number variable has been initialized to 30.
Step-2: We pass address of number as parameters in the square function. As per the concept of function overloading in C++ the second square function will be executed.
Step-3: –(*y) will be executed first since decrement operator has the higher precedence than multiplication.
*x = (*x) * –(*y);
*x = 30 * 29;
*x = 870
Note: x is a pointer variable and it holds the address of the variable number.” -
Question 8 of 30
8. Question
2 points“Consider the following C function:
int f(int n)
{
static int i = 1;
if(n >= 5) return n;
n = n+i;
i++;
return f(n);
}
The value returned by f(1) is”Correct
“The variable “i” is static variable and the value of that variable will be retained between multiple function calls.
first line of f() is executed only once.
Depending upon the value “n” and “i”, the function f() will until n>=5.
You can find the tracing of function f() from the below Execution of f(1)
i = 1
n = 2
i = 2
Call f(2)
i = 2
n = 4
i = 3
Call f(4)
i = 3
n = 7
i = 4
Call f(7)
since n >= 5 return n(7) with return value = 7”Incorrect
“The variable “i” is static variable and the value of that variable will be retained between multiple function calls.
first line of f() is executed only once.
Depending upon the value “n” and “i”, the function f() will until n>=5.
You can find the tracing of function f() from the below Execution of f(1)
i = 1
n = 2
i = 2
Call f(2)
i = 2
n = 4
i = 3
Call f(4)
i = 3
n = 7
i = 4
Call f(7)
since n >= 5 return n(7) with return value = 7” -
Question 9 of 30
9. Question
2 points“Consider the following code segment
for (int k=0; k<20; k=k+2)
{
if (k % 3 == 1)
system.out.print(k+ “” “”)
}
What is printed as a result of executing the code segment?”Correct
“for loop starts from 0 to 20 and increments with 2 at each iteration.
k = 0 % 3 = 0
k = 2 % 3 = 2
k = 4 % 3 = 1 // prints 4
k = 6 % 3 = 0
k = 8 % 3 = 2
k = 10 % 3 = 1 // prints 10
k = 12 % 3 = 0
k = 14 % 3 = 2
k = 16 % 3 = 1 // prints 16
k = 18 % 3 = 0
So, Output is 4 10 16”Incorrect
“for loop starts from 0 to 20 and increments with 2 at each iteration.
k = 0 % 3 = 0
k = 2 % 3 = 2
k = 4 % 3 = 1 // prints 4
k = 6 % 3 = 0
k = 8 % 3 = 2
k = 10 % 3 = 1 // prints 10
k = 12 % 3 = 0
k = 14 % 3 = 2
k = 16 % 3 = 1 // prints 16
k = 18 % 3 = 0
So, Output is 4 10 16” -
Question 10 of 30
10. Question
2 pointsCorrect
“If we are given p instead of *p then it prints the address of k but we are printing the value of k.
The same rule applies in **m.
Output is 5 5 5”Incorrect
“If we are given p instead of *p then it prints the address of k but we are printing the value of k.
The same rule applies in **m.
Output is 5 5 5” -
Question 11 of 30
11. Question
2 pointsCorrect
Incorrect
-
Question 12 of 30
12. Question
2 points“What is the output of the following C code?
#include
int main()
{
int index;
for(index=1; index<=5; index++) { printf(""%d"", index); if (index==3) continue; } }"
Correct
“The continue statement is used inside loops. When a continue statement is encountered inside a loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop for the current iteration.
In the given code, there are no statements after continue statement , So it won’t effect on the output.
The loop will executes for five iterations,For each iteration it will print corresponding value i.e; 12345.”Incorrect
“The continue statement is used inside loops. When a continue statement is encountered inside a loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop for the current iteration.
In the given code, there are no statements after continue statement , So it won’t effect on the output.
The loop will executes for five iterations,For each iteration it will print corresponding value i.e; 12345.” -
Question 13 of 30
13. Question
2 points“Consider the following C code.
#include
#include
void main()
{
double pi = 3.1415926535;
int a = 1;
int i;
for(i=0; i < 3; i++) if(a = cos(pi * i/2) ) printf(""%d "",1); else printf(""%d "", 0); } What would the program print?"Correct
“→The for loop will execute three times for a given i values 0,1,2.
→For a given i = 0:
a = cos(pi * 0/2) [ PI*0 is 0]
a = cos(0) = 1, if condition true and it will print 1
→For a given i = 1
a = cos (pi/2) [pi*1 is pi]
a=cos(1.57075) whose value approximately equal to zero
a = 0, Here the condition is false then else part will execute and it will print 0
→For i = 2
a = cos(pi) [pi*2/2 is nothing but pi]
a = -1, ,Here also condition is true and it will execute if part and it will print “1”
→Finally it will print 101.”Incorrect
“→The for loop will execute three times for a given i values 0,1,2.
→For a given i = 0:
a = cos(pi * 0/2) [ PI*0 is 0]
a = cos(0) = 1, if condition true and it will print 1
→For a given i = 1
a = cos (pi/2) [pi*1 is pi]
a=cos(1.57075) whose value approximately equal to zero
a = 0, Here the condition is false then else part will execute and it will print 0
→For i = 2
a = cos(pi) [pi*2/2 is nothing but pi]
a = -1, ,Here also condition is true and it will execute if part and it will print “1”
→Finally it will print 101.” -
Question 14 of 30
14. Question
2 points“Write the output of the following C program
#include
int main (void)
{
int shifty;
shifty = 0570;
shifty = shifty >>4;
shifty = shifty <<6; printf(""the value of shifty is %o"",shifty); }"Correct
Incorrect
-
Question 15 of 30
15. Question
2 points“The following three ‘C’ language statements is equivalent to which single statement?
y=y+1;
z=x+y;
x=x+1”Correct
“From the below statements
y=y+1;
z=x+y;
x=x+1
First statement: “y” value is incremented by 1
Second statement : that incremented value is added to x and stored into “z”
Third statement : “y” value is incremented by 1
z = (x++) + (++y);
X++ post-increment , so it will perform action which is addition and later the value of “x” is incremented .
++y pre-increment , here first value “y” is incremented and updated value is added to value x.
Finally the result will store into z.
The sequence of operations you can find from the below statements
z=x+y; //z = x + (++y)
x=x+1 //z = (x++) + (++y)”Incorrect
“From the below statements
y=y+1;
z=x+y;
x=x+1
First statement: “y” value is incremented by 1
Second statement : that incremented value is added to x and stored into “z”
Third statement : “y” value is incremented by 1
z = (x++) + (++y);
X++ post-increment , so it will perform action which is addition and later the value of “x” is incremented .
++y pre-increment , here first value “y” is incremented and updated value is added to value x.
Finally the result will store into z.
The sequence of operations you can find from the below statements
z=x+y; //z = x + (++y)
x=x+1 //z = (x++) + (++y)” -
Question 16 of 30
16. Question
2 points“How many lines of output does the following C code produce?
#include
float i=2.0;
float j=1.0;
float sum = 0.0;
main()
{
while (i/j > 0.001)
{
j+=j;
sum=sum+(i/j);
printf(“”%f\n””, sum);
}
}”Correct
“Iteration-1:
while (1.000000 > 0.001)
{
j=2.0
sum=0+1.000000;
printf(“”%f\n””,sum); /* It will print 1.000000 */
}
Iteration-2: 1.500000
Iteration-3: 1.750000
Iteration-4: 1.875000
Iteration-5: 1.937500
Iteration-6: 1.968750
Iteration-7: 1.984375
Iteration-8: 1.992188
Iteration-9: 1.996094
Iteration-10: 1.998047
Iteration-11: 1.999023
The program will terminate after 11th iteration. So, it print 11 lines.”Incorrect
“Iteration-1:
while (1.000000 > 0.001)
{
j=2.0
sum=0+1.000000;
printf(“”%f\n””,sum); /* It will print 1.000000 */
}
Iteration-2: 1.500000
Iteration-3: 1.750000
Iteration-4: 1.875000
Iteration-5: 1.937500
Iteration-6: 1.968750
Iteration-7: 1.984375
Iteration-8: 1.992188
Iteration-9: 1.996094
Iteration-10: 1.998047
Iteration-11: 1.999023
The program will terminate after 11th iteration. So, it print 11 lines.” -
Question 17 of 30
17. Question
2 points“The output of the following code is:
int main()
{
static int x[ ]={1,2,3,4,5,6,7,8}
int i;
for(i=2;i<6;++i)
x[x[i]]=x[i];
for(i=0;i<8;++i)
printf(“%d”,x[i]);
Return 0;
}”Correct
Incorrect
-
Question 18 of 30
18. Question
2 points“Consider the following code fragment
void foo(int x, int y)
{
x+=y;
y+=x;
}
main()
{
int x=5.5;
foo(x,x);
}
What is the final value of x in both call by value and call by reference, respectively?”Correct
“Call by Value:
The call by value method of passing arguments to a function copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.
foo(x,x) —->foo(5,5)
Modification of x and y values won’t effect in the main program, So still x will hold value “5” because the data type is integer.
Call by Reference:
The call by reference method of passing arguments to a function copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. It means the changes made to the parameter affect the passed argument.
Function call foo(x,x)—foo(5,5) calls the function
void foo(int x, int y)
{
x+=y;
y+=x;
}
Here x and y variables, both pointing to same variable “x” in the main function.
So, if any modification done in the function it automatically reflect in the main function.
x+=y means x=x+y=5+5=10 // The variable “x” of main function will hold value 10 which used by both local variables of x and y
y+=x means u=y+x= 10+10=20 // Y value is 10 because , it point to variable ”x” in the main function.”Incorrect
“Call by Value:
The call by value method of passing arguments to a function copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.
foo(x,x) —->foo(5,5)
Modification of x and y values won’t effect in the main program, So still x will hold value “5” because the data type is integer.
Call by Reference:
The call by reference method of passing arguments to a function copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. It means the changes made to the parameter affect the passed argument.
Function call foo(x,x)—foo(5,5) calls the function
void foo(int x, int y)
{
x+=y;
y+=x;
}
Here x and y variables, both pointing to same variable “x” in the main function.
So, if any modification done in the function it automatically reflect in the main function.
x+=y means x=x+y=5+5=10 // The variable “x” of main function will hold value 10 which used by both local variables of x and y
y+=x means u=y+x= 10+10=20 // Y value is 10 because , it point to variable ”x” in the main function.” -
Question 19 of 30
19. Question
2 points“Consider the following C declaration
struct
{
short s[5];
union
{
float y;
long z;
}u;
}t;
Assume that the objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment consideration, is”Correct
short [5] = 5×2 = 10 max[float, long] = max [4, 8] = 8 Total = short[5] + max[float,long] = 10+8 = 18
Incorrect
short [5] = 5×2 = 10 max[float, long] = max [4, 8] = 8 Total = short[5] + max[float,long] = 10+8 = 18
-
Question 20 of 30
20. Question
2 points“Consider the following program fragment
if(a > b)
if(b > c)
s1;
else
s2;
s2 will be executed if”Correct
“Here, possibility to happen “dangling if” error. But according to else statement it is matched with above if statement only.
We can write code segment is like this because to avoid “dangling if”
if(a>b)
{
if(b>c)
{ s1; }
else
{ s2; }
}
→ To execute s2, it (a>b) should be TRUE. And it (b>c) should be FALSE.
Hence, Option-D is correct”Incorrect
“Here, possibility to happen “dangling if” error. But according to else statement it is matched with above if statement only.
We can write code segment is like this because to avoid “dangling if”
if(a>b)
{
if(b>c)
{ s1; }
else
{ s2; }
}
→ To execute s2, it (a>b) should be TRUE. And it (b>c) should be FALSE.
Hence, Option-D is correct” -
Question 21 of 30
21. Question
2 pointsIf n has 3, then the statement a[++n]=n++;
Correct
Given statement consists of three operators which are pre-increment , post-increment and equal to operator. According to operator precedence and associativity, the order of operators evaluation is post-increment,pre-increment and finally equal to operator. But one variable value is modifying multiple times in the same expression means that behaviour is undefined behaviour which is compiler dependent.
Incorrect
Given statement consists of three operators which are pre-increment , post-increment and equal to operator. According to operator precedence and associativity, the order of operators evaluation is post-increment,pre-increment and finally equal to operator. But one variable value is modifying multiple times in the same expression means that behaviour is undefined behaviour which is compiler dependent.
-
Question 22 of 30
22. Question
2 points“The following program
main()
{
inc();
inc();
inc();
}
inc()
{
static int x;
printf(“”%d””, ++x);
}”Correct
“In this question, we have to remind one point about “static” storage class.
Static storage class by default value is 0.
Step-1: We are calling inc( ) in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 0 with 1.
Step-2: Second inc() in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 1 with 2.
Step-3: Third inc() in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 2 with 3.
Note: The static storage class instructs the compiler to keep a local variable in existence during the life-time of the program instead of creating and destroying it each time it comes into and goes out of scope.”Incorrect
“In this question, we have to remind one point about “static” storage class.
Static storage class by default value is 0.
Step-1: We are calling inc( ) in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 0 with 1.
Step-2: Second inc() in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 1 with 2.
Step-3: Third inc() in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 2 with 3.
Note: The static storage class instructs the compiler to keep a local variable in existence during the life-time of the program instead of creating and destroying it each time it comes into and goes out of scope.” -
Question 23 of 30
23. Question
2 points“Consider the following program fragment
i=6720;
j=4;
while (i%j==0)
{
i=i/j;
j=j+1;
}
On termination j will have the value”Correct
“Initial values of i and j are 6720 and 4 respectively
Iteration 1:
i=6720
j=4
i%j==0 which is 6720%4 ==0 condition is true then
i=i/j=6720/4=1680
j=j+1=5
Iteration-2:
i=1630
j=5
i%j==0 which is 1680%5 ==0 condition is true then
i=i/j=1630/5=336
j=j+1=6
Iteration-3: i=336
j=6
i%j==0 which is 336%6 ==0 condition is true then
i=i/j=336/6=56
j=j+1=7
Iteration-4:
i=56
j=7
i%j==0 which is 56%7 ==0 condition is true then
i=i/j=56/7=8
j=j+1=8
Iteration-5:
i=8
j=8
i%j==0 which is 8%8 ==0 condition is true then
i=i/j=8/8=1
j=j+1=9
Iteration-6:
i=1
j=9
i%j==0 which is 1%9 ==0 condition is false.
At this iteration, the “j” value is 9.”Incorrect
“Initial values of i and j are 6720 and 4 respectively
Iteration 1:
i=6720
j=4
i%j==0 which is 6720%4 ==0 condition is true then
i=i/j=6720/4=1680
j=j+1=5
Iteration-2:
i=1630
j=5
i%j==0 which is 1680%5 ==0 condition is true then
i=i/j=1630/5=336
j=j+1=6
Iteration-3: i=336
j=6
i%j==0 which is 336%6 ==0 condition is true then
i=i/j=336/6=56
j=j+1=7
Iteration-4:
i=56
j=7
i%j==0 which is 56%7 ==0 condition is true then
i=i/j=56/7=8
j=j+1=8
Iteration-5:
i=8
j=8
i%j==0 which is 8%8 ==0 condition is true then
i=i/j=8/8=1
j=j+1=9
Iteration-6:
i=1
j=9
i%j==0 which is 1%9 ==0 condition is false.
At this iteration, the “j” value is 9.” -
Question 24 of 30
24. Question
2 points“Consider the following declaration:
int a, *b=&a, **c=&b;
The following program fragment
a=4;
**c=5;”Correct
“In the given program fragment, three variables are there
Ordinary variable -a // value will be stored
Pointer variable -b // address of variable will be storedPointer to pointer variable(double pointer) -c // address of pointer variable will stored.
a=4 means storing/assigning value to “a”.
**c means value at(value at(c)) =value at(value at(&b)) (c holds address of pointer “b”)
=value at(&a) (b holds the address of “a”)
Memory location of variable “a”, value 5 is stored/assigned into the variable.”Incorrect
“In the given program fragment, three variables are there
Ordinary variable -a // value will be stored
Pointer variable -b // address of variable will be storedPointer to pointer variable(double pointer) -c // address of pointer variable will stored.
a=4 means storing/assigning value to “a”.
**c means value at(value at(c)) =value at(value at(&b)) (c holds address of pointer “b”)
=value at(&a) (b holds the address of “a”)
Memory location of variable “a”, value 5 is stored/assigned into the variable.” -
Question 25 of 30
25. Question
2 points“The output of the following program is
main()
{
static int x[] = {1,2,3,4,5,6,7,8}
int i;
for (i=2; i<6; ++i)
x[x[i]]=x[i];
for (i=0; i<8; ++i)
printf(“”%d””, x[i]);
}”Correct
Incorrect
-
Question 26 of 30
26. Question
2 pointsWhich of the following has the compilation error in C?
Correct
“Option A: General declaration of integer variable.
Option B: General declaration of character variable.
Option C: It is type casting. But given cast also same type.
Option D: We have to include a file otherwise it treated as compiler error.”Incorrect
“Option A: General declaration of integer variable.
Option B: General declaration of character variable.
Option C: It is type casting. But given cast also same type.
Option D: We have to include a file otherwise it treated as compiler error.” -
Question 27 of 30
27. Question
2 points“The for loop
for (i=0; i<10; ++i)
printf(“”%d””, i&1);
prints:”Correct
Incorrect
-
Question 28 of 30
28. Question
2 points“What will be the output of following?
main()
{
static int a=3;
printf(“”%d””,a–);
if(a)
main();
}”Correct
“Step-1: initial a=3 but we are given storage class is static.
Step-2: In printf( ) we are given post decrement. So, it will print 3 then decrements.
Step-3: if(2) then we are calling main() function, a=2 because of static otherwise it will be 3 only.
Step-4: It will print 2 and next iteration will print 1.”Incorrect
“Step-1: initial a=3 but we are given storage class is static.
Step-2: In printf( ) we are given post decrement. So, it will print 3 then decrements.
Step-3: if(2) then we are calling main() function, a=2 because of static otherwise it will be 3 only.
Step-4: It will print 2 and next iteration will print 1.” -
Question 29 of 30
29. Question
2 pointsWhich of the following is not true in case of public inheritance in c++?
Correct
Incorrect
-
Question 30 of 30
30. Question
2 pointsCorrect
Incorrect
- Next Quiz Daily at navclasses.in 12 PM
- Paper 2 Sunday at navclasses.in
Study Paper 1 Topics for Free Click Here
Get subscription for Complete Preparation NTA NET JRF: https://unacademy.com/subscribe/TEWDQ
use my referral code for 10% additional discount: NAVCLASSES
Search Navdeep Kaur and start watching ongoing courses
NTA NET Paper 1
Paper 2 CS Programming Languages Comp Graphics Part 6
Quiz-summary
0 of 30 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
Information
Paper 1 Quiz helps u to Excel in NET JRF
Paper 1 All questions 2 Marks each
- Navdeep Kaur
- All the Best
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 30 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
-
Average marks Improve next time All the Best
-
Nice Keep it up, Stay Blessed
-
Awesome Great Marks, Keep doing
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- Answered
- Review
-
Question 1 of 30
1. Question
2 points“Which of the following statements is/are True regarding the solution to the visibility problem in 3D graphics ?
S1 : The Painter’s algorithm sorts polygons by depth and then paints (scan – converts) each Polygon onto the screen starting with the most nearest polygon. S2 : Backface Culling refers to eliminating geometry with back facing normals. Code :”
Correct
“Visibility problem in 3D graphics
1. Painter’s algorithm
– A depth sorting method
– Surfaces are sorted in the order of decreasing depth
– Surfaces are drawn in the sorted order, and overwrite the pixels in the frame buffer – Subtle difference from depth buffer approach: entire face drawn
– Two problems:
• It can be nontrivial to sort the surfaces
• There can be no solution for the sorting order
2. Back Face Culling
– Back faces: faces of opaque object which are “pointing away” from viewer
– Back face culling – remove back faces (supported by OpenGL)
How to detect back faces
– If we find backface, do not draw, save rendering resources
– There must be other forward face(s) closer to eye
– F is face of object we want to test if backface
– P is a point on F
– Form view vector, V as (eye – P)
– N is normal to face F
3. View-Frustum Culling
– Remove objects that are outside the viewing frustum
– Done by 3D clipping algorithm (e.g. Liang-Barsky)
4. Ray Tracing
– Ray tracing is another example of image space method
– Ray tracing: Cast a ray from eye through each pixel to the world
5. Z(Depth buffer algorithm)
Reference: https://web.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture08_p2.pdf“Incorrect
“Visibility problem in 3D graphics
1. Painter’s algorithm
– A depth sorting method
– Surfaces are sorted in the order of decreasing depth
– Surfaces are drawn in the sorted order, and overwrite the pixels in the frame buffer – Subtle difference from depth buffer approach: entire face drawn
– Two problems:
• It can be nontrivial to sort the surfaces
• There can be no solution for the sorting order
2. Back Face Culling
– Back faces: faces of opaque object which are “pointing away” from viewer
– Back face culling – remove back faces (supported by OpenGL)
How to detect back faces
– If we find backface, do not draw, save rendering resources
– There must be other forward face(s) closer to eye
– F is face of object we want to test if backface
– P is a point on F
– Form view vector, V as (eye – P)
– N is normal to face F
3. View-Frustum Culling
– Remove objects that are outside the viewing frustum
– Done by 3D clipping algorithm (e.g. Liang-Barsky)
4. Ray Tracing
– Ray tracing is another example of image space method
– Ray tracing: Cast a ray from eye through each pixel to the world
5. Z(Depth buffer algorithm)
Reference: https://web.cs.wpi.edu/~emmanuel/courses/cs543/slides/lecture08_p2.pdf“ -
Question 2 of 30
2. Question
2 pointsCorrect
“→ The above iterative code is computes the GCD of two numbers using euclidean algorithm.
→ The procedure is to subtract smaller number from larger. So that we can reduce larger number then doesn’t change the value of GCD.
→ if we performing number of iterations based on condition the larger of two numbers will end up with GCD.”Incorrect
“→ The above iterative code is computes the GCD of two numbers using euclidean algorithm.
→ The procedure is to subtract smaller number from larger. So that we can reduce larger number then doesn’t change the value of GCD.
→ if we performing number of iterations based on condition the larger of two numbers will end up with GCD.” -
Question 3 of 30
3. Question
2 pointsCorrect
Incorrect
-
Question 4 of 30
4. Question
2 pointsCorrect
Incorrect
-
Question 5 of 30
5. Question
2 pointsCorrect
“*(kd -> name +2) /* this is wrong statement */
We have to write *((*kd).name+2).
Note: They are specifically asked about a value stored at that location of the string by using “”*”” outside the brackets. Otherwise, option A and B would be correct.”Incorrect
“*(kd -> name +2) /* this is wrong statement */
We have to write *((*kd).name+2).
Note: They are specifically asked about a value stored at that location of the string by using “”*”” outside the brackets. Otherwise, option A and B would be correct.” -
Question 6 of 30
6. Question
2 pointsCorrect
Incorrect
-
Question 7 of 30
7. Question
2 pointsCorrect
“Step-1: In main function, number variable has been initialized to 30.
Step-2: We pass address of number as parameters in the square function. As per the concept of function overloading in C++ the second square function will be executed.
Step-3: –(*y) will be executed first since decrement operator has the higher precedence than multiplication.
*x = (*x) * –(*y);
*x = 30 * 29;
*x = 870
Note: x is a pointer variable and it holds the address of the variable number.”Incorrect
“Step-1: In main function, number variable has been initialized to 30.
Step-2: We pass address of number as parameters in the square function. As per the concept of function overloading in C++ the second square function will be executed.
Step-3: –(*y) will be executed first since decrement operator has the higher precedence than multiplication.
*x = (*x) * –(*y);
*x = 30 * 29;
*x = 870
Note: x is a pointer variable and it holds the address of the variable number.” -
Question 8 of 30
8. Question
2 points“Consider the following C function:
int f(int n)
{
static int i = 1;
if(n >= 5) return n;
n = n+i;
i++;
return f(n);
}
The value returned by f(1) is”Correct
“The variable “i” is static variable and the value of that variable will be retained between multiple function calls.
first line of f() is executed only once.
Depending upon the value “n” and “i”, the function f() will until n>=5.
You can find the tracing of function f() from the below Execution of f(1)
i = 1
n = 2
i = 2
Call f(2)
i = 2
n = 4
i = 3
Call f(4)
i = 3
n = 7
i = 4
Call f(7)
since n >= 5 return n(7) with return value = 7”Incorrect
“The variable “i” is static variable and the value of that variable will be retained between multiple function calls.
first line of f() is executed only once.
Depending upon the value “n” and “i”, the function f() will until n>=5.
You can find the tracing of function f() from the below Execution of f(1)
i = 1
n = 2
i = 2
Call f(2)
i = 2
n = 4
i = 3
Call f(4)
i = 3
n = 7
i = 4
Call f(7)
since n >= 5 return n(7) with return value = 7” -
Question 9 of 30
9. Question
2 points“Consider the following code segment
for (int k=0; k<20; k=k+2)
{
if (k % 3 == 1)
system.out.print(k+ “” “”)
}
What is printed as a result of executing the code segment?”Correct
“for loop starts from 0 to 20 and increments with 2 at each iteration.
k = 0 % 3 = 0
k = 2 % 3 = 2
k = 4 % 3 = 1 // prints 4
k = 6 % 3 = 0
k = 8 % 3 = 2
k = 10 % 3 = 1 // prints 10
k = 12 % 3 = 0
k = 14 % 3 = 2
k = 16 % 3 = 1 // prints 16
k = 18 % 3 = 0
So, Output is 4 10 16”Incorrect
“for loop starts from 0 to 20 and increments with 2 at each iteration.
k = 0 % 3 = 0
k = 2 % 3 = 2
k = 4 % 3 = 1 // prints 4
k = 6 % 3 = 0
k = 8 % 3 = 2
k = 10 % 3 = 1 // prints 10
k = 12 % 3 = 0
k = 14 % 3 = 2
k = 16 % 3 = 1 // prints 16
k = 18 % 3 = 0
So, Output is 4 10 16” -
Question 10 of 30
10. Question
2 pointsCorrect
“If we are given p instead of *p then it prints the address of k but we are printing the value of k.
The same rule applies in **m.
Output is 5 5 5”Incorrect
“If we are given p instead of *p then it prints the address of k but we are printing the value of k.
The same rule applies in **m.
Output is 5 5 5” -
Question 11 of 30
11. Question
2 pointsCorrect
Incorrect
-
Question 12 of 30
12. Question
2 points“What is the output of the following C code?
#include
int main()
{
int index;
for(index=1; index<=5; index++) { printf(""%d"", index); if (index==3) continue; } }"
Correct
“The continue statement is used inside loops. When a continue statement is encountered inside a loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop for the current iteration.
In the given code, there are no statements after continue statement , So it won’t effect on the output.
The loop will executes for five iterations,For each iteration it will print corresponding value i.e; 12345.”Incorrect
“The continue statement is used inside loops. When a continue statement is encountered inside a loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop for the current iteration.
In the given code, there are no statements after continue statement , So it won’t effect on the output.
The loop will executes for five iterations,For each iteration it will print corresponding value i.e; 12345.” -
Question 13 of 30
13. Question
2 points“Consider the following C code.
#include
#include
void main()
{
double pi = 3.1415926535;
int a = 1;
int i;
for(i=0; i < 3; i++) if(a = cos(pi * i/2) ) printf(""%d "",1); else printf(""%d "", 0); } What would the program print?"Correct
“→The for loop will execute three times for a given i values 0,1,2.
→For a given i = 0:
a = cos(pi * 0/2) [ PI*0 is 0]
a = cos(0) = 1, if condition true and it will print 1
→For a given i = 1
a = cos (pi/2) [pi*1 is pi]
a=cos(1.57075) whose value approximately equal to zero
a = 0, Here the condition is false then else part will execute and it will print 0
→For i = 2
a = cos(pi) [pi*2/2 is nothing but pi]
a = -1, ,Here also condition is true and it will execute if part and it will print “1”
→Finally it will print 101.”Incorrect
“→The for loop will execute three times for a given i values 0,1,2.
→For a given i = 0:
a = cos(pi * 0/2) [ PI*0 is 0]
a = cos(0) = 1, if condition true and it will print 1
→For a given i = 1
a = cos (pi/2) [pi*1 is pi]
a=cos(1.57075) whose value approximately equal to zero
a = 0, Here the condition is false then else part will execute and it will print 0
→For i = 2
a = cos(pi) [pi*2/2 is nothing but pi]
a = -1, ,Here also condition is true and it will execute if part and it will print “1”
→Finally it will print 101.” -
Question 14 of 30
14. Question
2 points“Write the output of the following C program
#include
int main (void)
{
int shifty;
shifty = 0570;
shifty = shifty >>4;
shifty = shifty <<6; printf(""the value of shifty is %o"",shifty); }"Correct
Incorrect
-
Question 15 of 30
15. Question
2 points“The following three ‘C’ language statements is equivalent to which single statement?
y=y+1;
z=x+y;
x=x+1”Correct
“From the below statements
y=y+1;
z=x+y;
x=x+1
First statement: “y” value is incremented by 1
Second statement : that incremented value is added to x and stored into “z”
Third statement : “y” value is incremented by 1
z = (x++) + (++y);
X++ post-increment , so it will perform action which is addition and later the value of “x” is incremented .
++y pre-increment , here first value “y” is incremented and updated value is added to value x.
Finally the result will store into z.
The sequence of operations you can find from the below statements
z=x+y; //z = x + (++y)
x=x+1 //z = (x++) + (++y)”Incorrect
“From the below statements
y=y+1;
z=x+y;
x=x+1
First statement: “y” value is incremented by 1
Second statement : that incremented value is added to x and stored into “z”
Third statement : “y” value is incremented by 1
z = (x++) + (++y);
X++ post-increment , so it will perform action which is addition and later the value of “x” is incremented .
++y pre-increment , here first value “y” is incremented and updated value is added to value x.
Finally the result will store into z.
The sequence of operations you can find from the below statements
z=x+y; //z = x + (++y)
x=x+1 //z = (x++) + (++y)” -
Question 16 of 30
16. Question
2 points“How many lines of output does the following C code produce?
#include
float i=2.0;
float j=1.0;
float sum = 0.0;
main()
{
while (i/j > 0.001)
{
j+=j;
sum=sum+(i/j);
printf(“”%f\n””, sum);
}
}”Correct
“Iteration-1:
while (1.000000 > 0.001)
{
j=2.0
sum=0+1.000000;
printf(“”%f\n””,sum); /* It will print 1.000000 */
}
Iteration-2: 1.500000
Iteration-3: 1.750000
Iteration-4: 1.875000
Iteration-5: 1.937500
Iteration-6: 1.968750
Iteration-7: 1.984375
Iteration-8: 1.992188
Iteration-9: 1.996094
Iteration-10: 1.998047
Iteration-11: 1.999023
The program will terminate after 11th iteration. So, it print 11 lines.”Incorrect
“Iteration-1:
while (1.000000 > 0.001)
{
j=2.0
sum=0+1.000000;
printf(“”%f\n””,sum); /* It will print 1.000000 */
}
Iteration-2: 1.500000
Iteration-3: 1.750000
Iteration-4: 1.875000
Iteration-5: 1.937500
Iteration-6: 1.968750
Iteration-7: 1.984375
Iteration-8: 1.992188
Iteration-9: 1.996094
Iteration-10: 1.998047
Iteration-11: 1.999023
The program will terminate after 11th iteration. So, it print 11 lines.” -
Question 17 of 30
17. Question
2 points“The output of the following code is:
int main()
{
static int x[ ]={1,2,3,4,5,6,7,8}
int i;
for(i=2;i<6;++i)
x[x[i]]=x[i];
for(i=0;i<8;++i)
printf(“%d”,x[i]);
Return 0;
}”Correct
Incorrect
-
Question 18 of 30
18. Question
2 points“Consider the following code fragment
void foo(int x, int y)
{
x+=y;
y+=x;
}
main()
{
int x=5.5;
foo(x,x);
}
What is the final value of x in both call by value and call by reference, respectively?”Correct
“Call by Value:
The call by value method of passing arguments to a function copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.
foo(x,x) —->foo(5,5)
Modification of x and y values won’t effect in the main program, So still x will hold value “5” because the data type is integer.
Call by Reference:
The call by reference method of passing arguments to a function copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. It means the changes made to the parameter affect the passed argument.
Function call foo(x,x)—foo(5,5) calls the function
void foo(int x, int y)
{
x+=y;
y+=x;
}
Here x and y variables, both pointing to same variable “x” in the main function.
So, if any modification done in the function it automatically reflect in the main function.
x+=y means x=x+y=5+5=10 // The variable “x” of main function will hold value 10 which used by both local variables of x and y
y+=x means u=y+x= 10+10=20 // Y value is 10 because , it point to variable ”x” in the main function.”Incorrect
“Call by Value:
The call by value method of passing arguments to a function copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.
foo(x,x) —->foo(5,5)
Modification of x and y values won’t effect in the main program, So still x will hold value “5” because the data type is integer.
Call by Reference:
The call by reference method of passing arguments to a function copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. It means the changes made to the parameter affect the passed argument.
Function call foo(x,x)—foo(5,5) calls the function
void foo(int x, int y)
{
x+=y;
y+=x;
}
Here x and y variables, both pointing to same variable “x” in the main function.
So, if any modification done in the function it automatically reflect in the main function.
x+=y means x=x+y=5+5=10 // The variable “x” of main function will hold value 10 which used by both local variables of x and y
y+=x means u=y+x= 10+10=20 // Y value is 10 because , it point to variable ”x” in the main function.” -
Question 19 of 30
19. Question
2 points“Consider the following C declaration
struct
{
short s[5];
union
{
float y;
long z;
}u;
}t;
Assume that the objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment consideration, is”Correct
short [5] = 5×2 = 10 max[float, long] = max [4, 8] = 8 Total = short[5] + max[float,long] = 10+8 = 18
Incorrect
short [5] = 5×2 = 10 max[float, long] = max [4, 8] = 8 Total = short[5] + max[float,long] = 10+8 = 18
-
Question 20 of 30
20. Question
2 points“Consider the following program fragment
if(a > b)
if(b > c)
s1;
else
s2;
s2 will be executed if”Correct
“Here, possibility to happen “dangling if” error. But according to else statement it is matched with above if statement only.
We can write code segment is like this because to avoid “dangling if”
if(a>b)
{
if(b>c)
{ s1; }
else
{ s2; }
}
→ To execute s2, it (a>b) should be TRUE. And it (b>c) should be FALSE.
Hence, Option-D is correct”Incorrect
“Here, possibility to happen “dangling if” error. But according to else statement it is matched with above if statement only.
We can write code segment is like this because to avoid “dangling if”
if(a>b)
{
if(b>c)
{ s1; }
else
{ s2; }
}
→ To execute s2, it (a>b) should be TRUE. And it (b>c) should be FALSE.
Hence, Option-D is correct” -
Question 21 of 30
21. Question
2 pointsIf n has 3, then the statement a[++n]=n++;
Correct
Given statement consists of three operators which are pre-increment , post-increment and equal to operator. According to operator precedence and associativity, the order of operators evaluation is post-increment,pre-increment and finally equal to operator. But one variable value is modifying multiple times in the same expression means that behaviour is undefined behaviour which is compiler dependent.
Incorrect
Given statement consists of three operators which are pre-increment , post-increment and equal to operator. According to operator precedence and associativity, the order of operators evaluation is post-increment,pre-increment and finally equal to operator. But one variable value is modifying multiple times in the same expression means that behaviour is undefined behaviour which is compiler dependent.
-
Question 22 of 30
22. Question
2 points“The following program
main()
{
inc();
inc();
inc();
}
inc()
{
static int x;
printf(“”%d””, ++x);
}”Correct
“In this question, we have to remind one point about “static” storage class.
Static storage class by default value is 0.
Step-1: We are calling inc( ) in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 0 with 1.
Step-2: Second inc() in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 1 with 2.
Step-3: Third inc() in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 2 with 3.
Note: The static storage class instructs the compiler to keep a local variable in existence during the life-time of the program instead of creating and destroying it each time it comes into and goes out of scope.”Incorrect
“In this question, we have to remind one point about “static” storage class.
Static storage class by default value is 0.
Step-1: We are calling inc( ) in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 0 with 1.
Step-2: Second inc() in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 1 with 2.
Step-3: Third inc() in main function. So, it will enter into inc() function.
Here, we are using pre increment function, so it replaced 2 with 3.
Note: The static storage class instructs the compiler to keep a local variable in existence during the life-time of the program instead of creating and destroying it each time it comes into and goes out of scope.” -
Question 23 of 30
23. Question
2 points“Consider the following program fragment
i=6720;
j=4;
while (i%j==0)
{
i=i/j;
j=j+1;
}
On termination j will have the value”Correct
“Initial values of i and j are 6720 and 4 respectively
Iteration 1:
i=6720
j=4
i%j==0 which is 6720%4 ==0 condition is true then
i=i/j=6720/4=1680
j=j+1=5
Iteration-2:
i=1630
j=5
i%j==0 which is 1680%5 ==0 condition is true then
i=i/j=1630/5=336
j=j+1=6
Iteration-3: i=336
j=6
i%j==0 which is 336%6 ==0 condition is true then
i=i/j=336/6=56
j=j+1=7
Iteration-4:
i=56
j=7
i%j==0 which is 56%7 ==0 condition is true then
i=i/j=56/7=8
j=j+1=8
Iteration-5:
i=8
j=8
i%j==0 which is 8%8 ==0 condition is true then
i=i/j=8/8=1
j=j+1=9
Iteration-6:
i=1
j=9
i%j==0 which is 1%9 ==0 condition is false.
At this iteration, the “j” value is 9.”Incorrect
“Initial values of i and j are 6720 and 4 respectively
Iteration 1:
i=6720
j=4
i%j==0 which is 6720%4 ==0 condition is true then
i=i/j=6720/4=1680
j=j+1=5
Iteration-2:
i=1630
j=5
i%j==0 which is 1680%5 ==0 condition is true then
i=i/j=1630/5=336
j=j+1=6
Iteration-3: i=336
j=6
i%j==0 which is 336%6 ==0 condition is true then
i=i/j=336/6=56
j=j+1=7
Iteration-4:
i=56
j=7
i%j==0 which is 56%7 ==0 condition is true then
i=i/j=56/7=8
j=j+1=8
Iteration-5:
i=8
j=8
i%j==0 which is 8%8 ==0 condition is true then
i=i/j=8/8=1
j=j+1=9
Iteration-6:
i=1
j=9
i%j==0 which is 1%9 ==0 condition is false.
At this iteration, the “j” value is 9.” -
Question 24 of 30
24. Question
2 points“Consider the following declaration:
int a, *b=&a, **c=&b;
The following program fragment
a=4;
**c=5;”Correct
“In the given program fragment, three variables are there
Ordinary variable -a // value will be stored
Pointer variable -b // address of variable will be storedPointer to pointer variable(double pointer) -c // address of pointer variable will stored.
a=4 means storing/assigning value to “a”.
**c means value at(value at(c)) =value at(value at(&b)) (c holds address of pointer “b”)
=value at(&a) (b holds the address of “a”)
Memory location of variable “a”, value 5 is stored/assigned into the variable.”Incorrect
“In the given program fragment, three variables are there
Ordinary variable -a // value will be stored
Pointer variable -b // address of variable will be storedPointer to pointer variable(double pointer) -c // address of pointer variable will stored.
a=4 means storing/assigning value to “a”.
**c means value at(value at(c)) =value at(value at(&b)) (c holds address of pointer “b”)
=value at(&a) (b holds the address of “a”)
Memory location of variable “a”, value 5 is stored/assigned into the variable.” -
Question 25 of 30
25. Question
2 points“The output of the following program is
main()
{
static int x[] = {1,2,3,4,5,6,7,8}
int i;
for (i=2; i<6; ++i)
x[x[i]]=x[i];
for (i=0; i<8; ++i)
printf(“”%d””, x[i]);
}”Correct
Incorrect
-
Question 26 of 30
26. Question
2 pointsWhich of the following has the compilation error in C?
Correct
“Option A: General declaration of integer variable.
Option B: General declaration of character variable.
Option C: It is type casting. But given cast also same type.
Option D: We have to include a file otherwise it treated as compiler error.”Incorrect
“Option A: General declaration of integer variable.
Option B: General declaration of character variable.
Option C: It is type casting. But given cast also same type.
Option D: We have to include a file otherwise it treated as compiler error.” -
Question 27 of 30
27. Question
2 points“The for loop
for (i=0; i<10; ++i)
printf(“”%d””, i&1);
prints:”Correct
Incorrect
-
Question 28 of 30
28. Question
2 points“What will be the output of following?
main()
{
static int a=3;
printf(“”%d””,a–);
if(a)
main();
}”Correct
“Step-1: initial a=3 but we are given storage class is static.
Step-2: In printf( ) we are given post decrement. So, it will print 3 then decrements.
Step-3: if(2) then we are calling main() function, a=2 because of static otherwise it will be 3 only.
Step-4: It will print 2 and next iteration will print 1.”Incorrect
“Step-1: initial a=3 but we are given storage class is static.
Step-2: In printf( ) we are given post decrement. So, it will print 3 then decrements.
Step-3: if(2) then we are calling main() function, a=2 because of static otherwise it will be 3 only.
Step-4: It will print 2 and next iteration will print 1.” -
Question 29 of 30
29. Question
2 pointsWhich of the following is not true in case of public inheritance in c++?
Correct
Incorrect
-
Question 30 of 30
30. Question
2 pointsCorrect
Incorrect