0

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.

6
Contributors
6
Replies
8
Views
12 Years
Discussion Span
Last Post by Mohtadeen
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!

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);
   }
}
0

#include<stdio.h>
#include<conio.h>
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[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[j]);
}
printf("\n");
}
}

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.

0

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;
}

Edited by Nick Evan: Added CODE-tags

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.