intf1(int a, int b){
if (a > b)
{
printf("A is greater than B\n");
return1;
}
else {
printf("B is greater than A");
return0;
}
}
main()
{
if (f1(20,10) || f1(10,20))
printf("C is fun!\n");
}
:
A is greater than B
C is fun!
:
A is greater than B
B is greater than A
C is fun!
:
A is greater than B
B is greater than A
Nothing is printed on Screen
Q3. What is the name for calling a function inside the same function?
Q6. Header files are listed using the preprocessing directive #include, and can have one of the following formats: #include <fileA> or #include "fileB". What is the difference between these two formats?
The preprocessor will try to locate fileA in the same directory as the source file, and the fileB in a predetermined directory path.
The preprocessor will try to locate fileA in the fixed system directory. It will try to locate fileB in the directory path designated by the -I option added to the command line while compiling the source code.
The file using the fileA syntax must be system files, of unlimited number; fileB must be a user file at a maximum of one per source file.
The preprocessor will try to locate fileA in a predetermined directory path. It will try to locate fileB in the same directory as the source file along with a custom directory path.
Q48. Which line of code, after execution, results in i having the value of 1?
for(i=1; i<=1; i++);
for(i=1; i=10; i++);
for(i=1; i==10; i++);
for(i=10; i>=1; i--);
Q49. What is the value of variable c at the end of this program?
1 main() {
2 int a, b, c;
3 a=10; b=50;
4 c=a * b % a;
5 }
50
5
0
500
Q50. What is not one of the basic data types in C
long double
unsigned char
array
float
Q51. What is the member access operator for a structure?
,
[]
.
:
Q52. What standard data type provides the smallest storage size and can be used in computations?
char
float
int
short
Q53. what does the ctype tolower() function do?
It returns TRUE for lowercase letters of the alphabet.
It ensures that text output uses only ASCII values (0 through 127).
It returns FALSE for lowercase letters of the alphabet.
It converts an uppercase letter of the alphabet to lowercase.
Q54. Void pointer vptr is assigned the address of float variable g. What is a valid way to dereference vptr to assign its pointed value to a float variable named f later in the program?
float g;
void *vptr=&g;
f=(float *)vptr;
f=*(float *)vptr;
f=*(float)vptr;
f=(float)*vptr;
Q55. The dynamic memory allocation functions are defined in which system header file?
stdio.h
stdlib.h
limits.h
stddef.h
Q56. A function is a set of _.
declarations
statements
variables
objects
Q57. How are static functions different from global functions?
Static functions must be declared in advance of being defined.
Static functions must be declared in a separate header file.
Static functions always return the same value.
Static functions can be accessed only in the file where they are declared.
Q58. Which code example creates the string "Hello Mars" in storage buffer hello.
Q62. What is not a valid type definition of a structure that contains x and y coordinates as integers, and that can be used as shown for the variable named point?
coord point;
point.x = 9;
point.y = 3;
:
structcoord{int x;
int y;
};
typedefstructcoordcoord;
:
typedefstructcoord{int x;
int y;
};
:
typedefstructcoord{int x;
int y;
} coord;
:
typedefstruct{int x;
int y;
} coord;
Q63. What is the output of the below program?
#include<stdio.h>#if X == 3#define Y 3#else#define Y 5#endifintmain(){
printf("%d", Y);
return0;
}
3
5
3 or 5 depending on input
Compile time error
Q64. What do the functions malloc() and calloc() allocate?
Q75. What is the output of the following code snippet?
intmain(){
int sum = 2 + 4 / 2 + 6 * 2;
printf("%d", sum);
return0;
}
2
15
16
18
Q76. What does the following declaration mean?
int (*ptr)[10];
ptr is an array of pointers to 10 integers
ptr is a pointer to an array of 10 integers
ptr is an array of 10 integers
ptr is a pointer to an array
Q77. What will be the output of the following code snippet?
#include<stdio.h>voidchange(int,int);
intmain(){
int a=10,b=20;
change(a,b); //calling a function by passing the values of variables.printf("Value of a is: %d",a);
printf("\n");
printf("Value of b is: %d",b);
return0;
}
voidchange(int x,int y){
x=13;
y=17;
}
10,20
10,10
20,20
20,10
Explanation: The function "change" will change the value of x and y only within its own scope, so a and is unaffected.
Q78. Choose true or false. When a variable is created in C, a memory address is assigned to the variable.
True
False
Q79. What does the following fragment of C-program print?
Explanation: char c[ ] = "GATE2011"; since char *p =c it means p represents the base address of string “GATE2011” SO p[3] is 'E' and p[1] is 'A'. Value of Sub expression p[3] – p[1] = ASCII value of ‘E’ – ASCII value of ‘A’ = 4. So the expression p + p[3] – p[1] becomes ( p + 4) And (p+4) represent to base address of string “2011” printf(“%s”, p + p[3] – p[1]) ; So it will print 2011
Q80. What is the output of the following code snippet?
intmain(){
int a = 5, b = 6, c;
c = a++ + ++b;
printf("%d %d %d", a, b, c);
return0;
}
5 6 11
6 7 12
5 6 12
6 6 12
Q81. What will be the output of the following C program segment?
Q82. String variable str1 has the value of "abc", and string variable str2 has the value "xyz". What are the values of str1 and str2 after this statement is executed?
strcpy(str1, str2);
str1: "xyz" ; str2: "xyz"
str1: "abc" ; str2: "xyz"
str1: "xyz" ; str2: "abc"
str1: "abc" ; str2: "abc"
Q83. Which is not one of the basic data types in C?
array
float
long double
unsigned char
Q84. You have written a function that you want to include as a member of structure a. How is such as structure member defined?
:
structa {void *f1;
};
:
structa {void (*f1)();
};
:
structa { *(void *f1)();
};
:
structa {void *f1();
};
Q85. You need to determine if a string variable is a substring of another string. Which standard C library function do you use?
substr(str1, str2);
strstr(str1, str2);
substring(str1, str2);
strspn(str1, str2);
Q86. How are static functions different from global functions?
Static functions must be declared in advance of being defined.
Static functions must be declared in a separate header file.
Static functions always return the same value.
Static functions can be accessed only in the file where they are declared.
Q87. What does this program display?
main(){
char *p = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int i;
for (i=0;i<5;i++) *p++; *p++;
printf("%c",*p++);
}
K
M
H
G
Q88. What is not a valid command with this declaration?