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
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 |
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 |
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 |
Write a single line c expression to delete a,b,c from aabbcc
#include<conio.h> main() { int x,y=2,z,a; if(x=y%2) z=2; a=2; printf("%d %d ",z,x); }
void main() { int i=10, j=2; int *ip= &i, *jp = &j; int k = *ip/*jp; printf(ā%dā,k); }
Find your day from your DOB?
15 Answers Accenture, Microsoft,
main() { int i=5; printf("%d",++i++); }
void main() { char a[]="12345\0"; int i=strlen(a); printf("here in 3 %d\n",++i); }
What is wrong with the following code? int *foo() { int *s = malloc(sizeof(int)100); assert(s != NULL); return s; }
#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }
Set up procedure for generating a wire frame display of a polyhedron with the hidden edges of the object drawn with dashed lines
#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d..%d",*p,*q); }
main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }
main() { int i=300; char *ptr = &i; *++ptr=2; printf("%d",i); }