search
Log In

Webpage

Programming in C. Recursion.

$$\small{\overset{{\large{\textbf{Mark Distribution in Previous GATE}}}}{\begin{array}{|c|c|c|c|c|c|c|c|}\hline
\textbf{Year}&\textbf{2019}&\textbf{2018}&\textbf{2017-1}&\textbf{2017-2}&\textbf{2016-1}&\textbf{2016-2}&\textbf{Minimum}&\textbf{Average}&\textbf{Maximum}
\\\hline\textbf{1 Mark Count}&2&2&1&2&2&1&1&1.7&2
\\\hline\textbf{2 Marks Count}&3&3&4&4&2&2&2&3&4
\\\hline\textbf{Total Marks}&8&8&9&10&6&5&\bf{5}&\bf{8}&\bf{10}\\\hline
\end{array}}}$$

Recent questions in Programming

4 votes
2 answers
1
What does the following function compute in terms of $n$ and $d$, for integer value of $n$ and $d,d>1?$ Note that $a//b$ denotes the quotient(integer part) of $a \div b,$ for integers $a$ and $b$. For instance $7//3$ is $2.$ function foo(n,d){ x := ... of size $n.$ The number of digits in the base $d$ representation of $n.$ The number of ways of partitioning $n$ elements into groups of size $d.$
asked Sep 13, 2019 in Programming gatecse 166 views
3 votes
1 answer
2
Consider the following pseudo-code fragment in which an invariant for the loop is $m ^*x^k=p^n$ and $k \geq 0$ (here, $p$ and $n$ are integer variable that have been initialized): /* Pre-conditions : $p \geq 1 \wedge n \geq 0$ */ /* Assume that overflow never occurs */ int $x=p$; ... $x=p^n$ $m=p^n$ $p=x^n$ $p=m^n$
asked Jul 2, 2019 in Programming Arjun 796 views
4 votes
3 answers
3
Consider the following C-code fragment running on a $32$-bit $X86$ machine: typedef struct { union { unsigned char a; unsigned short b; } U; unsigned char c; }S; S B[10]; S*p=&B[4]; S*q=&B[5]; p → U.b=0x1234; /* structure S takes 32-bits */ If M is the value of $q-p$ and $N$ is the value of $((\text{int )&} ( p \rightarrow c)) – ((\text{int})p)$, then $(M,N)$ is $(1,1)$ $(3,2)$ $(1,2)$ $(4,4)$
asked Jul 2, 2019 in Programming Arjun 1.2k views
1 vote
2 answers
4
I have learnt that self-referential structure is one which contains a structure of same type in it as an element. But I have a doubt regarding how that line is compiled successfully (i.e, how compiler knows how much space should be allocated and its elements)when the ... structure is not yet finished? struct node { int data; struct node *next; }; correct me If I am wrong in understanding this.
asked Jun 12, 2019 in Programming Sathuri Bharath 397 views
1 vote
0 answers
5
We know that UNIX support a feature that allows for variable field with precision. please help me out in this statement -> printf(“% * .* s \n”,w,d,string); ? i know using of precision with string such as %10.4s <width>.<precision> indicating that first four character to be printed in a field with 10 columns.
asked Jun 6, 2019 in Programming Aks9639 182 views
1 vote
2 answers
6
#include <stdio.h> int main(void) { char* ar[4]; scanf("%s",ar[3]); printf("%s",ar[3]); return 0; } char *test1[3]= {"arrtest","ao", "123"}; if one can initialize array like this ,how can input be taken by using scanf ?
asked Jun 2, 2019 in Programming hitendra singh 239 views
0 votes
1 answer
7
#include<iostream> using namespace std; int i=0; void a() { i+=1; cout<<i<< ".hello"<<endl; a(); } int main() { a(); } For this above code the output is only upto → 64891.Hello Does this mean that that the stack can hold only 64891 recursive calls? (I am using dev c++)
asked Jun 2, 2019 in Programming Hirak 647 views
0 votes
1 answer
8
#include<stdio.h> #include<stdlib.h> int main(void) { int maxLineCount = 500, maxCharCount = 500, index, j, count; char *line = NULL; size_t size; char *a[maxLineCount]; for (index = 0; index < maxLineCount; index++) a[index] = (char *)malloc(maxCharCount * ... of the code is doing. suppose we have 3 string given as input in 3 different lines then how can we access each character of the string?
asked Jun 1, 2019 in Programming Satbir 920 views
0 votes
0 answers
9
output is a=34 and x=13 can anyone plzz explain #include <iostream> using namespace std; int main() { int x = 10, a; a = x++ + ++x + x++; cout << "Post Increment Operation"; cout << "\na = " << a; cout << "\nx = " << x; return 0; }
asked May 30, 2019 in Programming Arun Rout 123 views
4 votes
4 answers
10
void fun(int *p) { int q = 10; p = &q; z } int main() { int r = 20; int *p = &r; fun(p); printf("%d", *p); return 0; }
asked May 30, 2019 in Programming manisha11 589 views
4 votes
4 answers
11
https://gateoverflow.in/?qa=blob&qa_blobid=14433986388826671915 int main() { int a = 10; int *b = &a; scanf("%d",b); printf("%d",a+50); } What will be the Output of the following code if input given is $25$ ?
asked May 22, 2019 in Programming Manoj Kumar Pandey 325 views
4 votes
3 answers
12
#include<stdio.h> #include<iostream> int bar(int m, int n){ if(m==0)return n; if(n==0)return m; return bar(n%m,m); } int foo(int m,int n){ return(m*n/bar(m,n)); } int main(){ int x=foo(1000,1500); printf("%d",x); return 0; } Output of the program is ___________
asked May 20, 2019 in Programming srestha 408 views
2 votes
1 answer
13
Consider the following $C$ implementation which when given $3$ numbers a,b,c as input, find the maximum of $3$ numbers $a,b,c.$ int kickstart(int a,int b,int c) { if(B1) return a; if(a>=b) return B2; return kickstart(c,a,b); } How the boxes filled up correctly? $I)B1:a\geq b$ ... $IV)B1:a\geq b$ && $a\geq c, B2:kickstart\left ( b,c,a \right );$ Is it $I) and II)$ or $I) and IV)$
asked May 19, 2019 in Programming srestha 440 views
1 vote
1 answer
14
Implement Linked list using stack.
asked May 19, 2019 in Programming shraddha priya 384 views
0 votes
2 answers
15
A default catch block catches, [A]. all thrown objects [B]. no thrown objects [C]. any thrown object that has not been caught by an earlier catch block [D]. all thrown objects that have been caught by an earlier catch block
asked May 19, 2019 in Programming logan1x 196 views
0 votes
1 answer
16
What will be the output of the below code? the answer given is E)0 but I am not getting it. #include <stdio.h> void fun(short int *a,char *b) { b += 2; short int *p = (short int*)b; *p = *a; } int main() { void (*fptr)(short int *,char *) short int a = 101; char ... *fptr)(&a,arr); printf("%d", arr[3]); return 0; } $A)$ Compilation error. $B) 100$ $C)$ Garbage Value $D)$ Segmentation Fault. $E) 0$
asked May 18, 2019 in Programming Aishvarya Akshaya Vi 443 views
2 votes
2 answers
17
Can someone explain the output of this code? and what (char*) is doing actually? #include<stdio.h> struct Ournode{ char x, y, z; }; int main() { struct Ournode p={'1', '0', 'a'+2}; struct Ournode *q=&p; printf("%c, %c", '*((char*)q+1)', '*((char*)q+2)'); return 0; }
asked May 13, 2019 in Programming srestha 302 views
2 votes
2 answers
18
Consider the following function $foo()$ void foo(int n){ if(n<=0) printf("Bye"); else{ printf("Hi"); foo(n-3); printf("Hi"); foo(n-1); } } Let $P(n)$ represent recurrence relation, indicating number of time print statement executed. What will best recurrence for ... $n=0$ The options are confusing to me. Can someone explain the options well. Moreover , what will be constant added $1$ or $2?$
asked May 12, 2019 in Programming srestha 352 views
1 vote
0 answers
19
Consider the following C code: int getNextGap(int gap){ gap=(gap*10)/13; if(gap<1)return 1; return gap; } void mystery(int a[ ],int n){ int gap=n; bool red=true; while(gap!=1||red==true){ gap=getNextGap(gap); red=false; for(int i=0;i<(n-gap ... n is number of array elements, then what output will print at last? I mostly stuck how bool function working here. Plz help me out, how program executing:(
asked May 10, 2019 in Programming srestha 336 views
1 vote
0 answers
20
Consider the following function int fun(int a[ ],int l, int target){ int i=0,j=0,sum=0,count=0; while(j<l){ if(sum<target){ sum=sum+a[j]; j++; } else if(sum>target){ sum=sum-a[i]; i++; } else{ count++; sum=sum-a[i]; i++; } } if(sum==target) ... be return value of function call $fun\left ( a,16,8 \right )=$_______________ Given ans $6,$ but I got $4.$ Which one correct?? Any shortcut to evaluate??
asked May 8, 2019 in Programming srestha 358 views
...