C++ :: Program That Adds Matrices And Edits The Result

Jun 24, 2013

The program adds 2 matrices that are 3x3 using arrays and then stores them into another matrix (array) and then it's edited to show a diagonal line of "0" through it, btw I'm pretty new to programming....

insert
Code:
#include <iostream>
using namespace std;
int main() {
int x[3][3],y[3][3],c[3][3],i,j;
cout<<"Enter your numbers"<<endl;

[Code] .....

It works almost just fine lol, Except that the first portion of the diagonal line does not become zero and instead displays the normal addition result.....

View 5 Replies


ADVERTISEMENT

C :: Program That Adds All Digits Of Integer

May 5, 2013

Just wanted to share a program I made. It was the answer to one of the end chapter exercises in the C programming book I'm using, asking the reader to create a program that adds all the digits of an integer.

Code:

/* Program to calculate the sum of the digits in an integer */
#include <stdio.h>
int main () {
int number, right_digit, sum = 0;

[code]....

View 7 Replies View Related

C++ :: Program Which Adds Text Onto Image?

Jan 28, 2013

I want to create a program using c++ which will accept text from the user and then adds it onto a image of a form in specific locations (if that makes sense?)

and what libraries will be required?

View 1 Replies View Related

C/C++ :: Write A Program That Adds Numbers To Array

Jan 18, 2015

I am trying to write a program that adds numbers to an array. The array capacity starts out at 2, then doubles whenever the size reaches capacity. The program works perfectly fine when the array needs to be expanded. So I have narrowed down the issues into this one function (_dynArrSetCapacity)

Creates original array
DynArr* createDynArr(int cap) {
assert(cap > 0);
DynArr *r = (DynArr *)malloc(sizeof( DynArr));
assert(r != 0);
initDynArr(r,cap);

[Code]...

If i do createDynArr(10) for instance in the main, the program works perfectly, as it never gets expanded

View 3 Replies View Related

C++ :: Program That Asks User For Numbers And Adds Odd Ones Doesn't Work

Nov 12, 2014

Title is self-explanatory.

Code:
#include <iostream>
using namespace std;
int main ( ) {
float number;
float sum;
float divi;
while(number != -1) {

[Code] .....

View 5 Replies View Related

C :: Program On Multiplication Of Matrices Using Functions

Feb 26, 2013

when i am running this program no errors are being shown but as soon as i press ctr+f9 to run the program my tc++ window closes.....

Code:
#include<stdio.h>
#include<conio.h>
void multiply(int m1[50][50],int ,int,int m2[50][50],int ,int );
void main() {
int i,j,m,n,p,q,m1[50][50],m2[50][50];

[Code] ....

View 4 Replies View Related

C++ :: Program To Complete Mathematical Operations Using Matrices

Jul 10, 2014

I've been assigned to build a program which completes mathematical operations using matrices. I have to use dynamically allocated 2d arrays, and can only use * to dereference and not []. I have this code so far, but the multiply_matrix function does not work with most values. I've looked at other similar posts, which have a similar algorithm to mine, but mine does not work for some reason.

/*
*(*matrix(matrix+i)+j)
*/

#include <iostream>
//for sleep() which allows user to see messages before screen is cleared
#include <unistd.h>
using namespace std;

[Code] .....

View 1 Replies View Related

C :: Configuration Tool That Edits Certain Parameters In File

Sep 15, 2014

I want to make a configuration tool that edits certain parameters in my C. file. My problem is that I don't have a clue on how to start making this.

View 12 Replies View Related

C :: Calculate Product Of Two Matrices - Segmentation Fault In Program

Oct 29, 2014

New to C Programming, I have a problem with a little program I made that calculates the product of two matrices.

And here is the error I get:

View 4 Replies View Related

Visual C++ :: Linear Program For Matrices - System Cannot Find Path Specified

Dec 8, 2012

I have two pieces of code:

Code:
#include <cmath>;
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <iomanip>

[Code] ....

I am using the gnu glpk library to calculate a linear program for my matrices. Why I get the error message exit code 3 which apparently means "The system cannot find the path specified"?

View 12 Replies View Related

C/C++ :: Program That Adds Feet As Well As Inches And Outputs In Inches?

Apr 4, 2015

This program must take user input(from stdin) that contains both a number and then a punctuation character, either a single quote(') or double quote(") that specifies feet or inches. It keeps prompting the user to enter a length until the user enters the sentinel value of 0. For example:

Enter a measurement and unit: 1'
Enter a measurement and unit: 2"
Enter a measurement and unit: 0
Total: 14 inches

The ultimate goal of this program is to then write an Assembly language program that is structurally similar and makes use of these 4 functions:

void printStr(char *)
Arguments:
edi = address of null-terminated string to print
Returns:
Nothing

[Code] ...

So here is what I have:

int main() {
char value[50];
char *end;
int sum = 0;
long conv;
while(conv !=0)

[Code] .....

I was told to use fgets instead of scanf for for stdin to parse the number and the quotation marks. I think I converted the number from string to integer correctly with strtol, but I really do not know how to obtain the (") or (') from user input so the program knows whether to convert the number to feet or just inches. No matter what I type in, even if it's without a quotation mark, it still multiplies the number by 12. In the IF and ELSE IF statement, it should state

if(value = ''')
and...
else if(value = '"')

View 4 Replies View Related

C# :: Program Keeps Adding 1 To Result?

Oct 21, 2014

I am creating a program that allows the user to enter the number of days worked and calculates the amount of money gained by doubling the amount from the previous day, starting with .01 cents. The program works fine except for in day 3, the program adds .01 along with doubling the amount from day 2. Also I must use a List Box.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

[code]....

View 3 Replies View Related

C++ :: Multiplying Variables In Program The End Result Comes Up As Null

Jun 4, 2013

So I have this program to calculate the types of meat, I have fixed the system errors but the actual program when I run it comes up with <null>

Code:
#include <stdio.h>
#include <stdlib.h>
#define beef 1 /* multiplication factor of beef*/
#define chicken 1.5 /*factor of chicken*/

[Code] .....

View 2 Replies View Related

C++ ::  Simple Program To Prepare Result Of N Students Using Structure

Jan 17, 2014

This is the program below..can you spot the errors in it.. I am getting lots of errors...!!

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct student {
char name[10];
int rollnumber,result
float m1,m2,m3,total

[Code] .....

View 12 Replies View Related

C++ :: Program To Check If Phrase Is In File And Output The Result

Jun 6, 2013

I wrote a program that should check if phrase is in file and output the result.

File:
//////////////
Eat my shorts!
Ay Carumba!
Stupid Flanders...
////////

Why my program doesn't cout?

#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <fstream>
using namespace std;
string checkData (char Input[], char dataB [], int nMAX){

[Code] .....

View 2 Replies View Related

C :: Calculate Number Of Bits In Type - Incorrect Result In Program

Feb 15, 2014

I have this simple program below:

Code:
#include <stdio.h>
#include <limits.h>
unsigned int rightrot(unsigned int x, unsigned int n) {

/* calculate number of bits in type */

size_t s = sizeof(x) * CHAR_BIT;

[Code] ....

The result it prints is 2684356604 on my 32-bit computer. The result I expect is as follows:
0xFF94 is 0000000000000000 1111111110010100 in binary.

Shift it right by 5:
0000000000000000 0000011111111100

Then take that result in shift it right by 27 (s is 32 and p is 5, so the difference is 27):
1111111110000000 0000000000000000

Now we use bitwise or:
0000000000000000 0000011111111100 | 1111111110000000 0000000000000000 = 1111111110000000 0000011111111100

That in decimal is 4286580732. So how does it come up with 2684356604?

View 2 Replies View Related

C++ :: Getline Function Adds Another Line To Output

Aug 10, 2014

Taken from Accelerated C++ book, I modified those code to use getline() instead of std::cin >> only to find out that the output has extra line. Why is that so?

#include <iostream>
#include <string>
int main() {
std::cout << "What is your name?" << std::endl;
std::string name;

[Code] .....

What is your name?
Naruto
*****************
* *
* Hello, Naruto
*
* *
*****************

Notice one asterisk after the greeting where it should be in the same line as the greeting.

View 4 Replies View Related

Visual C++ :: Fstream Adds Extra Byte?

Feb 7, 2014

I've been having this odd problem when I write a file byte by byte, when I write a byte (dec)10 it adds a (dec)13 in front of it, and as far as I can tell, this is the only byte value that does this.

and most annoyingly, I can't read that (dec)13 with fstream, the only reason I know it's adds it, is because I used an external hex editor.

here is the code that causes the problem:

Code:
#include <fstream>
using namespace std;
int main()
{

[Code]...

but the output file reads '0D 0A' (that's in hex, '13 10' in decimal) when viewed in a hex editor. no other number (that I've tried) adds that extra 13.

View 2 Replies View Related

C++ :: Reading Integers Out Of A Text File And Only Adds Positive Ones?

Sep 26, 2014

I'm basically trying to make a simple program that reads integers out of a text file and only adds the positive ones and not the negatives.

All is well except it won't take the last integer (the last line, I presume.) I took the negative out, nothing to do with that. I put more numbers in and I made the txt file less, no answer. No matter what the last number is, the program won't read it. I've been researching online and I've been seeing that it might be an issue with "while "!inFile.eof())".

Anyway here's the program:

#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream inFile;
ofstream outFile;

[Code] .....

Here's the txt file:
5
6
-9
21
3

I'm always getting 32 for some reason.

View 2 Replies View Related

C++ :: Tree Arrays Of Same Even Lengths And Adds Values At Odd Indexes

Oct 22, 2013

I am trying a program with that takes tree arrays of same even lengths and adds the values at odd indexes and save at even index of 3rd array and voice versa........

what will be the logic i have tried it a lot of time not worked................

View 3 Replies View Related

C++ :: Program Prints Correct Result But Prints It Over And Over

Feb 9, 2015

I have a program where the user inputs a line of integers, and then all unique ones are outputted. It works fine-almost. It prints the numbers correctly, but prints them more than once and I'm not sure why.

Code: #include <iostream>
using namespace std;
int main ( ) {

[Code]......

View 10 Replies View Related

C :: How To Add Two Matrices Together

Mar 6, 2013

How do you add two matrices together ?

View 2 Replies View Related

C/C++ :: How To Multiply Two Matrices Together

Mar 7, 2014

I haven't found anything that small for Matrix multiplication i was just going to ask about how i would multiply to matrices together in c++ as easy as possible, so for example say a i have the following

[2 0 1 0 * [3 0
6 -1 0 2] 0 3
1 2
3 1]

How would i multiply these together. Here is the example

Attached image(s)

View 11 Replies View Related

C :: Cofactor Routine For N X N Matrices

Jul 26, 2013

I tried writing a cofactoring routine for n x n matrices and my code works but it shouldn't. Like, at all. But it does. Idk how and it's consistent.

Basically, my error is when assigning the sub-matrix for the cofactorization method I'm using from here :

Mathwords: Cofactor Matrix

My assignment routine should not work for the sub-matrix because of how I address the rows. under is always 0 and yet it'll assign values to the proper row. Idk how, it's magic.

Code:
#include <stdio.h>
#include <stdlib.h>
long double det(long double **x, int rank) {
/* Determinant calculator routine */
/* We initialize the resulting determinant to zero */

[Code] .....

View 11 Replies View Related

C :: Printing Matrices Without Arrays

Nov 13, 2013

Any example code for printing a square matrix without arrays?

View 7 Replies View Related

C++ :: Adding Two Matrices Using Function

Apr 17, 2014

The program below should add two matrices using function. I have problem in the third function (the summing function). It's saying that something wrong with the array! I'm new to arrays and functions.

#include<iostream>
#include<fstream>
#include<conio.h>
using namespace std;
int matrix1 ();
int matrix1 ();
int add ();

[Code] ....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved