1
GATE CSE 2004
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program segment:
char p[20];
char *s = "string";
int length = strlen(s);
for(i=0; i < length; i++)
p[i] = s[length-i];
printf("%s",p);
The output of the program is
2
GATE CSE 2003
MCQ (Single Correct Answer)
+2
-0.6
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 = x-1;
print(x);
}
main(void) {
x = 5;
P(&x);
print(x);
}
The output of this program is3
GATE CSE 2001
MCQ (Single Correct Answer)
+2
-0.6
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 *px
px =(int*)malloc (size of (int));
*px = 10;
return px;
}
Which of the above three functions are likely to cause problems with pointers?Questions Asked from Pointer and Structure in C (Marks 2)
Number in Brackets after Paper Indicates No. of Questions
GATE CSE Subjects
Theory of Computation
Operating Systems
Algorithms
Database Management System
Data Structures
Computer Networks
Software Engineering
Compiler Design
Web Technologies
General Aptitude
Discrete Mathematics
Programming Languages