NEW AND EXCLUSIVE : GO TO THE ONLINE TEST PAGE AND TEST YOURSELF THROUGH EXAMINATION

Find Out the Output of the C-codes

Friends here is five C-questions involving Switch Case.
Lets solve these......
Q.1
What will be output when you will execute following c code?

#include<stdio.h>
void main(){
int check=2;
switch(check){
case 1: printf("D.W.Steyn");
case 2: printf(" M.G.Johnson");
case 3: printf(" Mohammad Asif");
default: printf(" M.Muralidaran");
}
}


Q.2
What will be output when you will execute following c code?


#include
<stdio.h> 
#define L 10
void main(){
auto money=10;
switch(money,money*2){
case L: printf("Willian");
break;
case L*2:printf("Warren");
break;
case L*3:printf("Carlos");
break;
default: printf("Lawrence");
case L*4:printf("Inqvar");
break;
}
}

Q.3
What will be output when you will execute following c code?

#include
<stdio.h> 
void main(){
int const X=0;
switch(5/4/3){
case X: printf("Clinton");
break;
case X+1:printf("Gandhi");
break;
case X+2:printf("Gates");
break;
default: printf("Brown");
}
}

Q.4
What will be output when you will execute following c code?


#include
<stdio.h> 
enum actor{
SeanPenn=5,
AlPacino=-2,
GaryOldman,
EdNorton
};
void main(){
enum actor a=0;
switch(a){
case SeanPenn: printf("Kevin Spacey");
break;
case AlPacino: printf("Paul Giamatti");
break;
case GaryOldman:printf("Donald Shuterland");
break;
case EdNorton: printf("Johnny Depp");
}
}

Q.5
What will be output when you will execute following c code?


#include
<stdio.h> 
void main(){
switch(*(1+"AB" "CD"+1)){
case 'A':printf("Pulp Fiction");
break;
case 'B':printf("12 Angry Man");
break;
case 'C':printf("Casabance");
break;
case 'D':printf("Blood Diamond");
}

}


Read More!!

What will be the Output Of the Following C-codes?

Q.1
Which of the following statements are correct about an array?

a:The array int num[26]; can store 26 elements.
b:The expression num[1] designates the very first element in the array.
c:It is necessary to initialize the array at the time of declaration.
d:The declaration num[SIZE] is allowed if SIZE is a macro.


Q.2
If char=1, int=4, and float=4 bytes size, What will be the output of the program ?

#include<stdio.h>


int main()
{
char ch = 'A';
printf("%d, %d, %d", sizeof(ch), sizeof('A'), sizeof(3.14f));
return 0;
}

Q.3
What will be the output of the program ?

#include<stdio.h>

int main()
{
char str[] = "Nagpur";
str[0]='K';
printf("%s, ", str);
str = "Kanpur";
printf("%s", str+1);
return 0;
}


Read More!!

What will be the Output Of the Following C-codes?

Q.1
Point out the error, if any in the program.

#include<stdio.h>
int main()
{
int P = 10;
switch(P)
{
case 10:
printf("Case 1");

case 20:
printf("Case 2");
break;

case P:
printf("Case 2");
break;
}
return 0;
}

Q.2
What will be the output of the program?


#include<stdio.h>
int main()
{
int i=2;
printf("%d, %d\n", ++i, ++i);
return 0;
}



Q.3
 In the expression a=b=5 the order of Assignment is NOT decided by Associativity of operators



A.true
B.false


Read More!!

What will be the Output Of the Following C-codes?

Q.1
How many times the program will print "TheNextLevel" ?

#include <stdio.h>
int main()
{
printf("TheNextLevel");
main();
return 0;
}


Q.2
How many times the while loop will get executed if a short int is 2 byte wide?


#include<stdio.h>

int main()
{
int j=1;
while(j <= 255) 

 { 
 printf("%c %d\n", j, j); 
 j++; 
 } 
 return 0; 



 Q.3 Which of the following errors would be reported by the compiler on compiling the program given below? 

 #include<stdio.h>
int main()
{
int a = 5;
switch(a)
{
case 1:
printf("First");

case 2:
printf("Second");

case 3 + 2:
printf("Third");

case 5:
printf("Final");
break;

}
return 0;
}


Read More!!