Float numbers - C | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 3

Float numbers - C

Input five float numbers in one line. Print out the float numbers in one line, separated by spaces, and make sure you only print up to 1 decimal place. Add the first four float numbers and check if their sum is greater than the fifth float number. Print out "Yes" if they are. Input 1. First float number 2. Second float number 3. Third float number 4. Fourth float number 5. Fifth float number Output The first five lines will contain message prompts to input the five float numbers. The next line contains the inputted float numbers. The last line contains "Yes" if the condition is true.

16th Nov 2021, 11:22 AM
nalla
1 Answer
0
Nalla #include <stdio.h> int main(void) { float numList[5]; float numSum; puts("Please enter five(5) floating point (decimals) numbers"); for(int i = 0; i < 5; i++){ scanf("%f", &numList[i]); } for(int i = 0; i < 5; i++){ printf("%.1f\n", numList[i]); } for(int i = 0; i < 4; i++){ numSum += numList[i]; } if(numSum >= numList[4]){ puts("Yes"); } } This will do what you are asking about. What are your questions? I am guessing that assignment is no longer due :-).
23rd Feb 2022, 10:37 PM
William Owens
William Owens - avatar