Programming Languages and Computer Graphics – Previous Year Questions
229 questions from past UGC NET Paper 2 – Computer Science papers, each with the correct answer. Open any question for its explanation.
- Consider the following C program:#include<stdio.h> int main() { int x[] = {2,4,6,8,10}; int a, b = 0, *y = x + 4; for (a = 0; a < 5; a++) { b = b + (*y - a) - *(y - a); } printf("%d\n", b); return 0; } What will be the…
- Which of the following are TRUE about constructors in C++? (A) A constructor can be overloaded. (B) A constructor does not have a return type. (C) A constructor must be declared as a friend function. (D) A constructor i…
- What is the output of the following program?#include<stdio.h> void f1(char *x, char *y) { char *t1; t1 = x; x = y; y = t1; } void f2(char **x, char **y) { char *t1; t1 = *x; *x = *y; *y = t1; } int main() { char *a = "O…
- Which of the following C++ statements correctly declares an abstract class?
- Consider the following C++ program:#include<iostream> using namespace std; void swap(int &x, int &y) { int temp = x; x = y; y = temp; } int main() { int a = 5, b = 10; swap(a, b); swap(a, b); cout << a << " " << b; retu…
- What is the output of the code given below?#include<iostream> using namespace std; class Base { public: Base() { cout << "Base Const"; } virtual ~Base() { cout << "Base dest"; } }; class Derived : public Base { public:…
- Consider the following C code:#include<stdio.h> int temp = 0; int fun(int x, int y) { int z; temp++; if (y == 3) return (x*x*x); else { z = fun(x, y/3); return (z*z*z); } } int main() { fun(4, 81); printf("%d", temp); }…
- Match List I with List IIList I List II (A) HTML (I) Allows for dynamic and interactive web pages. (B) DHTML (II) Defines the structure of web pages. (C) XML (III) Object-oriented programming language for web applicatio…
- Arrange the following steps of file handling in C in the correct order: (A) Close the file (B) Read from or write to the file (C) Open the file (D) Check for error Choose the correct answer from the options given below:
- What will be the output of the following C code?#include<stdio.h> void main() { int arr[5] = {10,20,30,40,50}; int *p = (int*)(&arr + 1); printf("%d %d", *(arr+1), *(p-1)); }
- Find the output of the following code:#include<stdio.h> void main() { int arr[] = {1, 2, 3, 4, 5}; int *p = arr; printf("%d", *p++); printf("%d", *(p+1)); }
- Consider a triangle PQR with coordinates P(0,0), Q(2,2) and R(10,4). If this triangle is to be magnified to four times its size while keeping R(10,4) fixed, then the coordinates of the magnified triangle are:
- Which of the following statements is TRUE?
- What is the output of the following program?#include<stdio.h> int main() { int i = 3; while (i--) { int i = 10; i--; printf("%d", i); } printf("%d", i); }
- The hue of a colour is related to its:
- What is the output of the following program?#include <stdio.h> #define SQR(x) (x*x) int main() { int a, b = 3; a = SQR(b+2); printf("%d", a); return 0; }
- Consider the three points P1(1, 2, 0), P2(3, 6, 20) and P3(2, 4, 6) and a viewpoint C(0, 0, −10). Choose the correct options. (A) P1 obscures P2 if viewed from C. (B) P2 obscures P1 if viewed from C. (C) P3 does not obs…
- Which of the statements are CORRECT? (A) Constructors are invoked automatically when objects are created. (B) Constructors do not have return types, not even void, and therefore cannot return values. (C) Constructors ca…
- Match List I with List IIList I List II (a) Bresenham (I) Hidden surface removal (b) Cohen-Sutherland algorithm (II) Line drawing (c) Sutherland-Hodgeman algorithm (III) Line clipping (d) Z-Buffer algorithm (IV) Polygon…
- Consider the following code segment:int arr[] = {0,1,2,3,4}; int i = 1, *ptr; ptr = arr + 2; Arrange the following printf statements in increasing order of their output: (a) printf("%d", ptr[i]); (b) printf("%d", ptr[i+…
- Statement (I): A friend function and the member functions of a friend class can directly access private and protected data. Statement (II): A friend function can access private data through the member functions of the b…
- Match List I with List IIList I List II A. Bezier curves I. 3-D objects that have translational/rotational symmetry B. B-Splines II. Fractal geometry C. Sweep representations III. Bias and tension D. Natural objects IV.…
- What will be the output of the following code?#include <stdio.h> int main() { int a, b, c; a = 0x10; b = 010; c = a + b; printf("%d", c); return 0; }
- A three-dimensional array in C++ is declared as int A[a][b][c]. Array elements are stored in row-major order and indexing begins from 0. The address of the element A[r][s][t], in terms of the word length w of an integer…
- What is the output of the following code?main() { struct s1 { char *z; int i; struct s1 *p; }; static struct s1 a[] = { {"Nagpur", 1, a+1}, {"Raipur", 2, a+2}, {"Kanpur", 3, a} }; struct s1 *ptr = a; printf("%s %s %s\n"…
- The Sutherland-Hodgeman method is used on
- What is x in the following program?#include <stdio.h> int main() { typedef int (*(*arrfptr[3])())[10]; arrfptr x; return 0; }
- How will you free the memory allocated by the following program?#include <stdio.h> #include <stdlib.h> #define MAXROW 3 #define MAXCOL 4 int main() { int **p, i, j; p = (int **) malloc(MAXROW * sizeof(int*)); return 0; }
- The clipping process in computer graphics is used for
- Consider the rectangle with vertices (0, 0), (0, 2), (3, 0), (3, 2). It is scaled by 2 along the x-axis and 3 along the y-axis. The new coordinates of the rectangle are