Thread: Matrix

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    13

    Unhappy Matrix

    Hi can anyone help i have to write a program in c that reads in a 4x4 matrix A checks if all the entries are positive and if each row is less than one then get the program to print out the value of b=I+A+A^2....A^999

    I am only new to this please please help someone i really need the help
    Last edited by Bubbles293; 02-07-2010 at 08:34 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Is this supposed to be written in C or C++? What have you tried?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    13

    Matrix

    In C i am using dev C++ so far i have read in the matrx A
    Code:
    #include<stdio.h>
    #define DIM 4
    int main(void){
    double A[DIM][DIM];
    int i, j;
    
    /*read in the matrix*/
    for(i=0; i<DIM; i++){
    for(j=0; j<DIM; j++){
    if (scanf("%lf", &A[i][j])!=1){
    printf("couldn.t read element %d, %d\n" i, j);
    return 1;
    }
    }
    }
    i am not really sure where to go after that

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    * Moved to C Programming forum *

    Quote Originally Posted by Bubbles293
    i am not really sure where to go after that
    For starters, indent your code properly.

    After that, do the part that performs the required checking of the matrix. It would be similiar to what you did to read in the values for the matrix's entries (and in fact you could combine these steps).
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C - access violation
    By uber in forum C Programming
    Replies: 2
    Last Post: 07-08-2009, 01:30 PM
  2. Matrix Help
    By HelpmeMark in forum C++ Programming
    Replies: 27
    Last Post: 03-06-2008, 05:57 PM
  3. Matrix and vector operations on computers
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 05-11-2004, 06:36 AM
  4. Matrix Reloaded Questions (SPOILERS_
    By Xei in forum A Brief History of Cprogramming.com
    Replies: 73
    Last Post: 10-19-2003, 02:21 PM