# Recent questions tagged programming-in-c

1
Consider the following $\text{ANSI C}$ program. #include <stdio.h> int main() { int arr[4][5]; int i, j; for (i=0; i<4; i++) ​​​​​​{ for (j=0; j<5; j++) { arr[i][j] = 10 * i + j; } } printf(“%d”, *(arr[1]+9)); return 0; } What is the output of the above program? $14$ $20$ $24$ $30$
2
Consider the following $\text{ANSI C}$ program: #include <stdio.h> #include <stdlib.h> struct Node{ int value; struct Node *next;}; int main( ) { struct Node *boxE, *head, *boxN; int index=0; boxE=head= (struct Node *) malloc(sizeof(struct Node)) ... $\textsf{return}$ which will be reported as an error by the compiler It dereferences an uninitialized pointer that may result in a run-time error
1 vote
3
Consider the following$\text{ ANSI C}$ program. #include <stdio.h> int main() { int i, j, count; count=0; i=0; for (j=-3; j<=3; j++) { if (( j >= 0) && (i++)) count = count + j; } count = count + ... will compile successfully and output $10$ when executed The program will compile successfully and output $8$ when executed The program will compile successfully and output $13$ when executed
1 vote
4
Consider the following pseudo-code fragment, where $a$ and $b$ are integer variables that have been initialized: /* Pre-conditions : $(a > 1 \wedge a < b)$ */ /* Assume that overflow never occurs */ int $x=0$; int $p=1$; while $(p<b) \{$ $p=p*a$; $x=x+1$; $\}$ ... $\lfloor \: \: \rfloor$ means floor */ $\lfloor \log_a^b \rfloor$ /* $\lceil \: \: \rceil$ means ceil */
5
Suppose you are compiling on a machine with $1$-byte chars, $2$-byte shorts, $4$-byte ints, and $8$-byte doubles, and with alignment rules that require the address of every primitive data element to be an integer multiple of the element's size. Suppose further that the compiler is not ... ; double r; int i; } A[10]; /*10 element array of structs */ $150$ bytes $320$ bytes $240$ bytes $200$ bytes
6
7
An external variable is globally accessible by all functions has a declaration “extern” associated with it when declared within a function will be initialized to $0$ if not initialized all of these
1 vote
8
If initialization is a part of declaration of a structure, then storage class can be automatic register static anything
1 vote
9
For $x$ and $y$ are variables as declared below $\textit{double }x=0.005, \: y = – 0.01;$ What is the value of $\text{ceil }(x+y)$, where $\text{ceil }$ is a function to compute ceiling of a number? $1$ $0$ $0.005$ $0.5$
In C programming language, if the first and the second operands of operator $+$ are of types int and float, respectively, the result will be of type int float char long int
What will be the value of $x$ and $y$ after execution of the following statement(C language) n = 5; x = n++; y = -x; $5,-4$ $6,-5$ $6,-6$ $5,-5$
The question is based on the following program fragment. f(intY[10],int x){ int u,j,k; i=0;j=9; do{ k=(i+j)/2; if(Y[k] < x) i=k; else j=k; } while((Y[k]!=x) && (i<j)); if (Y[k]==x) printf( x is in the array. ); else printf( x is not in the array. ); } On which of the following contents of ... $x>2$ $Y$ is $[2\;4\;6\;8\;10\;12\;14\;16\;18\;20]$ and $2<x<20$ and $'x'$ is even