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

You are given any character string. Find the number of sets of vowels that come in the order of aeiou in the given string. For eg., let the given string be DIPLOMATIC. The answer returned must be "The number of sets is 2" and "The sets are "IO and AI". Vowels that form a singleton set must be neglected. Try to post the program executable in gcc or g++ or in java.

3 Answers  


What is the subtle error in the following code segment? void fun(int n, int arr[]) { int *p=0; int i=0; while(i++<n) p = &arr[i]; *p = 0; }

1 Answers  


#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

2 Answers  


How do you write a program which produces its own source code as its output?

7 Answers  


pls anyone can help me to write a code to print the values in words for any value.Example:1034 to print as "one thousand and thirty four only"

2 Answers  






write a program in c to merge two array

2 Answers  


#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }

1 Answers  


Link list in reverse order.

8 Answers   NetApp,


int a=1; printf("%d %d %d",a++,a++,a); need o/p in 'c' and what explanation too

1 Answers  


What is the main difference between STRUCTURE and UNION?

13 Answers   HCL,


main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); }

2 Answers   Wipro,


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

3 Answers  


Categories