954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C language problem

can anyone help me with the above problem?
i need the code in C language.
the problem is:
Store random numbers into two-dimensional array of 6 * 6 and interchange first 3 rows with last three rows
thanks you in advance.

bill13
Newbie Poster
2 posts since Feb 2005
Reputation Points: 10
Solved Threads: 0
 

Do you have any code to show me that u've tried?

a two dimensional array is int blah [][];

there's a start for you!

Gnome_101
Light Poster
27 posts since Apr 2004
Reputation Points: 10
Solved Threads: 0
 
void foo(int a[6][6])
{
   int i, swap[6];
   for (i = 0; i < 3; ++i)
   {
      memcpy(swap,     a[i],     sizeof swap);
      memcpy(a[i],     a[5 - i], sizeof swap);
      memcpy(a[5 - i], swap,     sizeof swap);
   }
}
Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

#include
#include
void main()
{
int a[6][6],temp[3];
int i,j;
clrscr();
printf("enter elements of array (6*6)\n");
for(i=0;i<6;i++)
{
for(j=0;j<6;j++)
{
scanf("%d",&a[i][j];
}
}
printf("interchanging first 3 rows elements with last 3 rows elements\n");
temp[0]=a[5][3];
temp[1]=a[5][4];
temp[2]=a[5][5];

a[5][3]=a[0][0];
a[5][4]=a[0][1];
a[5][5]=a[0][2];

a[0][0]=temp[0];
a[0][1]=temp[1];
a[0][2]=temp[2];

for(i=0;i<6;i++)
{
for(j=0;j<6;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
}

kalai2790
Newbie Poster
2 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

int i,j;

kalai2790
Newbie Poster
2 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

@kalai: click on the code tag icon in the editing window, and paste your code in between the code tags. Makes your code easy to read and study, and not look like html text and all squished to the left hand margin.

Adak
Nearly a Posting Virtuoso
1,479 posts since Jun 2008
Reputation Points: 425
Solved Threads: 185
 

Write a program that reads three nonezero float values and determines and prints if they could represent the sides the sides of a triangle.

#include <stdio.h>
main()
{
   float a, b, c;
   
   printf("Enter three nonezero valuues: );
  scanf("%d%d%d", &a, &b, &c);

   return 0;
}
Mohtadeen
Newbie Poster
1 post since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You