Hey I have this asignment due on sunday at 11 pm and have no idea how to do it if anyone could help me out i would greatly appreciate it. The assignment is to create a 3 by 4 int array containing 1,2,3,4,5,6,7,8,9,10,11,12. I then have to use loops to get the average of each row and collumn in the array
5 1088
Hey I have this asignment due on sunday at 11 pm and have no idea how to do it if anyone could help me out i would greatly appreciate it. The assignment is to create a 3 by 4 int array containing 1,2,3,4,5,6,7,8,9,10,11,12. I then have to use loops to get the average of each row and collumn in the array
to get you started, you're going to be using a 2-dimensional array which will look like this by calling array[3][4]:
then you'll use for loops to put numbers into each array element and then you can do the calculations
yeah see that where im stuck...on the for loop part, i understand how to make an array but i really cant figure out how to make a loop which will give the average of each collumn and row of that array.
I give up can someone please just show me the code for this : /?
Hi there,
Here is the program which calculates the average of each row and column. See if it helps you,
#include<stdio.h>
int main()
{
int intArray[3][4]={{1,2,3,4},
{5,6,7,8},
{9,10,11,12}};
int i=0,j=0;
int sCol=0,sRow=0;
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
sRow=sRow+intArray[i][j];
}
printf("The Average of the %d Row is %d\n",i,sRow/4);
sRow=0;
}
for(i=0;i<4;i++)
{
for(j=0;j<3;j++)
{
sCol=sCol+intArray[j][i];
}
printf("The Average of the %d Column is %d\n",i,sCol/3);
sCol=0;
}
Thanks and Regards,
Aarthy
thanks a ton that really helped me out alot I greatly appreciate your help. I just have one more thing to ask. How would i make it so the averages are returned as floats instead of intigers?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Spamtrap |
last post by:
I only do occasional Perl programming and most things I write are
short processes. I have something I'm working on that is scanning a
text file with about 15 million lines and trying to extract...
|
by: aj902 |
last post by:
Hello ,
I am trying to create a program
where all detail,
http://www.albany.edu/~csi333/projects.htm
|
by: vgame64 |
last post by:
Hi, I have been struggling with writing a program for a few hours. The
requirements are that: """You will be writing a program which will
determine whether a date is valid in
terms of days in that...
|
by: robinsand |
last post by:
My apologies to those of you who are more advanced Visual C++ .NET
programmers, but I am working on a project for an MBA course that is
condensed into an eight-week schedule, and I need help...
|
by: pamelafluente |
last post by:
I am still working with no success on that client/server
problem. I need your help. I will submit simplified versions
of my problem so we can see clearly what is going on.
My model:
A client...
|
by: skumar434 |
last post by:
i need to store the data from a data base in to structure
.............the problem is like this ....suppose there is a data base
which stores the sequence no and item type etc ...but i need only...
|
by: naknak4 |
last post by:
Introduction
This assignment requires you to develop solutions to the given problem
using several different approaches (which actually involves using three
different STL containers). You will...
|
by: naknak |
last post by:
Introduction
This assignment requires you to develop solutions to the given problem
using several different approaches (which actually involves using three
different STL containers). You will...
|
by: peterggmss |
last post by:
This is a slot machine game, 2 forms. One is the actual game (frmMachine) and the other is in the background and randomizes the images shown on frmMachine. I need to make frmMachine wait for...
|
by: raghavshastri |
last post by:
You are to write a C++ program to perform a statistical analysis of the blobs in an image. The image will be a grayscale image in PGM format for simplicity.
Here is a sample PGM image with 10...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |