Answer to Question #346300 in C++ for HASNAT

Question #346300

Write a program to:

a)      Initialize an array of 8 entries for serial number.

b)     Set the value of 5th serial number to 89.

c)      Set the value of 3rd serial number to the addition of first two serial numbers.

d)     Display the serial number on 2nd index

e)     Print the whole array




1
Expert's answer
2022-05-30T08:16:41-0400
#include <iostream>
using namespace std;
 
int main() {
// a) Initialize an array of 8 entries for serial number
    const int N =8;
    int arr[N] = {0, 1, 2, 3, 4, 5, 6, 7};
    int i;
    
// b) Set the value of 5th serial number to 89  
  arr[5] = 89;
 
// c) Set the value of 3rd serial number to the addition of first two serial numbers.
  arr[3]= arr[0] + arr[1];

// d) Display the serial number on 2nd index  
  cout << "arr[2] = "<< arr[2]<<endl;
   
// e) Print the whole array
    for(i=0;i<8;++i)
        cout<<arr[i]<<" ";   

    cout<<endl;
    
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS