Tuesday 10 August 2010

Matrix Output in C

user will just enter number of rows and cols and your program will generate following result.....
for eg.
for n=3 your output should be

4 9 2
3 5 7
8 1 6

each number is used only once....addition of numbers in rows,cols and on diagonals are same. So, now try this, first of all just for the odd values of n...then think about the even values of n.....first of all is there any pattern ??? then and then you can write logic for this.... Lets see how much time it will take????

void main()
{
int a=3;
int b;
b=(++a)+(++a)+(++a);
a=3;
printf("%d",(++a)+(++a)+(++a));
}

No comments:

Post a Comment