C Programming, getting data from a file and computing them into 5 parallel arrays so that they can be used for later calculation.
Also please avoid using structures at all costs for this code as they have not yet been covered.


c code:
#include <stdio.h>
#include <stdlib.h>
//structure pedestrian
struct Pedestrian
{
//variables
int yyyy;
int mm;
int dd;
int day;
int dayCount;
};
int main()
{
struct Pedestrian p[4000]; //array of struct objects
int n=0;
FILE *fptr;
char line[256];
fptr=fopen("pedestrian.tsv","r");//file
if(!fptr)
{
printf("File not found\n");
return 1;
}
//ignore first two lines
fgets(line, sizeof(line), fptr);
fgets(line, sizeof(line), fptr);
//read and store in structure
while(!feof(fptr))
{
fscanf(fptr,"%d%d%d%d%d",&p[n].yyyy, &p[n].mm,&p[n].dd,
&p[n].day, &p[n].dayCount);
n++; //line count
}
//print the results
printf("\nS1: Total data lines = %d", n);
printf("\nS1: First data line = %d/%d/%d,
%d",p[0].dd,p[0].mm,p[0].yyyy,p[0].dayCount);
printf("\nS1: last data line = %d/%d/%d,
%d",p[n-1].dd,p[n-1].mm,p[n-1].yyyy,p[n-1].dayCount);
return 0;
}
output:

//i have given the output for file with only 3 lines.. you can give n numbers in your file.. it works fine..
for any clarification, do comments, please give me thumbs up..
C Programming, getting data from a file and computing them into 5 parallel arrays so that...
Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e. parallel arrays … called multiple arrays in the zyBook) Transform data Read from files Write to files structs Code Requirements Start with this code: mtnpathstart.zip Do not modify the function signatures provided. Do not #include or #include Program Flow Read the data into a 2D array Find min and max elevation to correspond to darkest and brightest color, respectively Compute the shade of...
Write a C++ program that will input data from a Comma-separated
values (.csv) file and output some information about it. This
program uses a csv file from Yahoo Finance
(.csv) filename : SBUX.csv
1. Output the name of the ticker to the console screen (without
the “.csv”)
2. Output the start date and end date that was found in the
file
3. Output how many trading day(s) existed in the file
4. Prompt the use to input a number of...
Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e. parallel arrays … called multiple arrays in the zyBook) Transform data Read from files Write to files structs Code Requirements Start with this code: mtnpathstart.zip Do not modify the function signatures provided. Do not #include or #include Program Flow Read the data into a 2D array Find min and max elevation to correspond to darkest and brightest color, respectively Compute the shade of...
Code with Java using arrays and Scanner only ( input should end with 0 to terminate the program) Everyone loves to be celebrated on their birthdays. Birthday celebration can encourage positive social interaction among co-workers, foster friendship among classmates or even strengthen bond between families. Birthday graph can be display in many forms. It can a creative drawing consists of cupcakes, balloons, candles with names, or it can be in the form of simple bar chart to indicate the birthday...
C++ Please Contact list - functions & parallel arrays/CStrings No Vectors can be used since we haven't learned them yet !! A contact list is a place where you can store a specific information with other associated information such as a phone number, email address, birthday, etc. Write a program that will read 5 data pairs into two parallel arrays. Data pairs consist of a name (as a CString) and a GPA (double). That list is followed by a name,...
Introduction to Data Structures programming assignments can be completed either in C++ (preferred) or in Java. In both cases you cannot use libraries or packages that contain pre-built data structures, other than built-in support for objects, arrays, references, and pointers. Classes in C++ and Java can represent anything in the real world. This assignment is to write a class to represent a Date in a Calendar. Date Class Member Variables The following table identifies and describes the purpose of each...
1. Write a C++ program that reads daily weather observation data from a file and writes monthly and annual summaries of the daily data to a file. a. The daily weather data will be contained in a file named wx_data.txt, with each line of the file representing the weather data for a single day. b. For each day, the date, precipitation amount, maximum temperature, and minimum temperature will be provided as tab-separated data with the following format: 20180101 0.02 37...
can someone please comment through this code to explain me
specifically how the variables and arrays are working? I am just
learning arrays
code is below assignment
C++
Programming from Problem Analysis to Program Design by D. S. Malik,
8th ed.
Programming
Exercise 12 on page 607
Lab9_data.txt
Jason, Samantha, Ravi,
Sheila, and Ankit are preparing for an upcoming marathon. Each day
of the week, they run a certain number of miles and write them into
a notebook. At the...
Lab 2: (one task for Program 5): Declare an array of C-strings to hold course names, and read in course names from an input file. Then do the output to show each course name that was read in. See Chapter 8 section on "C-Strings", and the section "Arrays of Strings and C-strings", which gives an example related to this lab. Declare the array for course names as a 2-D char array: char courseNames[10] [ 50]; -each row will be a...
Write a C++ program that demonstrates use of programmer-defined
data structures (structs), an array of structs,
passing an array of structs to a function, and returning a struct
as the value of a function. A function in the program should read
several rows of data from a text file. (The data file should
accompany this assignment.) Each row of the file contains a month
name, a high temperature, and a low temperature. The main program
should call another function which...