C :: Program To Find Mean Of Elements In Columns Which Are Divided By 3
Aug 9, 2014
The program need to find mean of elements in columns which are divided by 3. And to print which colmn has the greater mean
Example
For matrix:
7 9 5
17 15 30
29 34 60
Program print: 0 12 45. The greater mean: 3 column.
I wrote this code and it prints 0 12 45 idk how to find which column has greater mean?
Code:
#include <stdio.h>
#define max 50
int main()
{int n,m,i,j,k,d,br=0,suma;
int a[max][max];
int b[max][max];
printf("Kolku redici i kolku koloni da imat matricite: ");
scanf("%d %d ", &n,&m);
I need to create a program that will find the total of all the elements in array. I need to use for loop and the array size is 10.The output should be like this: i used user input
I have a function where i declared the number of elements in a vector alocated dynamically which returns the vector to the main function. The problem is how can i find the number of elements in main function? I tried length = sizeof(a) / sizeof(int) which gives me the same value, the value of the first element. Here's the code:
int* functie2 (void) { int* p; int c,i; printf("number of elements: "); scanf("%d",&c);
[Code]...
I know i could first read the value of c in main and then pass it thorugh parameter, but how can i do it the other way arround?I could also send the value of c allocating one more int value to the vector, but i don't want doing so.
Im using apmatrix and im inputting values into a 4 by 4 matrix and im getting all these errors that have nothing to do with my cpp file so im guessing its apmatrixies fault. Also I put in the cpp and header file of both apmatrix and apvector into my project folder. Heres my code:
error C1189: #error : The C++ Standard Library forbids macroizing keywords. Enable warning C4005 to find the forbidden macro.c:program filesmicrosoft visual studio 11.0vcincludexkeycheck.h2421TheMatrix
4IntelliSense: identifier "EMIT" is undefinedc:Program FilesMicrosoft Visual Studio 11.0VCincludeyvals.h4911TheMatrix
How would i get the total amount of elements From the input file(The .dat file) and then store them in a variable?Here is an example to show you what i want. If a line on the .dat file looked like this
1 2 3 4 5 6 7
How would i find the total number of elements? For example the total number of elements in this line would be 7.
I would like to know the algorithm or flow for finding unequal elements in an array entered by user. I tried using for loop but didn't get the expected output
Code: #include <iostream> #include <string> using namespace std; int main() { int a[10],b[10]; //array of integer elements
I have a N queens (actually 8 queens to be specific) program that accepts the numbers in order by row. I need to get it so it accepts the numbers in order by column. At first glance I thought it was just one space different, but it turned out not to be and how to get the one space difference in there. My current code (which I'm aware isn't doing the column accepting right) is:
Code:
#include <iostream> using namespace std; int main() { int board[8]; cout << "Enter the columns containing queens, in order by column: "; for(int i = 0; i < 8; ++i) { cin >> board[i];
[Code]...
What the output should be:
Code:
Enter the rows containing queens, in order by column:
I'm not sure why Im getting a wrong Sum. of the Columns.
Write a method that returns the sum of all the elements in a specific column in a matrix using the following header:
double sumColumn(const double m[] [SIZE], int rowSize, int columnIndex)
Write a test program that reads a 3-by-4 matrix and displays the sum of each column. here is a sample run:
Enter a 3-by-4 matrix row by row: 1.5 2 3 4 5.5 6 7 8 9.5 1 3 1 Sum of the elements at column 0 is 16.5 Sum of the elements at column 1 is 9.0 Sum of the elements at column 2 is 13.0 Sum of the elements at column 3 is 13.0
#include <iostream> using namespace std; const int SIZE = 4; int rowSize=3;
Develop a function that finds the greatest difference between two consecutive elements stored in an array. Develop a 9 element array of doubles to test your code. Print to the screen which two numbers have the greatest difference as well as the value of the difference. Finally include an overloaded version of the function that will work if the array is composed of integers. Include your code used to test this function.
I am writing a program that deals with 2d arrays. The program inputs the number of rows and columns and asks for the entries. When the program run and compiles it works perfectly until it outputs then it gives me a warning.
Here is my code:
#include <iostream> #include <cstdlib> using namespace std; int main() { int row1=0,col1=0,i,j; //int a[row1][col1]; int** a= new int*[row1];
[Code]...
I am learning how to do this before I can move on so it can read a text file of numbers.
Also I am having problems with ////delete [] a[];///// I took it out because it made my code compile and run but when I add it in, it gives me an error:
matrixtesting.cpp|56|error: expected primary-expression before ']' token|
I know this expression is suppose to deallocate the array.
Here your supposed to create a program that takes in information and formats it into three columns.
I can't seem to use the float variable unitprice with decimal places here for, if I try to use %.1f and type in an input, the program seems to skip over the second scanf function, not allowing me to put input into the third scanf function as the program runs before I can.
I can use %f on its own and it works but this creates too many zeroes(and you're supposed to set the currency limit to $99999.99).
Code: #include <stdio.h> int main(void) { int itemno, month, year, day; float unitprice;
[Code]....
So the output should look like three columns. It's just the float that is the issue here....
This program does everything i want except for one major problem and one small one.
1. The program keeps taking my last entered number and counting it as max and min 2. When I go to end with 0 it adsd the enter number prompt then returns.
#include <iostream> using namespace std; int main() {
Given that today is June 9, thursday, write a program that will print the day of the week on June 9, after x years from now. Assume one year is 365 days.
In my C++ program, lets call it menu.exe, I want the user to be able to run a specific program when selecting a specific menu, let's call this program cios.exe.
As the users of my program can have the cios.exe installed in any folder location, I need a way to first locate where the cios.exe is located and then start it with ShellExecute. My problem is : How do I find the path to where cios.exe is located in anyones PC as it can be installed it any folder location.
I have written a program that will input a text file named "inarray.cpp", which contains 10 numbers each separated by a comma, into an array and display the majority on the screen. I am having trouble reading the file in the correct way. For example the numbers have to be on their own separate lines with no commas for my program to work.
ie...
I need to read in 1,2,3,4,5... but instead i am reading 1 2 3 4 . . .
I'm doing a program about finding out the solution of a sudoku puzzle. I've been thinking about how I'm going to check every box of the small 3x3's. What would be the best and most efficient way of doing that?
I am writing a program to find the square root of a number. I am using the Newton-Raphson method..Just to clarify a bit of the code.. fabs(1/(x+1)) < 0.001 is to check for relative error..
EXAMPLE: for user entry of 100 if the iteration process ends in 10.055 the answer will return as 10 which is correct. But it isn't doing that.
It compiles I then proceed to run it..prompts me "Enter a number to find the square root of: I type 100 then hit enter...
"The square root of 100 is -1077834936"
My first time writing a program from complete scratch.
And I know there is a sqrt() function...just wanted to write my own.
Code:
#include <stdio.h> #include <math.h> double mysqrt(double a); int main() { double a, result; printf("Enter a number to find the square root of: ");