944,117 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 6041
  • C RSS
Feb 26th, 2005
0

C language problem

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bill13 is offline Offline
2 posts
since Feb 2005
Feb 26th, 2005
0

Re: C language problem

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!
Reputation Points: 10
Solved Threads: 0
Light Poster
Gnome_101 is offline Offline
27 posts
since Apr 2004
Feb 26th, 2005
0

Re: C language problem

  1. void foo(int a[6][6])
  2. {
  3. int i, swap[6];
  4. for (i = 0; i < 3; ++i)
  5. {
  6. memcpy(swap, a[i], sizeof swap);
  7. memcpy(a[i], a[5 - i], sizeof swap);
  8. memcpy(a[5 - i], swap, sizeof swap);
  9. }
  10. }
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Oct 11th, 2010
0
Re: C language problem
#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[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");
}
}
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kalai2790 is offline Offline
2 posts
since Oct 2010
Oct 11th, 2010
0
Re: C language problem
int i,j;
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kalai2790 is offline Offline
2 posts
since Oct 2010
Oct 11th, 2010
0
Re: C language problem
@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.
Reputation Points: 416
Solved Threads: 181
Nearly a Posting Virtuoso
Adak is offline Offline
1,463 posts
since Jun 2008
Dec 21st, 2010
0
Re: C language problem
Write a program that reads three nonezero float values and determines and prints if they could represent the sides the sides of a triangle.

  1. #include <stdio.h>
  2. main()
  3. {
  4. float a, b, c;
  5.  
  6. printf("Enter three nonezero valuues: );
  7. scanf("%d%d%d", &a, &b, &c);
  8.  
  9. return 0;
  10. }
  11.  
Last edited by Nick Evan; Dec 21st, 2010 at 6:46 am. Reason: Added CODE-tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Mohtadeen is offline Offline
1 posts
since Dec 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Coordinator in C (Linux)
Next Thread in C Forum Timeline: Write to a file line after line.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC