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
Choose all statements that identify the benefits of programming design.
Lubov Fominskaja [6]

Answer:

yes

Explanation:

it provides a design approach to a specific type of problem

4 0
3 years ago
Read 2 more answers
How does Technology impact any profession or occupation?
Brrunno [24]

Technology can create or dimish occupations.

Technology can also make the job easier

8 0
3 years ago
Ruben is helping his team choose a leader. Of the people Ruben is considering, which one has qualities most related to being an
siniylev [52]

An effective team leader shows great skills in every area, shows great support and respect to his teammates and is very easy to get along with.

5 0
3 years ago
Read 2 more answers
Which one of the following pieces of information would be allowed as part of a limited data set?
Inessa05 [86]
Phone number would be allowed
6 0
3 years ago
Consider the code fragment below (with nested loops). int sum = 0;for (int i = 1; i &lt; 5; i++) for (int j = 1; j &lt;= i; j++)
sammy [17]

Answer:

Option d is the correct answer for the above question.

Explanation:

  • The first loop of the program has a second loop and then the statement. In this scenario, the second loop executes for the value of the first loop and the statement executes for the value of the second loop.
  • The first loop executes 4 times, Then the second loop or inner loop executes n times for the n iteration of the first loop, for example, 1 time for the first iteration of the first loop, 2 times for the second iteration of the first loop and so on.
  • Then the inner loop executes (1+2+3+4) iteration which gives the result 10 iterations.
  • The sum initial value is 0 and the "sum++", increase the value of the sum by 1.
  • So the value of the sum becomes 10 after completing 10 iterations of the inner for loop.
  • Hence the 10 will be the output. So the Option d is the correct answer while the other is not.
3 0
3 years ago
Other questions:
  • Designing, producing, exhibiting, performing, writing, and publishing multimedia content including visual and performing arts an
    6·1 answer
  • Write a function called median, that takes as parameter a full, sorted array of doubles and returns the median of the list. For
    15·1 answer
  • Which four of the following hardware components are specifically used to enable networking and are not part of a stand-alone com
    13·2 answers
  • 1. What runs horizontally and is identified with numbers?
    12·2 answers
  • Someone plz answer
    8·1 answer
  • Such a class might store information about the account balance, the name of the account holder, and an account number. What inst
    13·1 answer
  • Explain each kind of pointer and for what it is appropriate
    15·2 answers
  • I need help with this question. its in the photo
    10·1 answer
  • Read the attached paper titled A Survey of Coarse-Grained Reconfigurable Architecture and comment on it. Make sure to specifical
    5·1 answer
  • How to transfer polygon from eth to polygon in ledger live
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!