MCQ1 mark
In C runtime environment, which one of the following is stored in heap?
Single correct
GATE CSE previous year questions · Programming & Data Structures
Single correct
#include <stdio.h>
int a=5;
int main(){
int a=7;
return(0);
}
P2
#include <stdio.h>
int main(){
int a=5;
int a=7;
return(0);
}
P3
#include <stdio.h>
int main(){
int a=5;
float a=7;
return(0);
}
Which one of the following statements is true?Single correct
#include <stdio.h>
void stringcopy(char *, char *);
int main(){
char a[30] = "@#Hello World!";
stringcopy(a, a + 2);
printf("%s\n", a);
return 0;
}
void stringcopy(char *s, char *t) {
while(*t)
*s++ = *t++;
}
Which ONE of the following will be the output of the program?Single correct
int x=126,y=105;
do {
if(x>y) x=x-y;
else y=y-x;
} while(x!=y);
printf("%d",x);
The output of the given C code segment is ________. (Answer in integer)Numerical answer
#include <stdio.h>
int g(int p) { printf("%d", p); return p; }
int h(int q) { printf("%d", q); return q; }
void f(int x, int y) {
g(x);
h(y);
}
int main() {
f(g(10),h(20));
}
Which one of the following options is the CORRECT output of the above C program?Single correct
int fX(char *a){
char *b = a;
while(*b)
b++;
return b - a;}
Which of the following statements is/are TRUE?One or more correct
#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?Single correct
Answer key coming soon
int SomeFunction(int x, int y)
{
if ((x == 1) || (y == 1)) return 1;
if (x == y) return x;
if (x > y) return SomeFunction(x - y, y);
if (y > x) return SomeFunction(x, y - x);
}
The value returned by SomeFunction(15, 255) is __________.Numerical answer
Answer key coming soon
(P) static char var; (i) Sequence of memory locations to store addresses
(Q) m = malloc(10); (ii) A variable located in data section of memory
m = NULL;
(R) char *ptr[10]; (iii) Request to allocate a CPU register to store data
(S) register int var1; (iv) A lost memory which cannot be freedSingle correct
Answer key coming soon
void printxy(int x, int y) {
int *ptr;
x = 0;
ptr = &x;
y = *ptr;
*ptr = 1;
printf("%d,%d",x,y);
}
The output of invoking printxy(1,1) isSingle correct
Answer key coming soon
void f(int* p, int m){
m = m + 5;
*p = *p + m;
return;
}
void main(){
int i=5, j=10;
f(&i, j);
printf("%d", i+j);
}Numerical answer
Answer key coming soon
#include <stdio.h>
int main()
{
char s1[7] = "1234", *p;
p = s1 + 2;
*p = '0';
printf("%s", s1);
}
What will be printed by the program?Single correct
func shown below:
int func(int num) {
int count = 0;
while (num) {
count++;
num>>= 1;
}
return (count);
}
The value returned by func(435) is _____.Numerical answer
Single correct
Numerical answer