Select chapter



functions (3.papers)
loops (1.papers)
arrays (2.papers)
structures (3.papers)
unions (1.papers)
pointers (7.papers)
null pointers (1.papers)
strings (2.papers)
misc c concepts (1.papers)
Data structures (5.papers)
linked lists (3.papers)
trees (1.papers)
basics (5.papers)
Hide

Sponsored Links


  

c conditional statements interview questions and answers

Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
6
if else in c:

What will be the output of this below program?

#include  <stdio.h>
static int i=10;
main( )
{
    printf("%d\n",i);
    i--;
    if(i==0)
        return;
    else
        main();
}
  1. it prints 10 to 1, and exits with out any run time crash.
  2. it prints 10 to 1, and crashes at run time due to stack over flow.
  3. it prints 10, and exits with out any run time error.
  4. it prints 10 infinite times, and crashes at run time due to stack over flow.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
16
Which one is the correct variant if you want to select a percentage rate based upon an integer category?
The code fragment is found below:

switch (category)
{
case 1: percentage_rate = 10.0 ;
case 2: percentage_rate = 15.0 ;
case 3: percentage_rate = 20.0 ;
default: percentage_rate = 25.0 ;
}
  1. is incorrect because "case" is not placed before the values
  2. is incorrect because the case actions need to be enclosed in braces
  3. will store the same value in percentage rate no matter what the value of category is
  4. is incorrect because a select statement should be used instead of switch
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
20
What is the output of this program? what is it doing?
main()
{
int num=45;
int res=find(num);
printf("result is.. %d",res);
}

int find(int s)
{
if(s == 0)
   return 0;
else
   return (s%10)+find(s/10);
}
  1. it prints the sum of the digits of a given number. here it prints 9 as result.
  2. it prints the product of all the digits in a given number. it prints 20.
  3. it prints the sum of the digits of a given number. but logic is wrong. it prints 0.
  4. it prints the sum of the digits of a given number. but logic is wrong. it will go into infinite loop and crashes at run time.
Show Answer
Share Facebook gmail Twitter
Read more papers :