1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Allisa [31]
2 years ago
8

Write a program which populates an array with integer values read from a file. We do not know how many integers are in the file,

so you must loop until the end of the file is reached. For this problem, you may NOT use the function feof(). Instead, use the result returned from fscanf() to determine the end-of-file. Recall, we can set the result of fscanf() to an integer variable, and check to see if the integer variable is equal to the EOF marker. The program must take the items in the array and reverse them. You may use one array only to solve this problem.
Computers and Technology
1 answer:
max2010maxim [7]2 years ago
5 0

Answer:

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

int main()

{

int arr[100];

int i = 0;

int j = 0;

char c[10];

char temp;

int sum = 0;

FILE* fp;

if ((fp = fopen("test.txt", "r")) == NULL) {

printf("cannot open the file");

return;

}

else {

do {

temp = fgetc(fp);

if (temp == ' ' || temp == '\n') {

c[j] = '\0';

arr[i++] = atoi(c);

j = 0;

continue;

}

c[j++] = temp;

} while (temp != EOF);

for (j = i - 1; j >= 0; j--) {

printf("%d\n", arr[j]);

}

}

getchar();

}

Explanation:

You might be interested in
Which type of security threat installs to a computer without the user's knowledge and then monitors all computer activity?
STatiana [176]
That would be what is known as Spyware, a common form of this is known as a "Trojan Horse". This type of malware is typically latched on and hidden within files, such as when downloading a pirated version of a song, game, art-work, etc...
3 0
3 years ago
Read 2 more answers
Windows 8 uses a(n) ________ account for easy access and storage of online files.
Dafna1 [17]

Answer: OneDrive

Explanation: OneDrive

8 0
1 year ago
Wirte a program which asks the users to input length and calculates the area of a square.( Area = Length^2)​
kogti [31]

Explanation:

i hope this will help you

3 0
2 years ago
Which one of the following downloads and uploads files to and from a server? A. Client B. Internet protocol C. Server D. Worksta
earnstyle [38]
The answer is A. Client request and receive files to and from a server.
5 0
2 years ago
True/False: Each individual element of an array can be accessed by the array name and an element number, called a subscript. Tru
Dahasolnce [82]

Answer:

True

Explanation:

3 0
2 years ago
Other questions:
  • HELP ASAP????? please
    5·2 answers
  • A senior center would like to add a new computer to their library so that members can check their email and read book reviews
    11·2 answers
  • True / False<br> 1. A byte is a standardized unit of measure that is always 8-bits.
    7·1 answer
  • The area on your screen where you can access the tab and menu options for word is called what?
    8·2 answers
  • A method that receives a two-dimensional array uses two ____ pairs following the data type in the parameter list of the method h
    11·1 answer
  • One page of content in a PowerPoint presentation is referred to as a
    12·1 answer
  • Which application is a digital version of a manual typewriter? A. Database B. Presentation C. Spreadsheet D. Word processor
    8·2 answers
  • Koi jinda hei kya hello​
    13·2 answers
  • Ninety percent of the fastest-growing jobs require some kind of postsecondary education.
    7·1 answer
  • What is the difference between a field and an infoobject? What is the advantage of using infoobjects instead of fields in an ads
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!