C Programming Fundamentals

Test your knowledge of C programming language concepts including operators, control flow, arrays, functions, preprocessor directives, and recursion.

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which is the actual syntax to find the ratio of boys and girls in C language? (given that float ratio; int boys, girls;)

  1. ratio = boys/girls;
  2. ratio = girls/boys;
  3. ratio = (float) girls/boys;
  4. ratio = (float) boys/girls;
  5. ratio = float boys/girls;
Question 2 Multiple Choice (Single Answer)

Find the output of the following code in C language assuming other parameters are correct.
void main( )
{
int a; int b;
scanf ("%2d %5d", &a, &b);
printf ("a = %d and b=%d.",a,b);
}
/* input by the user is a=12345 and b = 67 during program execution*/

  1. a=12345 and b=67
  2. a=67 and b=12345
  3. a=12 and b=345
  4. a=12 and b=34567
  5. a=12 and b=67
Question 3 Multiple Choice (Single Answer)

Which one of the following is example of compound assignment operator in C language?

  1. a* = 5;
  2. a=a+5;
  3. a=a*5;
  4. a<5;
  5. a&&5
Question 4 Multiple Choice (Single Answer)

What will be output of the code if all other terms are assumed correct in C language?
int age=17;
(age>=18)?
printf( I can vote.) :
printf( I cannot vote.);

  1. Incorrect code
  2. Incorrect operator used
  3. I can vote
  4. I cannot vote
  5. No output
Question 5 Multiple Choice (Single Answer)

'goto' statement is used in C programming to __________.

  1. jump the control to specific location o screen
  2. hold the control for user input
  3. end the program execution
  4. restart the execution from beginning
  5. jump the control up or down at its label
Question 6 Multiple Choice (Single Answer)

What is the right coding to find the formatted output of float value upto 4 decimal points?
float a=23.76548;

  1. printf ( "% f ",a);
  2. printf ( "% 4" , a );
  3. printf ( "%2.4" f ;a);
  4. printf ( "% i" ,a);
  5. printf ( "%d" ;a);
Question 7 Multiple Choice (Single Answer)

Which of the following is not correct in context to array in C language?

  1. It is a group of variables of similar datatype.
  2. It stores the data in consucative memory location.
  3. It is referred by a common name.
  4. int val[5].
  5. Array size can be changed during program execution.
Question 8 Multiple Choice (Single Answer)

Write the steps to interchange the variable values using least memory usages. Given that - int i, j;

  1. swap(i,j);
  2. i=j; j=i;
  3. i = i + j ;j = i - j ;i = i - j ;
  4. j = i - j;i = i + j ;i = i + j ;
  5. int temp;temp=i;i = j;j = temp;
Question 9 Multiple Choice (Single Answer)

Which of the following statements is not correct about a function?

  1. It is a set of instructions.
  2. It performs a specific task.
  3. It is reusable.
  4. It is modular programming.
  5. None of these
Question 10 Multiple Choice (Single Answer)

Find the output of the following code in C language, if assumed that all preprocessor directives are correct.
void main ( )
{
int a = 2, b = 2;
if (a > 2)
if (b > 2)
printf ( "Hello");
Else
Printf ("Hi");
}

  1. Hello
  2. Hi
  3. Error in execution
  4. Normal program execution without any output
  5. Program code error
Question 11 Multiple Choice (Single Answer)

If class name is Y, which is the right code to declare the copy constructor of the class?

  1. Y(const Y & arg )
  2. Y(Const *Y arg )
  3. Y(Y arg)
  4. Y(Y & arg)
  5. None of these
Question 12 Multiple Choice (Single Answer)

A user defined header file myheader.h is saved at root directory. Write pre-processor directives to include the header file in the program code in C language.

  1. # include <myheader.h><myheader.h></myheader.h>
  2. include <myheader.h><myheader.h></myheader.h>
  3. # include C:myheader.h
  4. # include "C:myheader.h"
  5. main (C:myheader.h)
Question 13 Multiple Choice (Single Answer)

Which of the following is true?

  1. # define P printf
  2. define P printf
  3. # use P printf
  4. # <define p="printf="></define>
  5. # include
Question 14 Multiple Choice (Single Answer)

Which is correct statement about recursion?

  1. It is a function which calls to itself.
  2. It is a process in which a function calls to itself.
  3. It runs for definite number of time without condition.
  4. It is used to call global function.
  5. It is used to call local function.
Question 15 Multiple Choice (Single Answer)

Given code is written in C language. Find the output of the program.

int i = 6, j = 14, k = 7, l = 7, x;
x = i > j ? j > k ? 12 : k > l? 13 : 14 : 15;printf("%d", x);

  1. 12
  2. 13
  3. 14
  4. 15
  5. %d