Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Computers for Beginners (https://www.askmehelpdesk.com/forumdisplay.php?f=79)
-   -   Computer C language 5x3 matrix problem (https://www.askmehelpdesk.com/showthread.php?t=686405)

  • Jul 23, 2012, 11:45 PM
    RevolKing
    Computer C language 5x3 matrix problem
    A common use of an initialized array is to create a look up table. Write a C program
    that initializes 5x3 array in which the first element of each row contains a number, the
    second element contains its square and third element contains its cube. Prompt the user to
    enter a number within 1 to 5 and prints its square and cube.
    Can sm1 help me do this?
    I tried but still can't do it.. xC
  • Jul 31, 2012, 10:06 PM
    kerk93
    #include<stdio.h>
    int main(){
    int mat[5][3],I,j,c,s;
    for (I=0;i<5;i++){
    for(j=0;j<1;j++){
    printf("Please keyn in the Number\n");
    scanf("%d",&mat[i][j]);
    mat[i][1]=mat[i][0]*mat[i][0];
    mat[i][2]=mat[i][0]*mat[i][0]*mat[i][0];
    printf("The square of the number is %d\n",mat[i][1]);
    printf("The square of the number is %d\n",mat[i][2]);
    }
    }
    for(j=0;j<3;j++){
    for (I=0;i<5;i++){
    printf("%d\t",mat[i][j]);
    }
    printf("\n");
    }
    system("pause");
    return 0;
    }

  • All times are GMT -7. The time now is 02:50 AM.