Write a function & a program to test it that will place a zero in each element of an array passed to it from the calling program. Pass the size of the array as well.
#include <iostream>
using namespace std;
void zero(char [], int);
int main()
{
char a[100];
cin.getline(a,100,'\n');
zero(a,100);
cout << a << endl;
return 0;
}
void zero (char a[], int size)
{
for (int i = 0; i < size; i++)
if (a[i] != '0')
a[i] = '0';
}
No comments:
Post a Comment