KEMBAR78
C Fundamentals Interview Questions | PDF | Pointer (Computer Programming) | Software Engineering
0% found this document useful (0 votes)
9 views5 pages

C Fundamentals Interview Questions

The document contains a series of C programming interview questions that test knowledge on code output, syntax, and concepts. Each question presents a code snippet with multiple-choice answers regarding the expected output or behavior. Topics include loops, pointers, and function return values.

Uploaded by

nidgundichetana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

C Fundamentals Interview Questions

The document contains a series of C programming interview questions that test knowledge on code output, syntax, and concepts. Each question presents a code snippet with multiple-choice answers regarding the expected output or behavior. Topics include loops, pointers, and function return values.

Uploaded by

nidgundichetana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

C Fundamentals Interview Questions.

1. What will be the output of the following C code?


#include <stdio.h>
int main()
{
while ()
printf("In while loop ");
printf("After loop\n");
}
a. In while loop after loop
b. After loop
c. Compile time error
d. Infinite loop

2. What will be the output of the following C code?


#include <stdio.h>
int main()
{
do
printf("In while loop ");
while (0);
printf("After loop\n");
}
a. In while loop
b. In while loop After loop
c. After loop
d. Infinite loop

3. What will be the output of the following C code?


#include <stdio.h>
void main()
{
int i = 0;
while (++i)
{
printf("H");
}
}
a. H
b. H is printed infinite times
c. Compile time error
d. Varies
4. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int k;
for (k = -3; k < -5; k++)
printf("Hello");
printf(“Nothing”);
}
a. Hello
b. Infinite hello
c. Run time error
d. Nothing

5. What will be the output of the following C code?


#include <stdio.h>
int main()
{
int i = 0;
for (; ; ;)
printf("In for loop\n");
printf("After loop\n");
}
a. Compile time error
b. Infinite loop
c. After loop
d. Undefined behavior

6. What will be the output of the following C code?


#include <stdio.h>
int main()
{
for (int i = 0;i < 1; i++)
printf("In for loop\n");
}
a. Compile time error
b. In for loop
c. Depends on the standard compiler implements
d. Run time error

7. What will be the output of the following C code?


#include <stdio.h>
void main()
{
char *str = "";
do
{
printf("hello");
} while (str);
}
a. Nothing
b. Run time error
c. Varies
d. Hello is printed infinite times

8. What will be the output of the following C code?


#include <stdio.h>
int main()
{
int i = 0;
while (i = 0)
printf("True\n");
printf("False\n");
}
a. True (infinite time)
b. True (1 time) False
c. False
d. Compiler dependent

9. What will be the correct syntax for running two variables for loop simultaneously?
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

10. What will be the output of the following C code?


#include <stdio.h>
void main()
{
int k = 0;
for (k)
printf("Hello");
}
a. Compile time error
b. hello
c. Nothing
d. Varies
11. Comment on the following C statement.
int (*a)[7];

a. An array “a” of pointers


b. A pointer “a” to an array
c. A ragged array
d. None of the mentioned

12. What will be the output of the following C code?


#include <stdio.h>
int main()
{
char *p = NULL;
char *q = 0;
if (p)
printf(" p ");
else
printf("nullp");
if (q)
printf("q\n");
else
printf(" nullq\n");
}
a. nullp nullq
b. Depends on the compiler
c. x nullq where x can be p or nullp depending on the value of NULL
d. pq

13. Comment on the following C statement.


const int *ptr;

a. You cannot change the value pointed by ptr


b. You cannot change the pointer ptr itself
c. You May or may not change the value pointed by ptr
d. You can change the pointer as well as the value pointed by it

14. Which pre-defined function returns a pointer to the last occurence of a character in a
string?’

a) strchr(s, c);
b) strrchr(s, c);
c) strlchr(s, c);
d) strfchr(s, c);

15. The value obtained in the function is given back to main by using ________ keyword.
a) return
b) static
c) new
d) volatile

You might also like