Array of Strings in C++


Array of strings can be created in C++ using string keyword. Here we are discussing a C++ program by using this approach.

Algorithm

Begin
   Initialize the elements of array by string keyword. And take string as input.
   Print the array.
End.

Example Code

 Live Demo

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
   string Fruit[3] = {"Grape", "Mango", "Orange"};
   cout <<"The name of fruits are:"<< "\n";
   for (int i = 0; i < 3; i++)
      cout<< Fruit[i]<<",";
   return 0;
}

Output

The name of fruits are:
Grape, Mango, Orange

Updated on: 30-Jul-2019

776 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements