FIND THE OUTPUT IF THE INPUT IS 5 5.75
void main()
{
int i=1;
float f=2.25;
scanf("%d%f",&i,&f);
printf("%d %f",,i,f);
}
ANSWER IS 5 AND 2.25 WHY?

Answers were Sorted based on User's Feedback



FIND THE OUTPUT IF THE INPUT IS 5 5.75 void main() { int i=1; float f=2.25; scanf("..

Answer / biren

5 2.25

Is This Answer Correct ?    6 Yes 4 No

FIND THE OUTPUT IF THE INPUT IS 5 5.75 void main() { int i=1; float f=2.25; scanf("..

Answer / hari.11

hey,
if we give input as 5 5.75
output would be: 5 5.750000

for further queries and discussions, visit..

http://forum.campusmaniac.com/
http://www.campusmaniac.com/

Is This Answer Correct ?    1 Yes 0 No

FIND THE OUTPUT IF THE INPUT IS 5 5.75 void main() { int i=1; float f=2.25; scanf("..

Answer / suman halder

There is a tiny mistake in the question..It should be..

FIND THE OUTPUT IF THE INPUT IS 5 5.75

void main()
{
int i=1;
float f=2.25;
scanf("%d %d",&i,&f);
printf("%d %f",,i,f);
}
ANSWER IS 5 AND 2.25 WHY?

The answer of this question actually lies within the question itself..
if we look at the scanf statement ,then the actual reason of the output will be revealed..
In scanf,we are trying to get the input into a floating point number through %d format specifier which is the format specifier for integers..here,lies the anomaly..
nothing actually get stored within f through scanf ,so the previous value of f is retained..and that gets printed..
thats it..

*** if we try the reverse of it.i.e using %f,we wanna get the value into an integer..the compiler may report some error like "floating point format not linked"...we can abstain the error by intoducing a linkfloat function but still there will be some anomaly in the value that get stored in the variable ..so,to get the expected output we need to specify the correct format specifier....dnt trust printf or scanf to perform the proper typecasting for u..
do it explicitly..

linkfloat()
{
float a,*b;
b=&a;
a=*b;
}

Is This Answer Correct ?    0 Yes 0 No

FIND THE OUTPUT IF THE INPUT IS 5 5.75 void main() { int i=1; float f=2.25; scanf("..

Answer / reshma pawar

there is error in
printf("%d %f",,i,f);
because 2 (,) operators are used
an if operator is removed then output will be
5 5.750000

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Write a program to find the given number is odd or even without using any loops(if,for,do,while)

4 Answers   CNC, Gokul,


What is the meaning of int *x[]();?

1 Answers  


what is the difference between char * const and const char *?

2 Answers   TCS,


Is the C language is the portable language...If yes...Then Why...and if not then what is problem so it is not a Portable language..???

2 Answers   TCS,


WAP to accept basic salary of an employee? Calculate it HRA=25%,DA=30%,PF=30%&net salary display all contents?

6 Answers   Finite Infotech, Lovely Professional University, Wipro,






What is Memory leakage ?

2 Answers   HCL,


Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.

0 Answers  


What functions are used for dynamic memory allocation in c language?

0 Answers  


how to do in place reversal of a linked list(singly or doubly)?

3 Answers  


Is there any possibility to create customized header file with c programming language?

0 Answers  


i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k);

8 Answers   HCL,


Please write the area of a RIGHT ANGLED TRIANGLE.

1 Answers  


Categories