Log In Register

Units


For Loops - Questions and Answers

 

Practice these For Loops under C Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on For Loops for following purpose.


– Anyone who is wishing to increase their perfect knowledge of For Loops of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically For Loops.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on For Loops under C Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  For Loops topic of C Programming:

 

1.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         double k = 0;
  5.         for (k = 0.0; k < 3.0; k++)
  6.             printf("Hello");
  7.     }

Answer: Option D

Explanation:

2.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         double k = 0;
  5.         for (k = 0.0; k < 3.0; k++);
  6.             printf("%lf", k);
  7.     }

Answer: Option B

Explanation:

3.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int k = 0;
  5.         for (k < 3; k++)
  6.         printf("Hello");
  7.     }

Answer: Option C

Explanation:

4.

The following code ‘for(;;)’ represents an infinite loop. It can be terminated by.

Answer: Option C

Explanation:

5.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         for (i++; i == 1; i = 2)
  6.             printf("In for loop ");
  7.             printf("After loop\n");
  8.     }

Answer: Option C

Explanation:

6.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         short i;
  5.         for (i = 1; i >= 0; i++)
  6.             printf("%d\n", i);
  7. 
     
  8.     }

Answer: Option B

Explanation:

7.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int k = 0;
  5.         for (k)
  6.             printf("Hello");
  7.     }

Answer: Option D

Explanation:

8.

Which for loop has range of similar indexes of ‘i’ used in for (i = 0;i < n; i++)?

Answer: Option A

Explanation:

9.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         for (foo(); i == 1; i = 2)
  6.             printf("In for loop\n");
  7.             printf("After loop\n");
  8.     }
  9.     int foo()
  10.     {
  11.         return 1;
  12.     }

Answer: Option D

Explanation:

10.

Which of the following cannot be used as LHS of the expression in for (exp1;exp2; exp3) ?

Answer: Option A

Explanation:

11.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int *p = NULL;
  5.         for (foo(); p; p = 0)
  6.             printf("In for loop\n");
  7.             printf("After loop\n");
  8.     }

Answer: Option C

Explanation:

12.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int k;
  5.         for (k = -3; k < -5; k++)
  6.             printf("Hello");
  7.     }

Answer: Option A

Explanation:

13.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         for (int i = 0;i < 1; i++)
  5.             printf("In for loop\n");
  6.     }

Answer: Option B

Explanation:

14.

The correct syntax for running two variable for loop simultaneously is.

Answer: Option C

Explanation:

15.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         for (; ; ;)
  6.             printf("In for loop\n");
  7.             printf("After loop\n");
  8.     }

Answer: Option D

Explanation: