"Hello": #Include
"Hello": #Include
"Hello": #Include
#include<stdio.h>
main()
{ for(;;)printf("Hello");}
A - Infinite loop
B - Prints “Hello” once.
C - No output
D - Compile error
Answer : A
Explanation
infinite loop, with second expression of ‘for’ being absent it is considered as true by default.
#include<stdio.h>
main()
{
int x = 1;
float y = x>>2;
printf( "%f", y );
}
A-4
B - 0.5
C-0
D-1
Answer : C
Explanation
0, data bits are lost for the above shift operation hence the value is 0.
#include<stdio.h>
main()
{
int a[3] = {2,1};
printf("%d", a[a[1]]);
}
A-0
B-1
C-2
D-3
Answer : B
Explanation
1, The inner indirection evaluates to 1, and the value at index 1 for outer indirection is 1.
#include<stdio.h>
main()
{
fprintf(stdout,"Hello, World!");
}
A - Hello, World!
B - No output
C - Compile error
D - Runtime error
Answer : C
Explanation
stdout is the identifier declared in the header file stdio.h, need to include the same.
#include<stdio.h>
main()
{
char s[20] = "Hello\0Hi";
6. In the standard library of C programming language, which of the following header file
is designed for basic mathematical operations?
A - math.h
B - conio.h
C - dos.h
D - stdio.h
Answer : A
Explanation
math.h is a header file in the standard library designed for basic mathematical operations
A - stdlib.h
B - memory.h
C - math.h
D - stdio.h
Answer : A
Explanation
void *malloc(size_t size) : Allocates the requested memory and returns a pointer to it.
void *calloc(size_t nitems, size_t size): Allocates the requested memory and returns a pointer to
it.
#include<stdio.h>
int main()
{
const int i = 0;
printf("%d\n", i++);
return 0;
}
A - 100
B - Infinity
C-0
D - Return error
Answer : D
Explanation
It is because ++needs a value and a const variable can’t be modified.
#include<stdio.h>
int main()
{
const int i = 0;
printf("%d\n", i++);
return 0;
}
10.The library function strrchr() finds the first occurrence of a substring in another string.
A - Yes
B - Strstr()
C - strchr()
D - strnset()
Answer : B
Explanation
Strstr() finds the first occurrence of a substring in another string.
A-1
B - -1
C-2
D - -2
Answer : D
Explanation
-2, the one’s compliment of 1 is 1110 (binary) which is equivalent to two’s compliment of 2, ie
-2.
#include<stdio.h>
void swap(int m, int n)
{
int x = m;
m = n;
n = x;
}
main()
{
int x=5, y=3;
swap(x,y);
printf("%d %d", x, y);
}
A-35
B-53
C-55
D - Compile error
Answer : B
Explanation
5 3, call by value mechanism can’t alter actual arguments.
#include <stdio.h>
void swap(int m, int n)
{
int x = m;
m = n;
n = x;
}
main()
{
int x=5, y=3;
swap(x,y);
printf("%d %d", x, y);
}
13. First operating system designed using C programming language.
A - DOS
B - Windows
C - UNIX
D - Mac
Answer : C
Explanation
UNIX. C actually invented to write an operation system called UNIX. By 1973 the entire UNIX
OS is designed using C.
#include<stdio.h>
main()
{
fprintf(stdout,"Hello, World!");
}
A - Hello, World!
B - No output
C - Compile error
D - Runtime error
Answer : C
Explanation
stdout is the identifier declared in the header file stdio.h, need to include the same.
#include<stdio.h>
main()
{
printf("%d", -1<<1 );
}
A-2
B - -2
C-1
D - -1
Answer : B
Explanation
A negative number stored in two’s compliment of positive number. After shifting we get 1110,
which is equivalent to -2.
A - a, b, d
B - a, b, c
C - b, c, d
D - c, d, a
Answer : A
Explanation
In C, these are the unary operators,
Logical NOT = !
Address-of = &
Cast Operator = ( )
Pointer dereference = *
Unary Plus = +
Increment = ++
Unary negation = –
char *arr[30];