C :: Creating Rows And Columns
Mar 6, 2015
how to make the it all work later...but in the mean time how can i get this to display this? Note it has to be made using as a console program. The "Description" and "Cost/ib" collums will be referenced through use of a header file. all else is done by user input and calculations.
View 2 Replies
ADVERTISEMENT
Feb 26, 2015
I'm having trouble trying to get my loop program to display multiples of 4 in rows and columns. My objective is to print multiples of 4 that are less than 100 in a 4 by 4 format.
So far when I write the code I get 4 8 12 16 20 .... 96 all on the same line.
This is what I expect the code to look like if done correctly.
4 8 12 16
20 24 28 32
36 40 44 48
52 56 60 64
68 72 76 80
84 88 92 96
This is code that I have so far.
#include <iostream>
using namespace std;
int main(){
[Code]....
View 4 Replies
View Related
Sep 2, 2014
So I made a text file which goes like this
word word word word
word word word word word word word
word word word word word
word word word word
(word is actually word I just didnt type them)
Now i figured out how to get the rows to work
#include <iostream>
#include <fstream>
#include <istream>
#include <stdio.h>
int main()
{
FILE* fp;
int countLines = 1;
int i;
[Code]...
I cant figure out column to work... Is it the same method cause im getting confused a lot!
View 12 Replies
View Related
Dec 21, 2014
How i draw such a thing in .TXT file using file handling. This output must be in columns and rows and in well arranged form.
No. Name Roll No. Physic Math Compuer Science Islamiyat Pak Studies Average Grade
1 Student Name 12345 50 60 70 76 90 81 A
2 Student Name 12345 55 52 50 80 58 55 C
3 Student Name 12345 85 66 90 88 77 75 B
4 Student Name 12345 40 70 91 45 56 85 A
5 Student Name 12345 30 80 80 55 93 45 D
View 3 Replies
View Related
Aug 2, 2014
Here's my code for adding the rows and columns. My problem is that my program displays an incorrect output.
main() {
int a[20][20],r,c,y,x,sum=0,rn,cn,cs=0,rs=0;
cout<<"Enter number of columns : ";
cin>>cn;
[Code] .....
This should be the output
Enter number of columns: 4
Enter number of rows: 3
Enter twelve numbers: 9 2 3 4 2 3 1 2 5 6 7 8
The numbers are:
9234
2312
5678
Sum of number 1 column is: 16
Sum of number 2 column is: 11
Sum of number 3 column is: 11
Sum of number 4 column is: 14
Sum of number 1 row is: 18
Sum of number 2 row is: 8
Sum of number 3 row is: 26
View 6 Replies
View Related
Apr 23, 2014
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:
// Libraries
#include "apmatrix.h"
#include <iostream>
//cout, standard output
// <<, stream insertion operator
[code]....
My errors are:
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
and a bunch are repeated
View 1 Replies
View Related
Oct 5, 2014
I am trying to sort a Report Table by which the user can enter any column or row number and output the results. And also sort by names as well. And from my code
#include "stdafx.h"
#include<iostream>
#include <string>
#include<iomanip>
using namespace std;
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
[Code] .....
I know I need to start somewhere with a void function and put in a selection sort.
View 1 Replies
View Related
Feb 4, 2015
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:
7
6
5
3
4
2
1
0
.......Q
......Q.
.....Q..
...Q....
....Q...
..Q.....
.Q......
Q.......
What it is:
Code:
Enter the columns containing queens, in order by column:
7
6
5
3
4
2
1
0
........Q
.......Q.
......Q..
....Q....
.....Q...
...Q.....
..Q......
.Q.......
View 5 Replies
View Related
Mar 12, 2013
this is what i have so far
#include <iostream>
#include <cmath>
using namespace std;
int main () {
int v;
[Code] ....
im trying to get the program to print this as an example if the user enters 5 (the rounding of the decimal is optional).
1 1.41 1.73 2 2.24
1 1.41 1.73 2
1 1.41 1.73
1 1.41
1
why its not reading my for loop for rows its only doing columns ...
View 4 Replies
View Related
Feb 7, 2015
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.
View 7 Replies
View Related
May 29, 2014
I want to select three columns from my text file i.e. Empl No, Start Date and Created Date. After selecting this, I want to insert the data into a database.
I have attached a copy of the text file.
I have the following code so far:
if (File.Exists(filename))
{
string[] lines = File.ReadAllLines(filename);
for (int y = 0; y < lines.Length; y++) {
Console.WriteLine(lines[y].ToString());
}
How do i select specific details for each employee
View 1 Replies
View Related
Jan 19, 2014
I am trying to iterate a matrix in order to exchange rows and columns element by element. Although the function that exchanges the rows has come out well, i don't seem to figure out how to do the same on columns.The columns switch for a matrix like
1 2 3
1 2 3
1 2 3
if i try to switch column 3 and 2,is:
1 3 2
1 3 2
1 2 3
Here are both of the functions:
void interchange_rows(int *p,int n,int r1,int r2){
int temp;
for(int i=0;i<n;i++){
temp=*(p+r1*n+i);
*(p+r1*n+i)=*(p+r2*n+i);
*(p+r2*n+i)=temp;
[Code] ......
View 1 Replies
View Related
Feb 19, 2014
You will write a program that uses a multidimensional array having 3 rows and 8 columns and sorts each of the rows using both a bubble sort and a selection sort.
You must declare the array inside of main. You will have a for loop containing the calls to bubbleSort and selectionSort. You need to pass into function bubbleSort and selectionSort the following: 1) each column of the multidimensional array, 2) the size of the column, and 3) a particular row number of the multidimensional array to be used for printing out the "pass" shown on the following pages.
I keep getting an error that the identifier for bubbleSort and selectionSort is not found. (Error C3861)
Also, I feel like I'm missing something in int main() to get it to sort properly.
Code:
# include <iostream>
using namespace std;
int main() {
const int SIZE1 = 3;
const int SIZE2 = 8;
int arr [SIZE1][SIZE2] = { { 105, 102, 107, 103, 106, 100, 104, 101 },
[Code] ....
View 1 Replies
View Related
Apr 16, 2013
Code: i am trying to display the information in the array as a table and add the total rows and the total colums separately
#include<stdio.h>
int main(void)
{
int row, col;
[Code].....
View 1 Replies
View Related
Dec 4, 2014
I have a code that working well and find 2D arrays . I want to sum my rows and create 1D array . but not working .
for ( int i = 0 ; i < cins ; i++ ){
for (int j=1 ; j < saft.size() ; j++) {
if (ustk[i] > saft[j] && saft[j-1] > ustk[i]){ //some calculations working well.
tyy[i][j] = ((ustk[i] - saft[j])*yy[i]);
}else if (saft[j-1] <= ustk[i] && saft [j] >= altk[i]){
[Code]...
View 1 Replies
View Related
Oct 17, 2013
I have this code it sums the rows now I need it so it would sum all the columns in the output and put it in row 8 of the outcome. How would I go about doing that?
Code:
#include Code: "stdio.h"
#include "stdafx.h"
int main(void) {
int number[8][7];
}
[code]....
View 1 Replies
View Related
Apr 8, 2015
I have this code down except I'm very confused how to make the output come out in 3 columns.
#include<iostream>
#include<fstream>
using namespace std;
int main() {
int i, j, n, flag = 0, prime_number = 0, temp;
cout << "Enter first prime numbers that will be used or -1 to end:" << endl;
[Code] ......
My output right now is:
Enter first prime numbers that will be used or -1 to end: 20
Twin Prime Number : (3,5)
Twin Prime Number : (5,7)
Twin Prime Number : (11,13)
Twin Prime Number : (17,19)
But what I want is:
1. {3;5} 2.{5,7} 3.{11,13}
4. {17,19}
View 1 Replies
View Related
Mar 21, 2015
I want to swap the value of two rows in matrix among themselves, the index of rows are user defined.
void swapRows(int matrix[M][N], int m, int n, unsigned short R1, unsigned short R2) {
for (int i=0; i<m; i++) {
for (int j=0; j<n; j++) {
//dunno what to put in here
[Code] .....
View 6 Replies
View Related
Jun 25, 2013
I'm working with arrays and I get them column by column and need to print them. I as there a way to print in columns?
For example: I produce an array of A, B and C from a loop and then need to print them in one column and the go to the next column ....
so in the end I shall have an output like this:
A E
B F
C G
D h
... ...
My arrays are too long (over 50K) so I cant just store the arrays and then print them. I need to produce each column array, print them and delete it and go to the next column.
View 1 Replies
View Related
Apr 10, 2014
I have a basic question regarding 2d vectors. The following code makes a 2d vector and fills it with a matrix of integers. The vector tempVector3 gets added as a new row to the matrix. But what if I wanted to add the tempVector3 as a new column instead. How would this be done in the simplest way?
#include<iostream>
#include<vector>
int main(){
std::vector<std::vector<int>> numbers;
std::vector<int> tempVector1;
tempVector1.push_back(2);
[Code] ....
View 5 Replies
View Related
Oct 17, 2013
I have a file that can range from 100 rows to 10000+ that is comma delimited with 8 columns. The first 32 rows (also comma delimited) will always be ignored (geographical header information). I will be wanting the data from column2 and column3.
For this I believe I would need (2) For Loops as such:
for(i=0;i<2;++i) {
getline("do something here");
}
and
for (i=0;i<3;++i) {
getline("do something here")
}
Also would using a vector or array with dynamic storage be the better way to tackle this problem? Where to start from after accessing the file.
View 19 Replies
View Related
Sep 20, 2014
I am trying to add labels to the data. I have data in a file divided by space:
1 2 3 4 5 6
7 8 9 10 11 12
I need it to look like this:
label_1: 1 2 3 4 5
label_2: 6
label_1: 7 8 9 10 11
label_2: 12
How can this be done?
View 1 Replies
View Related
Apr 8, 2015
I have this code down except I'm very confused how to make the output come out in 3 columns.
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
int i, j, n, flag = 0, prime_number = 0, temp;
cout << "Enter first prime numbers that will be used or -1 to end:" << endl;
cin >> n;
[Code]...
My output right now is:
Enter first prime numbers that will be used or -1 to end: 20
Twin Prime Number : (3,5)
Twin Prime Number : (5,7)
Twin Prime Number : (11,13)
Twin Prime Number : (17,19)
But what I want is: 1. {3;5} 2.{5,7} 3.{11,13} 4. {17,19}
View 2 Replies
View Related
May 3, 2014
Ok so I'm working with a windows form in C# and sql server database. I'm trying to do something like what is in the image below using a datagridview. My question is how do I 1) ensure only 1 checkbox is checked per row 2) do math that 'links' a checkbox column with another column, and add the totals. I understand that asp.net and web forms would be easier but we have not reached that point in the course yet. Would this be on the right track:
foreach (DataGridViewRow row in dataGridView.Rows)
{
if ((bool)(row.Cells["Checkbox"]).Value || (CheckState)row.Cells["Checkbox"].Value == CheckState.Checked)
{
// Do something
}
}
Attached image(s)
View 1 Replies
View Related
Apr 8, 2015
My output right now is:
Enter first prime numbers that will be used or -1 to end: 20
Twin Prime Number : (3,5)
Twin Prime Number : (5,7)
Twin Prime Number : (11,13)
Twin Prime Number : (17,19)
But what I want is:
1. {3;5} 2.{5,7} 3.{11,13}
4. {17,19}
else if (i - prime_number == 2)
{
cout << "{" << prime_number << ";" << i << "}" << endl << endl;
prime_number = i;
}
View 1 Replies
View Related
Aug 1, 2013
I've got two columns of data.
Code:
int a[6]={1,3,5,8,10,12};
int b[3]={3,5,9};
int c[6]={0}; if a is equal to ANY of the data in b, then c= a*2
if a isn't equal to any of the data in b, then c=a.
Here is the answer I want
Code:
c[6]={1,6,10,8,10,12}
I tried using two for loop, but it isn't correct.....
Code:
int a[6]={1,3,5,8,10,12};
int b[3]={3,5,9};
int c[6]={0};
for(int i=0;i<6;++i){
[Code] ....
View 3 Replies
View Related