main()

{

int i, j, *p;

i = 25;

j = 100;

p = &i; // Address of i is assigned to pointer p

printf("%f", i/(*p) ); // i is divided by pointer p

}

a. Runtime error.

b. 1.00000

c. Compile error

d. 0.00000

Answers were Sorted based on User's Feedback



main() { int i, j, *p; i = 25; j = 100; p = &i; // Address of i is ass..

Answer / rk

d) it will print 0.0000.

If we typecast the result to float as shown below then
expected output will be printed(i.e. 1.0000)
printf("%f",(float) i/(*p) ); // i is divided by pointer p

Is This Answer Correct ?    8 Yes 0 No

main() { int i, j, *p; i = 25; j = 100; p = &i; // Address of i is ass..

Answer / guest

c) Error becoz i/(*p) is 25/25 i.e 1 which is int & printed
as a float,

So abnormal program termination,

runs if (float) i/(*p) -----> Type Casting

Is This Answer Correct ?    6 Yes 2 No

main() { int i, j, *p; i = 25; j = 100; p = &i; // Address of i is ass..

Answer / km

the answer to this question is implementation dependent:
if tried in Turbo C++
a) Runtime error
abnormal termination
if tried in Unix using GNU C
non of the above
you get a junk result

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Code Interview Questions

main() { int k=1; printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE"); }

1 Answers  


Write a program to implement the motion of a bouncing ball using a downward gravitational force and a ground-plane friction force. Initially the ball is to be projected in to space with a given velocity vector

2 Answers  


How to count a sum, when the numbers are read from stdin and stored into a structure?

1 Answers  


why is printf("%d %d %d",i++,--i,i--);

4 Answers   Apple, Cynity, TCS,


write a program in c to merge two array

2 Answers  






#include<stdio.h> main() { register i=5; char j[]= "hello"; printf("%s %d",j,i); }

2 Answers  


What is "far" and "near" pointers in "c"...?

3 Answers  


void main() { int const * p=5; printf("%d",++(*p)); }

3 Answers   Infosys, Made Easy, State Bank Of India SBI,


write a function to give demostrate the functionality of 3d in 1d. function prototye: change(int value,int indexX,int indexY,int indexZ, int [] 1dArray); value=what is the date; indexX=x-asix indexY=y-axis indexZ=z-axis and 1dArray=in which and where the value is stored??

0 Answers   Nagarro,


Cau u say the output....?

1 Answers  


main(){ int a= 0;int b = 20;char x =1;char y =10; if(a,b,x,y) printf("hello"); }

1 Answers   TCS,


Finding a number which was log of base 2

1 Answers   NetApp,


Categories