Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
 #include<stdio.h>
 #include<conio.h>

 int main()
 {
   int i,j,a[3][3];
   for(i=0;i<3;i++)
   {
     for(j=0;j<3;j++)
     {
       scanf("%d",&a[i][j]);
     }
   }
   //Array Without Transpose
   //Display
   for(i=0;i<3;i++)
   {
     for(j=0;j<3;j++)
     {
       printf("%d",a[i]);
     }
     printf("/n");
   }
   //Array After Transpose
   for(j=0;j<3;j++))																																		
   {
     printf("%d",&a[j]);
   }
   getch();
}
Posted
Updated 4-Aug-15 6:20am
v3
Comments
[no name] 4-Aug-15 10:39am    
Well you first start off by formatting your code.
Then you might as well update your code dump with an actual question or description of a problem.
ZurdoDev 4-Aug-15 10:39am    
It's been a long time since I've done C++ but I'm pretty sure if you have #include you need a file name to go along with it. You have 2 empty #includes.
[no name] 4-Aug-15 10:47am    
For starters, you need a { after int main()

A function definition is not a single statement - it always starts and ends with a curly bracket pair.
Then you have a spurious ")" in the "Array After Transpose" for loop.
Try:
C++
#include<stdio.h>
#include<conio.h>
int main()
    {
    int i,j,a[3][3];
    for(i=0;i<3;i++)
        {
        for(j=0;j<3;j++)
            {
            scanf("%d",&a[i][j]);
            }
        }
    //Array Without Transpose
    //Display
    for(i=0;i<3;i++)
        {
        for(j=0;j<3;j++)
            {
            printf("%d",a[i]);
            }
        printf("/n");
        }
    //Array After Transpose
    for(j=0;j<3;j++)
        {
        printf("%d",&a[j]);
        }
    getch();
    }


But do yourself a favour: one character variable names are easy to type, but they don;t tell you what they are used for. For a trivial example like this, it's not a major problem, but if your course starts to build on this, it can become very helpful if you use "proper names" that describe what the data is rather than "a" for example.
 
Share this answer
 
Comments
Member 11885213 4-Aug-15 13:40pm    
thanks a tonne sir. this was alot helpful to me. :D
OriginalGriff 4-Aug-15 13:59pm    
You're welcome!
Quote:
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d",a[i]);
}
printf("/n");
}
//Array After Transpose
for(j=0;j<3;j++))
{
printf("%d",&a[j]);
}

Should be instead:
C
for(i=0;i<3;i++)
   {
     for(j=0;j<3;j++)
     {
       printf("%d ",a[i][j]);
     }
     printf("/n");
   }
   //Array After Transpose
   for(i=0;i<3;i++)
   {
     for(j=0;j<3;j++)
     {
       printf("%d ",a[j][i]);
     }
     printf("/n");
   }
 
Share this answer
 
v2
Comments
Member 11885213 4-Aug-15 13:41pm    
now i understood where i was wrong.
thanks a lot for helping sir. :D means alot :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900