Thread: simple stuff

  1. #1
    Noah
    Guest

    simple stuff

    I'm trying to get this program to multiply two vectors and return the result c[2][2]. I think I have most of this correct, it looks like just my out put that is not making sense. I'm trying to get it to display something like
    2 3
    4 5


    Any help?
    Thanks

    Here's the source
    #include <stdio.h>
    #include <math.h>

    float multi(float a[2][2], float b[2][2], float c[2][2])
    {
    int i,j;
    for (i=0;i<2;i++)
    for (j=0;j<2;j++)
    c[i][j]=a[i][j]+b[i][j];
    }
    main()
    {
    int i,j;
    float *pc[2][2];
    float a[2][2]={{5,6},{8,2}}, b[2][2]={{5,7},{3,5}};
    float c[2][2];


    multi(a,b,c);
    for (i=0; i<2; i++)
    for (j=0; j<2; j++)

    printf("%f %f \n", c[2][2]);


    return 0;
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Try
    Code:
    for (i=0; i<2; i++)
        printf("%f  %f \n", c[i][0], c[i][1] );
    > float *pc[2][2];
    This is redundant
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple snmp console application.
    By csteinsv in forum C++ Programming
    Replies: 0
    Last Post: 06-01-2009, 05:03 PM
  2. Connecting to a SQL Server to do simple stuff
    By GDR92 in forum C Programming
    Replies: 4
    Last Post: 01-07-2009, 07:56 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Need help with simple data types
    By partnole in forum C++ Programming
    Replies: 1
    Last Post: 10-03-2001, 08:36 AM
  5. Linker errors with simple static library
    By Dang in forum Windows Programming
    Replies: 5
    Last Post: 09-08-2001, 09:38 AM