Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Webpage
Programming in C.
Recursion.
Filter
Recent
Hot!
Most votes
Most answers
Most views
Previous GATE
Featured
Recent questions in Programming and DS
0
votes
2
answers
3561
ISRO 2011-ECE Stack
In what order the elements of a pushdown stack are accessed? a. First In-First Out (FIFO) b. Last In Last Out (LILO) c. Last In First Out (LIFO) d. None of the above
In what order the elements of a pushdown stack are accessed?a. First In-First Out (FIFO)b. Last In Last Out (LILO)c. Last In First Out (LIFO)d. None of the above
sh!va
1.5k
views
sh!va
asked
Feb 28, 2017
DS
isro-ece
isro2011-ece
data-structures
+
–
0
votes
2
answers
3562
output of program
If the following fragment (assume negative numbers are stored in 2's complement form) unsigned i=1; int j=-4; printf("%u",i+j); prints x then printf("%d", 8*sizeof(int)); outputs an integer that is same as (log in the options are of base 2) a)8*log(x+3) b)log(x+3) c)unpredictable value d)none of the above
If the following fragment (assume negative numbers are stored in 2's complement form)unsigned i=1;int j=-4;printf("%u",i+j);prints x then printf("%d", 8*sizeof(int));outp...
Sanjay Sharma
995
views
Sanjay Sharma
asked
Feb 27, 2017
0
votes
0
answers
3563
segmentation fault or compilation error ?
Consider this C code to swap two integers and these five statements : void swap (int * px, int * py) { * px = *px - *py ; *py = *px + *py; *px = *py - *px; } S1 : Will generate a compilation error S2 : May generate a segmentation fault ... input pointers. S5 : May add or subtract integers and pointers. (A) S1 (B) S2 and S3 (C) S2 and S4 (D) S2 and S5
Consider this C code to swap two integers and these five statements :void swap (int * px, int * py){ * px = *px – *py ; *py = *px + *py; *...
Sanjay Sharma
1.0k
views
Sanjay Sharma
asked
Feb 24, 2017
2
votes
1
answer
3564
Self Framed
Whats the minimum number of multiplications required to compute $x^{7}$ * $x^{17}$ for any given integer value of 'x' ? A) 4 B) 5 C) 6 D) 7
Whats the minimum number of multiplications required to compute$x^{7}$ * $x^{17}$ for any given integer value of 'x' ?A) 4B) 5C) 6D) 7
Sushant Gokhale
465
views
Sushant Gokhale
asked
Feb 21, 2017
DS
dynamic-programming
+
–
2
votes
1
answer
3565
NPTEL DESIGN AND ANALYSIS OF ALGORITHMS
Suppose we have a graph with negative edge weights. We take the largest magnitude negative edge weight -k and reset each edge weight w to w+k+1. Which of the following is true? 1. Kruskal's algorithm will identify the same spanning ... There are more minimum cost spanning trees in the modified graph than in the original graph. is the correct answer 3 ?
Suppose we have a graph with negative edge weights. We take the largest magnitude negative edge weight -k and reset each edge weight w to w+k+1. Which of the following is...
shivamsat
2.1k
views
shivamsat
asked
Feb 20, 2017
DS
nptel-quiz
+
–
2
votes
1
answer
3566
C programming
int a[20]; unsigned int m; // global variable int foo(int a[]) { int i=0,count = 0; while(i < 20) m |= 1<<(a[i++]-1); i = (sizeof(int)<<3)-1; while(i>=0) if(m&(1<<(i--))) count++; return count; } In the above ... elements in a[] which are more than $20$ B No of distinct elements in a[] which less than $20$ C No of distinct elements in a[] D None of these
int a[20]; unsigned int m; // global variable int foo(int a[]) { int i=0,count = 0; while(i < 20) m |= 1<<(a[i++]-1); i = (sizeof(int)<<3)-1; while(i>=0) if(m&(1<<(i ))) ...
dd
570
views
dd
asked
Feb 18, 2017
Programming in C
programming-in-c
output
+
–
2
votes
2
answers
3567
let x be an array of integer which of the following can not be present in the LHS of an assignment statement
let x be an array of integer . which of the following can not be present in the left hand side of an assignment statementa)x b) x+i c) * (x+i) d) &x[i]
Sanjay Sharma
2.7k
views
Sanjay Sharma
asked
Feb 18, 2017
2
votes
3
answers
3568
program output
main() { static char a[3][4] = { "abcd", "efgh", "ijkl"}; putchar(**a); } a) compilation error b) run time error c)garbage d) none of these
main() {static char a[3][4] = { "abcd", "efgh", "ijkl"};putchar( a); } a) compilation error b) run time errorc)garbage d) none of these
Sanjay Sharma
1.5k
views
Sanjay Sharma
asked
Feb 18, 2017
0
votes
2
answers
3569
difference between if(a=0) and if(a=non zero)
what is the differernce between if (a=0) and if (a= -7) or any other non-zero number e.g what will be the out put of following program a)if ( a=0) printf(""a is zero ") else printf("a is not zero") and if we replace 0 by some +ve or -ve number then
what is the differernce between if (a=0) and if (a= -7) or any other non-zero number e.g what will be the out put of following program a)if ( a=0)printf(""a is zero ")els...
Sanjay Sharma
2.2k
views
Sanjay Sharma
asked
Feb 17, 2017
3
votes
1
answer
3570
Let x be an array . which of the following operations are illegal
Let x be an array . which of the following operations are illegal and why a) ++x b) x+1 c) x++ d) x - -
Let x be an array . which of the following operations are illegal and whya) ++x b) x+1 c) x++ d) x - -
Sanjay Sharma
6.6k
views
Sanjay Sharma
asked
Feb 17, 2017
85
votes
11
answers
3571
GATE CSE 2017 Set 1 | Question: 08
Consider the C code fragment given below. typedef struct node { int data; node* next; } node; void join(node* m, node* n) { node* p = n; while(p->next != NULL) { p = p->next; } p->next = m; } Assuming that m and n ... append list m to the end of list n. cause a null pointer dereference for all inputs. append list n to the end of list m for all inputs.
Consider the C code fragment given below.typedef struct node { int data; node* next; } node; void join(node* m, node* n) { node* p = n; while(p->next != NULL) { p = p->ne...
khushtak
26.1k
views
khushtak
asked
Feb 14, 2017
DS
gatecse-2017-set1
data-structures
linked-list
normal
+
–
0
votes
2
answers
3572
2017_1_42
#include <stdio.h> int total(int v) { static int count=0; while(v){ count+=v&1; v>>=1; } return count; } void main() { // your code goes here static int x=0; int i=5; for(;i>0;i--) { x=x+total(i); } printf("%d\n",x); return 0; }
#include <stdio.h int total(int v) { static int count=0; while(v){ count+=v&1; v>>=1; } return count; } void main() { // your code goes here static int x=0; int i=5; for(...
harveen singh
845
views
harveen singh
asked
Feb 14, 2017
102
votes
9
answers
3573
GATE CSE 2017 Set 1 | Question: 53
Consider the following C program. #include<stdio.h> #include<string.h> void printlength(char *s, char *t) { unsigned int c=0; int len = ((strlen(s) - strlen(t)) > c) ? strlen(s) : strlen(t); printf("%d\n", len); } ... in $string.h$ as returning a value of type $size\_t$, which is an unsigned int. The output of the program is __________ .
Consider the following C program.#include<stdio.h #include<string.h void printlength(char *s, char *t) { unsigned int c=0; int len = ((strlen(s) - strlen(t)) c) ? strlen...
srestha
25.4k
views
srestha
asked
Feb 14, 2017
Programming in C
gatecse-2017-set1
programming
programming-in-c
normal
numerical-answers
+
–
68
votes
5
answers
3574
GATE CSE 2017 Set 1 | Question: 55
The output of executing the following C program is _______________ . #include<stdio.h> int total(int v) { static int count = 0; while(v) { count += v&1; v >>= 1; } return count; } void main() { static int x=0; int i=5; for(; i>0; i--) { x = x + total(i); } printf("%d\n", x); }
The output of executing the following C program is _______________ .#include<stdio.h int total(int v) { static int count = 0; while(v) { count += v&1; v >>= 1; } return c...
srestha
22.8k
views
srestha
asked
Feb 14, 2017
Programming in C
gatecse-2017-set1
programming
programming-in-c
normal
numerical-answers
+
–
54
votes
7
answers
3575
GATE CSE 2017 Set 2 | Question: 43
Consider the following snippet of a C program. Assume that swap $(\&x, \&y)$ exchanges the content of $x$ and $y$: int main () { int array[] = {3, 5, 1, 4, 6, 2}; int done =0; int i; while (done==0) { done =1; for (i=0; i<=4; i ... i-1]) { swap(&array[i], &array[i-1]); done =0; } } } printf( %d , array[3]); } The output of the program is _______
Consider the following snippet of a C program. Assume that swap $(\&x, \&y)$ exchanges the content of $x$ and $y$:int main () { int array[] = {3, 5, 1, 4, 6, 2}; int done...
Arjun
17.3k
views
Arjun
asked
Feb 14, 2017
Programming in C
gatecse-2017-set2
programming
algorithms
numerical-answers
identify-function
+
–
36
votes
6
answers
3576
GATE CSE 2017 Set 2 | Question: 37
Consider the C program fragment below which is meant to divide $x$ by $y$ using repeated subtractions. The variables $x$, $y$, $q$ and $r$ are all unsigned int. while (r >= y) { r=r-y; q=q+1; } Which of the following conditions on the variables $x, y, q$ and $r$ ... $(q==0) \ \&\& \ (y>0)$
Consider the C program fragment below which is meant to divide $x$ by $y$ using repeated subtractions. The variables $x$, $y$, $q$ and $r$ are all unsigned int.while (r >...
Arjun
14.9k
views
Arjun
asked
Feb 14, 2017
Programming in C
gatecse-2017-set2
programming
loop-invariants
+
–
27
votes
5
answers
3577
GATE CSE 2017 Set 2 | Question: 36
The pre-order traversal of a binary search tree is given by $12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20$. Then the post-order traversal of this tree is $2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20$ $2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12$ $7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12$ $7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12$
The pre-order traversal of a binary search tree is given by $12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20$. Then the post-order traversal of this tree is$2, 6, 7, 8, 9, 10, ...
Arjun
8.9k
views
Arjun
asked
Feb 14, 2017
DS
gatecse-2017-set2
data-structures
binary-search-tree
+
–
70
votes
13
answers
3578
GATE CSE 2017 Set 2 | Question: 55
Consider the following C program. #include<stdio.h> #include<string.h> int main() { char* c="GATECSIT2017"; char* p=c; printf("%d", (int)strlen(c+2[p]-6[p]-1)); return 0; } The output of the program is _______
Consider the following C program.#include<stdio.h #include<string.h int main() { char* c="GATECSIT2017"; char* p=c; printf("%d", (int)strlen(c+2[p]-6[p]-1)); return 0; }T...
Madhav
28.8k
views
Madhav
asked
Feb 14, 2017
Programming in C
gatecse-2017-set2
programming-in-c
numerical-answers
array
pointers
+
–
104
votes
7
answers
3579
GATE CSE 2017 Set 1 | Question: 36
Consider the C functions foo and bar given below: int foo(int val) { int x=0; while(val > 0) { x = x + foo(val--); } return val; } int bar(int val) { int x = 0; while(val > 0) { x ... in: Return of $6$ and $6$ respectively. Infinite loop and abnormal termination respectively. Abnormal termination and infinite loop respectively. Both terminating abnormally.
Consider the C functions foo and bar given below:int foo(int val) { int x=0; while(val 0) { x = x + foo(val ); } return val; }int bar(int val) { int x = 0; while(val 0)...
Arjun
25.8k
views
Arjun
asked
Feb 14, 2017
Programming in C
gatecse-2017-set1
programming-in-c
programming
normal
recursion
+
–
47
votes
11
answers
3580
GATE CSE 2017 Set 1 | Question: 35
Consider the following two functions. void fun1(int n) { if(n == 0) return; printf("%d", n); fun2(n - 2); printf("%d", n); } void fun2(int n) { if(n == 0) return; printf("%d", n); ... printf("%d", n); } The output printed when $\text{fun1}(5)$ is called is $53423122233445$ $53423120112233$ $53423122132435$ $53423120213243$
Consider the following two functions.void fun1(int n) { if(n == 0) return; printf("%d", n); fun2(n - 2); printf("%d", n); } void fun2(int n) { if(n == 0) return; printf("...
Arjun
20.7k
views
Arjun
asked
Feb 14, 2017
Programming in C
gatecse-2017-set1
programming
normal
tricky
recursion
+
–
Page:
« prev
1
...
174
175
176
177
178
179
180
181
182
183
184
...
310
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register