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%l f%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.
1 1525
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 generate a random
number N from the total count. The problem is, now I need to access
entry no.N of table A, yet A doesn't have a counting field; so I cannot
execute something like "select * from A where id = N". Does anybody
know how to access a...
|
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 that sums the values from 2 textboxes. I wanted to implement a simple data validation that would spit out various error messages if the user typed in incorrect data.
I managed to vomit out the following code. Yes I know it's beastly,...
|
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 other things.
What would be a good design to accomplish these goals? Here are the
ideas that I have come up with:
Class X = class with data that I want to put into csv.
1. Nested Function Object
use a nested function object to do the conversion.
|
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 visual c# express edition
2005 as well as sql 2005 express.
Here's the thing I've been trying to figure out. I want to insert a new
row in the Employees Table when I click a button called btnAdd. When I
was learning delphi, I would just put the...
|
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 2718 2895
I wanna to read the data to an array, as the follows:
| |
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 whom to contact for a program or development of a program.
A little info:
I work for a radio broadcasting company. We have 15+ radio stations. Each station has its own website, but all from the same company, so basically same site, different...
|
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 Management
Anant Jhingran.
--------------------------------------------------
Are you applying semantic technologies for web or enterprise
applications? Do you have a problem or question related to RDF,
SPARQL, taxonomies, ontologies or semantic...
|
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
provides form data entry, data capture, HTML/SGML coding, image
scanning, file conversion with low cost, high quality,99.98% accuracy
and time bound.
Data Conversion Services offer cost effective data conversion
projects, Outsourcing Data...
|
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 simple code or smt? Thank afurther for ur answer!
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |