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
573 days 17 hours 32 minutes ago

Mr.Prasad Good Job

heta
By: heta
571 days 12 hours 45 minutes ago

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

esha
By: esha
568 days 8 hours 48 minutes ago

test was good
new questions was there
thanks :)

esha
By: esha
568 days 8 hours 29 minutes ago

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

praveen
By: praveen
568 days 2 hours 36 minutes ago

Great job man !!!

satish
By: satish
567 days 13 hours 14 minutes ago

Question no 5: Its Compiler dependent.

Dhamu
By: Dhamu
566 days 2 hours 44 minutes ago

thank u sir

Ashitha Afsal
By: Ashitha Afsal
565 days 12 hours 26 minutes ago

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

Ravi
By: Ravi
565 days 3 hours 33 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
559 days 12 hours 10 minutes ago

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

praveen
By: praveen
553 days 25 minutes ago

nice work man thanks..:-)

PRASAD KOLEKAR
By: PRASAD KOLEKAR
552 days 11 hours 28 minutes ago

very tricky!

Milan Singh
By: Milan Singh
551 days 4 hours 42 minutes ago

Answer for 6th

bmko
By: bmko
547 days 11 hours 30 minutes ago

Question 2: I guess (char *)

Divya
By: Divya
523 days 13 hours 25 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
505 days 4 hours 6 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.

ravi Kumar
By: ravi Kumar
519 days 22 hours 33 minutes ago

hello

ravi Kumar
By: ravi Kumar
519 days 22 hours 29 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
362 days 17 hours 17 minutes ago

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

ravi Kumar
By: ravi Kumar
519 days 22 hours 27 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
493 days 6 hours 12 minutes ago

nice leraning for me. Thanku sir ji.

abhinav
By: abhinav
490 days 4 hours 1 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
458 days 5 hours 49 minutes ago

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

Bhanuprakash
By: Bhanuprakash
442 days 9 hours 21 minutes ago

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

maria
By: maria
431 days 8 hours 17 minutes ago

better luck 4 nxt time

maria
By: maria
431 days 8 hours 17 minutes ago

better luck 4 nxt time

S.Priyanka
By: S.Priyanka
362 days 17 hours 19 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
236 days 9 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.

Name:
Your Email:
Password:
Country:
Contact no:


Area code Number
Subjects you are interested in:
Word verification: (Enter the text as 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

Give live classes, create & sell online courses

Try it free Plans & Pricing

Connect