C Programming test

What will be output if you will compile and execute the following c code?

#define x 5+2

void main(){

int i;

i=x*x*x;

printf("%d",i);

}


What will be output if you will compile and execute the following c code?

void main(){

int i=320;

char *ptr=(char *)&i;

printf("%d",*ptr);

}


What will be output if you will compile and execute the following c code?

void main(){

char c=125;

c=c+10;

printf("%d",c);

}


What will be output if you will compile and execute the following c code?

void main(){

float a=5.2;

if(a==5.2)

printf("Equal");

else if(a<5.2)

printf("Less than");

else

printf("Greater than");

}


What will be output if you will compile and execute the following c code?

void main(){

int a=10;

printf("%d %d %d",a,a++,++a);

}


#include "stdio.h"

#include "string.h"

void main(){

char *str=NULL;

strcpy(str,"cquestionbank");

printf("%s",str);

}


What will be output if you will compile and execute the following c code?

void main(){

int x;

for(x=1;x<=5;x++);

printf("%d",x);

}


What will be output if you will compile and execute the following c code?

void main(){

printf("%d",sizeof(5.2));

}


What will be output if you will compile and execute the following c code?

#include "stdio.h"

#include "string.h"

void main(){

char c='\08';

printf("%d",c);

}


What will be output if you will compile and execute the following c code?

#define call(x,y) x##y

void main(){

int x=5,y=10,xy=20;

printf("%d",xy+call(x,y));

}











































































Description:

This test is based on 'C' Programming skills

Comments
Suresh Rajappan
By: Suresh Rajappan
934 days 10 minutes ago

Mr.Prasad Good Job

heta
By: heta
931 days 19 hours 22 minutes ago

it was good one,can u post more such test with answer explanation too

esha
By: esha
928 days 15 hours 25 minutes ago

test was good
new questions was there
thanks :)

esha
By: esha
928 days 15 hours 7 minutes ago

qustion no.2)
answer is 64(given by you)
but i think its cmpile time error
plz explain

praveen
By: praveen
928 days 9 hours 13 minutes ago

Great job man !!!

satish
By: satish
927 days 19 hours 52 minutes ago

Question no 5: Its Compiler dependent.

Dhamu
By: Dhamu
926 days 9 hours 22 minutes ago

thank u sir

Ashitha Afsal
By: Ashitha Afsal
925 days 19 hours 4 minutes ago

In the Explanation window The right most part is not visible,I can't read it in full

Ravi
By: Ravi
925 days 10 hours 11 minutes ago

Q6 : Answer is wrong. This will give segmentation fault error. Memory is not allocation for the str and strcpy will try to copy the string at the 0th address i.e NULL and will lead to error.

tarun
By: tarun
919 days 18 hours 48 minutes ago

questions are nice but u should also include the basic general questions also...........

praveen
By: praveen
913 days 7 hours 3 minutes ago

nice work man thanks..:-)

PRASAD KOLEKAR
By: PRASAD KOLEKAR
912 days 18 hours 6 minutes ago

very tricky!

Milan Singh
By: Milan Singh
911 days 11 hours 20 minutes ago

Answer for 6th

bmko
By: bmko
907 days 18 hours 8 minutes ago

Question 2: I guess (char *)

Divya
By: Divya
883 days 20 hours 3 minutes ago

there are some errors in the answers it seems like in Q.5 the answer am gettin is option-d, but they gave it as option-a! if that was correct, then some one could help me to understand!

Divya
By: BHARATHI
865 days 10 hours 43 minutes ago

hi..in printf,the precedence is from left to right....so first a=11,then a =11, n then a=12(post incremented earlier)...so ans is 11 11 12.

Divya
By: yt
233 days 12 hours 41 minutes ago

at first y a=11?? its declared that a=10 and not incremented...
and for printf its not left to right in this case its right to left.
because it uses stack and so the last element would be poped out first and executed.

ravi Kumar
By: ravi Kumar
880 days 5 hours 11 minutes ago

hello

ravi Kumar
By: ravi Kumar
880 days 5 hours 7 minutes ago

another question sir int a=10 cout<how answer could be 12 11 11 ? please tell me any one.

ravi Kumar
By: S.Priyanka
722 days 23 hours 55 minutes ago

Ya sir even i don't under stand that question...

ravi Kumar
By: ravi Kumar
880 days 5 hours 5 minutes ago

dear varaprasad sir
some question are confusing like #define X 5 2 void main{cout X*X*X;}
how it is possible is not clear can you help me?

Avinash Kumar Yadav
By: Avinash Kumar Yadav
853 days 12 hours 50 minutes ago

nice leraning for me. Thanku sir ji.

abhinav
By: abhinav
850 days 10 hours 38 minutes ago

answer of ques2 is wrong.it leads to compiler error. u can not have '*'
operator(here means to derefernce) on char pointer.so it will give error like" invalid operands to binary *"

Ashwani Kumar Sinha
By: Ashwani Kumar Sinha
818 days 12 hours 27 minutes ago

GOOD EVENING SIR
TODAY I AM VERY HAPPY TO SOLVE THIS TEST.
THANKS!

Bhanuprakash
By: Bhanuprakash
802 days 15 hours 59 minutes ago

it was really good test, i need some c and c questions for preparing aptitude test for interview

maria
By: maria
791 days 14 hours 55 minutes ago

better luck 4 nxt time

maria
By: maria
791 days 14 hours 55 minutes ago

better luck 4 nxt time

S.Priyanka
By: S.Priyanka
722 days 23 hours 57 minutes ago

There was a lot of new quesions. It is a very good experience. If there is a explaination of these questions means it will be very useful....

Kazi gulam
By: Kazi gulam
596 days 6 hours 47 minutes ago

#define x 5 2 is without parentheses,therefore result into 5 2*5 2*5 2 =27 otherwise it could be 343

Want to learn?

Sign up and browse through relevant courses.

or fill this simple form
Name:
Your Email:
Password:
Country:
Contact no.:


Area code Number
Subjects you are interested in:
Word verification: (Enter the text as shown in image)


Sign Up Already a member? Sign In
I agree to WizIQ's User Agreement & Privacy Policy
varaprasad J
STUDENT
User
11 Followers
Test: 1

Your Facebook Friends on WizIQ

Connect