Time: 6 minute
(1)
void main(){
float a=30.3f;
int y=5;
clrscr();
printf("%d",a%y);
getch();
}
What will be output when you will compile above code?
(a) 6
(b) 6.0
(c) 7
(d) Compiler error
(e) None of these
int x=5;
float r=5.0;
clrscr();
printf("%x %X %o",sizeof(x,r),sizeof(r,x),sizeof(sizeof(5.0)));
getch();
}
What will be output when you will compile above code?
(a) 4 2 2
(b) 2 4 4
(c) 2 4 2
(d) Compiler error
(e) None of these
int y=15,z=25;
function(&y,&z);
clrscr();
printf("%d\t%d",z,y);
getch();
}
function (int *p,int *q){
return(*p=(*p+*q)-(*q=*p));
}
What will be output when you will compile above code?
(a) 25 15
(b) 15 25
(c) 25 25
(d) Compiler error
(e) None of these
int a=-1;
static int count;
clrscr();
while(a){
count++;
a&=a-1;
}
printf("%d",count);
getch();
}
What will be output when you will compile above code?
(a) 15
(b) 16
(c) 17
(d) Compiler error
(e) None of these
typedef float arr[10];
arr b={2,4,6};
clrscr();
printf("%d",sizeof(b));
getch();
}
What will be output when you will compile above code?
(a) 40
(b) 12
(c) 4
(d) Compiler error
(e) None of these
*((int *)p)=20;
}
void main(){
int const x=10;
change(&x);
clrscr();
printf("%d",x);
getch();
}
What will be output when you will compile above code?
(a) 10
(b) 20
(c) 30
(d) Compiler error
(e) None of these
(1)(d) Modular division is only possible for integral data type
(2)(a)
(3)(b)
(4)(b)
(5)(a)
(6)(b)
If you have any quires or suggestions on above c programming language quizzes or quiz with solution online test, please share us.
22 comments:
the 3rd question answer cant be right.I read in a book that addition of two pointers is wrong
hi anu
Pointer alway refer to some value or address .When it is referring to some value (integral) means we are performing addition operation between two number. So answer of question 3 is correct.
Kindly explain number 4. I dont undestrand how it turned out to be 16. How come that it looped 16 times?
hi angie
For if condition zero means false and any non zero means true. Initial value of variable a is -1 i.e. and while loop will execute until variable a became zero.
a =a &(a-1) always double the value of a i.e. -2 ,-4, -8, -16, ….
After the beyond of range of signed int it became zero due to cyclic nature of int data type. More details of cyclic nature visit this link: http://cquestionbank.blogspot.com/2009/06/cyclic-nature-of-data-type-in-c.html
can u explain hw does the value of a gets double in num 4? wts dat expression?
can u plz tell how can we use c programming to just print a statement
on dos shell by writing a program without using even a single semi-colon in the whole code...???
Solution 1:
void main(){
while(!printf("Hello world"));
}
Output: Hello world
Solution 2:
void main(){
if(printf("Hello world")){}
}
Output: Hello world
Solution 3:
void main(){
switch(printf("Hello world")){}
}
Output: Hello world
can u pls explain ues. no. 2
Question number 2 output is 4 4 4. The answer is incorrect. Plus, this really weird way of using sizeof operator. Why in the heck you want to overload this operator? I have developed C code for the past 17 years and never used the sizeof in this fashion. What a stupid and really irrelevant C pop-quiz question.
hi anu 3rd is absolutely right n u r also right pointers cant be added bt here we r nt adding pointer we r adding da values on which pointers r pointing nw got it sweetie
Can anyone tell me wat the 1st question declaration float f=33.3f; mean?
Then in the 4th how is that sizeof() operator acccepts 2 arguments?
Regarding question 3:
How can you claim that answer b is right, since C99 standard is not guarantying order of evaluation operands in statement. So, you can't be sure that (*p+*q) will be evaluated before (*q=*p).
Can u Plz explain How 4th answer is correct?
anyone can give me solution of all these questions?
hey i can't get u'r explanation 2 4th one. the statment a&=a-1;... how it works?
hi Nani,
a&=a-1
a=a&(a-1)
here & is bitwise and operator
For example: 5&3
binary of 5 is: 101
binary of 3 is: 011
in bitwise and operator:
0&0=0
0&1=0
1&0=0
1&1=1
I think now you can find 5 &3
If your doubt is something different then you can ask again.
hello this is sathish
i want tht answers wit explanation
pls send to me
pgdcasathish@gmail.com
hi i can't undarstand the ans 4 4th ques.so pls xplain it me clearly
give theanswer with explanation of 2 and 4 question.
I think the 2> is questionable. First, the usage of sizeof is not in good style. Second, its result is compiler dependent.
The questions are fine
Explain 6th one.Const value can not be changed
Post a Comment