Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
98 views
in Information Technology by (95.2k points)
closed by
Consider the ‘C’ statement printf (“%f”,(float) 7/5); It prints :
1. 1.0
2. 1.4
3. 2.0
4. None of the above

1 Answer

0 votes
by (95.4k points)
selected by
 
Best answer
Correct Answer - Option 2 : 1.4

Concept:

  • In C programming language, float is a data type that allows variables to store decimal values.
  • %f is a format specifier used for float data type
  • The storage size of the float data type is 4 bytes. This also varies depending upon the processor in the CPU.
  • Store up to 6 digits after decimal using float data type. For example, 21.456789 can be stored in a variable using the float data type.

Code:

#include<stdio.h>

int main()

{

printf ("%f",(float) 7/5);

return 0;

}

Output: 1.4

Confusion Point:

Some compiler will output 1.40000 and to get answer upto 1 decimal places execute the below given statement:

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...