
- Forum
- Programming Talk
- C and C++
- c program related to arrays
c program related to arrays
This is a discussion on c program related to arrays within the C and C++ forums, part of the Programming Talk category; please help with the following c program: Write a C function (HISTOGRAM) that finds the histogram of a two-dimensional matrix ...
-
c program related to arrays
please help with the following c program:
Write a C function (HISTOGRAM) that finds the histogram of a two-dimensional matrix of integers DATA[20][20]. Then
find the histogram element, mode, that has the highest frequency count and use this value to do the following: for each
1 <= i; j <= 20
if D[i][j] < mode then replace D[i][j] by 0( D[i][j] 0)
if D[i][j] >= mode then replace D[i][j] by 0( D[i][j] 1)
Embed your function in a suitable test program, that shows the original matrix, the mode and the resulting matrix .
-
05-18-2011, 05:41 PM #2
- Join Date
- May 2011
- Answers
- 3
An array in C language is a collection of similar data-type, means an array can authority amount of a accurate data type for which it has been declared. Arrays can be created from any of the C data-types int, float, and char. So an integer array can only hold integer values and cannot hold values other than integer.
-
07-27-2011, 06:45 AM #3
- Join Date
- Jul 2011
- Answers
- 1
Program in c using 2D array.
int main
{
clrscr();
int a[2][2]; //First Array
int b[2][2]; //Second Array
int c[2][2]; //Sum Array
int d,e,f;
printf(" Fill First 2D Array 'a[][]'");
for(d=0;d<2;d++)
{
for(e=0;e<2;e++)
scanf("%d",&a[d][e]);
}
printf(" Fill Second 2D Array 'b[][]'");
for(d=0;d<2;d++)
{
for(e=0;e<2;e++)
scanf("%d",&b[d][e]);
}
for(d=0;d<2;d++)
{
for(e=0;e<2;e++)
c[d][e]=a[][]+b[d][e];
}
printf("Sum Of Arrays Is\n");
for(d=0;d<2;d++)
{
for(e=0;e<2;e++)
printf("%d %d %d",c[d][e]);
}
getche();
return 0;
}
/* Answer To Your Problem */
int main
{
clrscr();
int a[2][2]; //First Array
int b[2][2]; //Second Array
int c[2][2]; //Sum Array
int d,e,f;
printf(" Fill First 2D Array 'a[][]'");
for(d=0;d<2;d++)
{
for(e=0;e<2;e++)
scanf("%d",&a[d][e]);
}
printf(" Fill Second 2D Array 'b[][]'");
for(d=0;d<2;d++)
{
for(e=0;e<2;e++)
scanf("%d",&b[d][e]);
}
for(d=0;d<2;d++)
{
for(e=0;e<2;e++)
c[d][e]=a[d][e]+b[d][e];
}
for(d=0;d<2;d++)
{
for(e=0;e<2;e++)
a[d][e]=c[d][e];
}
printf("Sum In Array a[][] Is\n");
for(d=0;d<2;d++)
{
for(e=0;e<2;e++)
printf("%d %d %d",a[d][e]);
}
for(d=0;d<2;d++)
{
for(e=0;e<2;e++)
b[d][e]=a[d][e];
}
printf("Sum In Array b[][] Is\n");
for(d=0;d<2;d++)
{
for(e=0;e<2;e++)
printf("%d %d %d",b[d][e]);
}
getche();
return 0;
}
Last edited by admin; 07-27-2011 at 09:05 AM.
-
Sponsored Ads
«
object based programming and object oriented programming
|
c++ code for the exponential smoothing formula in forcasting.
»

Reply With Quote





