Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   C++ (https://www.askmehelpdesk.com/forumdisplay.php?f=439)
-   -   Computer programming C++. Can someone help me out (https://www.askmehelpdesk.com/showthread.php?t=589687)

  • Jul 27, 2011, 04:11 AM
    Rubentheran
    computer programming C++. Can someone help me out
    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 someone help me write the source code for me. I have done but it has error and can't compile.I'm using Dev C++.Can someone correct my error or post your solution/source code ? I really desperately need it.Thanx in advance

    this is my try...

    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    void main(void)
    {
    int arr[5][3];
    int I,j,num=7;
    clrscr();
    for(I=0;i<5;i++)
    for(j=0;j♥;j++)
    {
    if(j==0)
    arr[i][j]=i+1;
    else if(j==1)
    arr[i][j]=pow(arr[i][0],2)​;
    else
    arr[i][j]=pow(arr[i][0],3)​;
    }
    printf("printing the array....\n");
    for(I=0;i<5;i++)
    {
    for(j=0;j♥;j++)
    {
    printf("\t%d",arr[i][j]);
    }
    printf("\n");
    }
    while(num>5||num<1)
    {
    printf("\nEnter a number:(1 -5) ");
    scanf("%d",&num);
    }

    for(j=0;j♥;j++)
    printf("\t %d",arr[num-1][j]);

    getch();
    }
  • Oct 5, 2011, 05:59 AM
    iyyazahmad345
    Hi,

    I just saw the problem. Actually Clrscr() doesn't support in dev c++. It will work in turbo c. So you should use system("cls") instead of Clrscr().

  • All times are GMT -7. The time now is 11:09 PM.