![]() |
In C++, arrays store data of the same type in a contiguous memory location. To reset an int array means setting all elements to zero. In this article, we will see how to reset an integer array elements to zero in C++. For Example, Input: Reset C++ int Array to ZeroIn C++, there is no direct function to reset an array but it can be done by using the Syntax of memset()memset(arr, val, n);
Here,
C++ Program to Reset an int Array to ZeroThe below program demonstrates how we can reset an int array to zero in C++ using the C++
Output
Original array: 10 20 30 40 50 Array after resetting: 0 0 0 0 0 Time Complexity: O(N), where N is the size of the array.
|
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |