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

All the combinations of prime numbers whose sum gives 32

1 Answers   HHH,


#include<stdio.h> int main() { int x=2,y; y=++x*x++*++x; printf("%d",y); } Output for this program is 64. can you explain how this output is come??

1 Answers  


#define max 5 #define int arr1[max] main() { typedef char arr2[max]; arr1 list={0,1,2,3,4}; arr2 name="name"; printf("%d %s",list[0],name); }

1 Answers  


main() { int i=5; printf("%d",++i++); }

1 Answers  


find simple interest & compund interest

2 Answers  






#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s=malloc(sizeof(struct xx)); printf("%d",s->x); printf("%s",s->name); }

1 Answers   TCS,


main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }

2 Answers  


main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

2 Answers  


Write a program that produces these three columns sequence nos. using loop statement Sequence nos. Squared Squared + 5 1 1 6 2 4 9 3 9 14 4 16 21 5 25 30

1 Answers   GoDB,


To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']

0 Answers  


Write a C program that defines a 2-dimentional integer array called A [50][50]. Then the elements of this array should randomly be initialized either to 1 or 0. The program should then print out all the elements in the diagonal (i.e. a[0][0], a[1][1],a[2][2], a[3][3], ……..a[49][49]). Finally, print out how many zeros and ones in the diagonal.

2 Answers  


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,


Categories