Activity Stream
48,167 MEMBERS
61036 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 4 of 4
  1.     
    #1
    Member
    Website's:
    android-apk.in latestplaza.com

    Wink C program help

    Matrix Addition

    Problem Statement:
    Develop a program to add two matrices. Program should accept input matrices to be added via files.
    Absolute path of these file should be accepted through a command line argument.
    The file format of the input files is described below. Your program should parse the input files and construct the input matrices.
    In case of a bad input, program should output appropriate message as mentioned in output specification below.
    Once the matrices are formed, apply appropriate logic to see if addition is possible.
    If addition is possible, add the input matrices and output the result in format specified below.
    Code: 
    Information:
    Matrix addition is the operation of adding two matrices that in turn produces resultant third matrix which is a sum of the two input matrices.
    Code: 
    File Format
    Each row is delimited by new line character
    Columns within each row are space delimited
    e.g.
    A 3x3 matrix will be represented in the file as :
    1 2 3
    4 5 6
    7 8 9
    Code: 
    Input Format
    Line 1    Absolute path of the first input file
    Line 2    Absolute path of the second input file
    Code: 
    Output
    1.    Input matrices which are inserted
    2.    Resultant matrix or appropriate error message
    Sample Output:

    Code: 
    matrix1.txt :
    3 3 1
    5 9 2
    6 4 2
    
    matrix2.txt:
    2 1 1
    1 5 5
    3 8 9
    Input Matrix 1 :
    3 3 1
    5 9 2
    6 4 2
    Input Matrix 2 :
    2 1 1
    1 5 5
    3 8 9
    Valid Matrix dimensions for addition.
    5 4 2
    6 14 7
    9 12 11
    Code: 
    matrix1.txt :
    7 3 1
    7 2 5
    2 6 4
    
    matrix2.txt :
    2 1
    1 5
    3 8    
    Input Matrix 1 :
    7 3 1
    7 2 5
    2 6 4
    Input Matrix 2 :
    2 1
    1 5
    3 8
    Invalid Matrix dimensions for addition.
    Cannot add matrix of dimensions 3 with 3x2
    Code: 
    matrix1.txt :
    9 4 8
    2 3 7
    9 2 1
    
    matrix2.txt :
    1 2 3
    4 5 6
    1 ? 3
    INVALID INPUT
    Code: 
    matrix1.txt:
    a b c
    d e f
    g h i
    
    matrix2.txt:
    2 8 5
    8 5 2
    0 2 4    
    INVALID INPUT
    How to code this Please Help
    Thanx in advance
    mak23101991 Reviewed by mak23101991 on . C program help Matrix Addition Problem Statement: Develop a program to add two matrices. Program should accept input matrices to be added via files. Absolute path of these file should be accepted through a command line argument. The file format of the input files is described below. Your program should parse the input files and construct the input matrices. In case of a bad input, program should output appropriate message as mentioned in output specification below. Once the matrices are formed, apply Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Where's the part you've already coded ?

  4.     
    #3
    Member
    Website's:
    android-apk.in latestplaza.com
    #include <stdio.h>
    #include <stdlib.h>
    #include<string.h>
    int main(int argc, char *argv[])
    {
    int i,j,c,r,r1,row,row1;
    int st[9],st1[9],st2[9];
    FILE *f = fopen(argv[1], "r");
    FILE *f1=fopen(argv[2],"r");
    r=9;
    r1=9;
    /*initialize array*/
    for(i=0;i<r;i++)
    {
    st[i]='\0';
    }
    for(i=0;i<r1;i++)
    {
    st1[i]='\0';
    }
    /*storing values in array from file*/
    for(i=0;i<r;i++)
    {
    fscanf(f,"%d",&st[i]);
    }
    for(i=0;i<r1;i++)
    {
    fscanf(f1,"%d",&st1[i]);
    }
    row=(sizeof(st)/sizeof(int));
    row1=(sizeof(st1)/sizeof(int));
    for(i=0;i<r;i++)
    {
    if((st[i]=='\0')||(st1[i]=='\0'))
    {
    printf("Invalid matrix dimension\n");
    exit(0);
    }
    }
    /*printing input matrix*/
    printf("Input Matrix1:\n");
    for(i=0;i<r;i++)
    {
    printf("%d\t", st[i]);
    }
    printf("\n");
    printf("Input Matrix2:\n");
    for(i=0;i<r1;i++)
    {

    printf("%d\t", st1[i]);
    }
    printf("\n");
    /*printing output matrix*/
    printf("Output Matrix:\n");
    for(i=0;i<r;i++)
    {
    st2[i]=st[i]+st1[i];
    printf("%d\t", st2[i]);
    }
    printf("\n");
    fclose(f);
    fclose(f1);
    return 0;
    }

  5.     
    #4
    You can call me G
    Just use a two dimensional array 3x3 in size and then proceed



    My Langotiya Yaars (Chaddi buddies): JmZ, humour, Chutad, Esotorisk, l0calhost, Daniel, Mind Freak?, TLK, Amz

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. need this program (pay)
    By Elleboy in forum Web Development Area
    Replies: 20
    Last Post: 12th Jun 2011, 12:20 PM
  2. Replies: 0
    Last Post: 9th Feb 2011, 04:29 PM
  3. best gfx program
    By Warez Junky in forum Graphics Area
    Replies: 7
    Last Post: 26th Nov 2010, 06:44 AM
  4. Need some invoice program source code/or program only
    By Nikolasr in forum Webmaster Discussion
    Replies: 2
    Last Post: 1st Feb 2010, 10:55 AM

Tags for this Thread

BE SOCIAL