How to write a C++ program that retrieves all the numbers stored in a data file named Project? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to write a C++ program that retrieves all the numbers stored in a data file named Project?

As each number is retrieved, it is displayed on the screen. When the end of file is reached, the average of the numbers is displayed accurate to the nearest tenth. NOTE: Create a data file named Project and then copy and type the following numbers one 7 4 12 3 EXAMPLE: Given the numbers above, the output should be The average of 7 4 12 3 is 6.5

23rd Sep 2016, 2:27 PM
Najwa
Najwa - avatar
2 Answers
+ 3
program for average of six numbers. int arr[6],avg; for ( i=0;i<=5;i++) { cout << " enter number."; cin>> arr[¡]; cout<<arr[i]; } avg = (arr[0]+arr[1]+arr[2]+arr[3]+arr[4]+arr[5]) / 6 cout<<avg ;
23rd Sep 2016, 5:55 PM
Hitesh Datt
Hitesh Datt - avatar
0
what about the opening tge data file
23rd Sep 2016, 5:59 PM
Najwa
Najwa - avatar