Recent questions tagged programming-in-c

33 33 votes
7 answers 7 answers
18.3k
18.3k views
Consider the C program below. What does it print?# include <stdio.h # define swap1 (a, b) tmp = a; a = b; b = tmp void swap2 ( int a, int b) { int tmp; tmp = a; a = b; b ...
60 60 votes
4 answers 4 answers
18.8k
18.8k views
What is the output printed by the following C code?# include <stdio.h int main () { char a [6] = "world"; int i, j; for (i = 0, j = 5; i < j; a [i++] = a [j ]); printf ("...
61 61 votes
3 answers 3 answers
15.8k
15.8k views
What does the following program print?#include<stdio.h void f(int *p, int *q) { p=q; *p=2; } int i=0, j=1; int main() { f(&i, &j); printf("%d %d\n", i,j); return 0; }$2 \...
62 62 votes
6 answers 6 answers
21.2k
21.2k views
Consider the following C code segment.int a, b, c = 0; void prtFun(void); main() { static int a = 1; /* Line 1 */ prtFun(); a += 1; prtFun(); printf(“ \n %d %d ”, a, b); ...
88 88 votes
5 answers 5 answers
37.1k
37.1k views
What does the following fragment of C program print?char c[] = "GATE2011"; char *p = c; printf("%s", p + p[3] - p );$\text{GATE2011}$$\text{E2011}$$2011$$011$
60 60 votes
6 answers 6 answers
13.7k
13.7k views
Consider the C function given below.int f(int j) { static int i = 50; int k; if (i == j) { printf("something"); k = f(i); return 0; } else return 0; }Which one of the fol...
145 145 votes
10 answers 10 answers
68.3k
68.3k views
For a C program accessing $\mathbf{X[i] [j] [k]}$, the following intermediate code is generated by a compiler. Assume that the size of an integer is $32$ bits and the siz...
224 224 votes
5 answers 5 answers
30.0k
30.0k views
Suppose $n$ and $p$ are unsigned int variables in a C program. We wish to set $p$ to $^nC_3$. If $n$ is large, which one of the following statements is most likely to set...
123 123 votes
8 answers 8 answers
32.4k
32.4k views
Consider this C code to swap two integers and these five statements: the codevoid swap (int *px, int *py) { *px = *px - *py; *py = *px + *py; *px = *py - *px; }S1: ...
101 101 votes
6 answers 6 answers
28.1k
28.1k views
Consider the following program in C language:#include <stdio.h main() { int i; int*pi = &i; scanf("%d",pi); printf("%d\n", i+5); }Which one of the following statements is...
82 82 votes
10 answers 10 answers
28.7k
28.7k views
Consider the following C program:double foo (double); /* Line 1 */ int main() { double da, db; //input da db = foo(da); } double foo (double a) { return a; }The above cod...
61 61 votes
8 answers 8 answers
28.8k
28.8k views
What does the following C-statement declare?int (*f) (int * );A function that takes an integer pointer as argument and returns an integerA function that takes an integer ...
60 60 votes
4 answers 4 answers
22.4k
22.4k views
Consider the following C program segment:char p[20]; int i; char* s = "string"; int length = strlen(s); for(i = 0; i < length; i++) p[i] = s[length-i]; printf("%s", p);Th...
49 49 votes
4 answers 4 answers
21.4k
21.4k views
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:$5$$6$$7$$8$
35 35 votes
5 answers 5 answers
20.3k
20.3k views
Consider the following functionvoid swap(int a, int b) { int temp; temp = a; a = b; b = temp; }In order to exchange the values of two variables $x$ and $y$.call $swap(x, ...
65 65 votes
6 answers 6 answers
20.3k
20.3k views
Consider the C program shown below:#include<stdio.h #define print(x) printf("%d", x) int x; void Q(int z) { z+=x; print(z); } void P(int *y) { int x = *y + 2; Q(x); *y = ...
117 117 votes
7 answers 7 answers
43.7k
43.7k views
Assume the following C variable declaration:int *A[10], B[10][10];Of the following expressions:$A $$A [3]$$B $$B [3]$which will not give compile-time errors if used as le...
59 59 votes
3 answers 3 answers
17.4k
17.4k views
The C language is:A context free languageA context sensitive languageA regular languageParsable fully only by a Turing machine
60 60 votes
8 answers 8 answers
39.1k
39.1k views
Consider the following declaration of a two-dimensional array in C:char $a[100][100]$;Assuming that the main memory is byte-addressable and that the array is stored start...
63 63 votes
2 answers 2 answers
14.9k
14.9k views
In the C language:At most one activation record exists between the current activation record and the activation record for the mainThe number of activation records betwee...
99 99 votes
4 answers 4 answers
40.5k
40.5k views
Consider the following three C functions:$[P1]$ int *g(void) { int x = 10; return (&x); }$[P2]$ int *g(void) { int *px; *px = 10; return px; }$[P3]$ int *g(void) { int *p...
43 43 votes
6 answers 6 answers
21.1k
21.1k views
What is printed by the print statements in the program $P1$ assuming call by reference parameter passing?Program P1() { x = 10; y = 3; func1(y,x,x); print x; print y; } f...
52 52 votes
6 answers 6 answers
21.4k
21.4k views
The value of $j$ at the end of the execution of the following C program:int incr (int i) { static int count = 0; count = count + i; return (count); } main () { int i, j; ...
81 81 votes
4 answers 4 answers
32.2k
32.2k views
Consider the following C declaration:struct { short x[5]; union { float y; long z; } u; )t;Assume that the objects of the type short, float and long occupy $2$ bytes, $4$...
79 79 votes
4 answers 4 answers
19.6k
19.6k views
The most appropriate matching for the following pairs$$\begin{array}{|ll|ll|}\hline X: & \text{m = malloc(5); m = NULL;} & 1: & \text{using dangling pointers} \\\hline Y...
60 60 votes
5 answers 5 answers
24.6k
24.6k views
The following C declarations:struct node { int i: float j; }; struct node *s[10];define s to be:An array, each element of which is a pointer to a structure of type nodeA ...
49 49 votes
7 answers 7 answers
15.6k
15.6k views
Choose the correct option to fill $?1$ and $?2$ so that the program below prints an input string in reverse order. Assume that the input string is terminated by a new lin...
69 69 votes
6 answers 6 answers
26.6k
26.6k views
What is printed by the following C program?int f(int x, int *py, int ppz) { int y, z; ppz += 1; z = ppz; // corrected z = *ppz; to z = ppz; *py += 2; y = *py; x += 3;...
41 41 votes
5 answers 5 answers
18.6k
18.6k views
Which combination of the integer variables $x, y,$ and $z$ makes the variable $a$ get the value $4$ in the following expression?$$a=(x y)?((x z) ?x:z): ((y z) ?y:z)$$$...
3 3 votes
2 2 answers
1.1k
1.1k views
#include<stdio.h #define decode(s,t,a,m,p,e,d)m s u t #define begin decode(a,n,i,m,a,t,e) int begin() { printf("hello"); }