You are on page 1of 4

1. #include <stdio.

h>
void f(char *k)
{
k++;
k[2] = 'm';
printf("%c\n", *k);
}
void main()
{
char s[] = "hello";
f(s);
}
(a) l (b) e (c) h (d) o
2. #include <stdio.h>
int main()
{
int a[5] = {1, 2, 3, 4, 5};
int i;
for (i = 0; i < 5; i++)
if ((char)a[i] == '5')
printf("%d\n", a[i]);
else
printf("FAIL\n");
}
(a) The compiler will flag an error
(b) Program will compile and print the output 5
(c) Program will compile and print the ASCII value of 5
(d) Program will compile and print FAIL for 5 times
3. #include <stdio.h>
int main()
{
int i = 0;
int x = i++, y = ++i;
printf("%d % d\n", x, y);
return 0;
}
(a) 0, 2
(b) 0, 1

(c) 1, 2

(d) Undefined

4.

#include <stdio.h>
void main()
{
register int x = 0;
if (x < 2)
{
x++;
main();
}
}
(a) Segmentation fault
(b) main is called twice
(d) main is called thrice

5.

6.

7.

(c) main is called once

The correct syntax for running two variable for loop simultaneously is.
(a) for (i = 0; i < n; i++)
for (j = 0; j < n; j += 5)
(b) for (i = 0, j = 0;i < n, j < n; i++, j += 5)
(c) for (i = 0; i < n;i++){ }
for (j = 0; j < n;j += 5){ }
(d)None of the mentioned
#include <stdio.h>
void main()
{
m();
void m()
{
printf("hi");
}
}
(a) hi
(b) Compile time error

#include <stdio.h>
int main()
{
int a = 1;

(c) Nothing

(d) Varies

if (a)
printf("Aditya");
printf("Madnapalli\n");
else
printf("No water\n");
}
(a) Output will be Aditya Madanapalli
(b) Output will be Madanapalli No water
(c) Output will be Madanapalli
(d) Compile time errors during compilation
8.

9.

10.

#include <stdio.h>
int main()
{
int a = 1;
if (a--)
printf("True");
if (a++)
printf("False");
}
(a) True
(b) False
(c)True False

(d)No output

#include <stdio.h>
int main()
{
int x = 0;
if (x == 1)
if (x >= 0)
printf("true\n");
else
printf("false\n");
}
(a) true
(b)false

(d) None of the above

#include <stdio.h>
int main()
{
int x = 0;
if (x == 1)
if (x == 0)

(c)null

printf("inside if\n");
else
printf("inside else if\n");
else
printf("inside else\n");
}
(a) inside if (b) inside else if

(c) inside else

(d) compile time error

You might also like