From f7eddf362c9916d493cc51c01fba8852142ed014 Mon Sep 17 00:00:00 2001 From: s-u-m-i-t-0 <73582715+s-u-m-i-t-0@users.noreply.github.com> Date: Wed, 28 Oct 2020 14:58:05 +0530 Subject: [PATCH] c++ array please accept --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index f6aa978..fecf696 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,25 @@ # cpp Array based solutions +include +using namespace std; + +#include +using std::setw; + +int main () { + + int n[ 10 ]; // n is an array of 10 integers + + // initialize elements of array n to 0 + for ( int i = 0; i < 10; i++ ) { + n[ i ] = i + 100; // set element at location i to i + 100 + } + cout << "Element" << setw( 13 ) << "Value" << endl; + + // output each array element's value + for ( int j = 0; j < 10; j++ ) { + cout << setw( 7 )<< j << setw( 13 ) << n[ j ] << endl; + } + + return 0; +}