Need a project done?

C++ Programming Developer

Search This Blog

Place a zero in each element of an array passed to it in C++

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

"Don't let anyone ever make you feel like you don't deserve what you want."