Write a program to perform the following functions.
Declare a 5*4 int array in the main ().
Pass it to another function that will initialize all of its elements to zero,
without using the subscript operator [ ].
*/
#include <iostream>
using namespace std;
void zero( char [][4], int, int);
int main()
{
char a[5][4];
zero(a,5,4);
//Printing array
for (int r=0; r<5; r++)
{
for (int c=0; c<4; c++)
cout << a[r][c];
cout << endl;
}
return 0;
}
void zero (char a[][4], int r, int c)
{
for (int j = 0; j<4; j++)
for (int i = 0; i<5; i++)
{
*(*(a+i)+j) = '0';
}
}
No comments:
Post a Comment