First and Last Element
Write a program with an array int iarray[5] = {10, 20, 30, 40, 50};. Print the first and last elements of the array using array indexing.
Expected Output
First Element: 10
Last Element: 50
Answer
#include <iostream>
int main()
{
int iarray[5] = {10, 20, 30, 40, 50};
std::cout << "First Element:" << farray[0] << "\n";
std::cout << "Last Element:" << farray[4] << "\n";
}