This is a Cpp Program which increments all the elements in an array by one.
Here we read all the elements in the array and print them all again each time incrementing its value by one.
PROGRAM :
OUTPUT :
Here we read all the elements in the array and print them all again each time incrementing its value by one.
PROGRAM :
#include <iostream> using namespace std; int main() { int i,n; cout << "\nEnter the no of Elements: \t"; cin >> n; int arr[n]; for(i=0;i<n;i++) { cout << "\nEnter Element " << i+1 << ": \t"; cin >> arr[i]; } cout << "\nOriginal array is :\t"; for(i=0;i<n;i++) cout << arr[i] << "\t"; cout << "\n\nIncremented array is :\t"; for(i=0;i<n;i=i++){ arr[i]++; cout << arr[i] << "\t";} return 0; }
OUTPUT :
Cpp - Increment all elements in an array |
No comments:
Post a Comment