473,413 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

question about labeling entry data

I have to create a 2 dimensional array (5X4 (int type)) which can hold 4 exam scores for each of 5 students.Here is my code:

#include<stdio.h>

int main(void)
{
int numstu = 5;
double studentscore[numstu][5];
double score1, score2, score3, score4;
int i, z;
double avgstu;
double avgexam = 0;
double sum = 0;
for(i = 0; i < 5; i++){
printf("Please input 4 exam scores for student %d: ", i+1);
scanf("%lf%lf%lf%lf", &score1, &score2, &score3, &score4);
studentscore[i][0] = score1;
studentscore[i][1] = score2;
studentscore[i][2] = score3;
studentscore[i][3] = score4;
avgstu = (score1 + score2 + score3 + score4) / 4.0;
studentscore[i][4] = avgstu;
printf("Average score for student %d is: %lf\n", i+1, avgstu);
}
for(z = 0; z < 4; z++){
for(i = 0; i < 5; i++){
avgexam += studentscore[i][z] / 5;
}
printf("Average exam %d is: %lf\n", z+1, avgexam);
avgexam = 0;
}
return 0;
}
Now I a asked to write a function that will output the entry data appropriately labeled, for example:

Student Data

Exam 1 Exam 2 Exam 3 Exam 4
1 75 82 66 87
2 69 59 72 77
3 66 87 77 62
4 80 57 91 93
5 94 86 88 96

Can someone please give me a hint of how to do that? I have no idea how to start.
Dec 6 '11 #1
1 1509
weaknessforcats
9,208 Expert Mod 8TB
First, you say you need an array of int but you have coded and array of double.

Second, read this: http://bytes.com/topic/c/insights/77...rrays-revealed

Third, write a function that can display one row of your array.

Fourth, write a loop in main() that passes each eement of your array to the function you just wrote.
Dec 6 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Qun Cao | last post by:
Hi, I have a question about sql query, I want to access a random entry in table A. It should be a simple task, what I need is to first do "select count(*) from A" to get the total, then...
4
by: sanou | last post by:
Hi No doubt this question, or a similar version of it, has been asked before. But, I was looking around the forums and i couldn't find anything. I'm using VC++ to create a simple calculator...
4
by: alacrite | last post by:
I have a class that I want to turn its contents into csv file. I want to be able to set the value of the delimiter, the name of the file it gets saved to, the path of that file, and maybe a few...
2
by: uluvale96799 | last post by:
Hi, I'm very new to programming so forgive me for asking the dumb question. I'm trying to develop a database application using c#, and I'm using the northwind database. I'm currently using...
7
by: bowlderster | last post by:
Hello, all. This is the text file named test.txt. 1041 1467 7334 9500 2169 7724 3478 3358 9962 7464 6705 2145 6281 8827 1961 1491 3995 3942 5827 6436 6391 6604 4902 1153 1292 4382 9421 1716...
1
by: scottdavid88 | last post by:
Ok, I am not sure if this is in the right forum or not (please feel free to move it where it would be more appropriate). I need help finding a program or maybe some guidance on where to look or...
0
by: knorth | last post by:
If you submit the best question for the workshop at LinkedData Planet, you'll win admission to the conference, including keynotes by W3C Director Sir Tim Berners-Lee and IBM CTO for Information...
0
by: dataentryoffshore | last post by:
Get a Discount up to 60% on data entry, data capture, dataentry services, large volume data processing and data conversion services through offshore facilities in India. Offshore data entry also...
0
by: csudess | last post by:
I have used perl Tk and i have an entry, i would like to send the entry value to another pc how could i get that? the socket is working between two computer but how could i send data? Anybody have a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.