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

Predict the Output: int main() { int *p=(int *)2000; scanf("%d",2000); printf("%d",*p); return 0; } if input is 20 ,what will be print

2 Answers  


posted by surbhi just now main() { float a = 5.375; char *p; int i; p=(char*)&a; for(i=0;i<=3;i++) printf("%02x",(unsigned char) p[i]); } how is the output of this program is :: 0000ac40 please let me know y this output has come

2 Answers   GATE,


Write a program that reads a dynamic array of 40 integers and displays only even integers

2 Answers  


main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }

9 Answers   CSC, GoDB Tech, IBM,


program to find magic aquare using array

4 Answers   HCL,






given integer number,write a program that displays the number as follows: First line :all digits second line : all except the first digit . . . . Last line : the last digit

8 Answers  


can u give me the c codings for converting a string into the hexa decimal form......

1 Answers  


#ifdef something int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }

1 Answers  


What are the following notations of defining functions known as? i. int abc(int a,float b) { /* some code */ } ii. int abc(a,b) int a; float b; { /* some code*/ }

1 Answers  


how to return a multiple value from a function?

2 Answers   Wipro,


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

0 Answers   TCS,


write a program to find out roots of quadratic equation "x=-b+-(b^2-4ac0^-1/2/2a"

2 Answers  


Categories