Computer Science, asked by osran05, 10 months ago

How many ways you can set values for a string?

Answers

Answered by Parthking111
0

Answer:

array of Strings in C++ (5 Different Ways to Create)

In C/C++, a string is a 1-D array of characters and an array of string in C is a 2D array of characters. This comes quite handy in C++. There are 3 ways in which an Array of Strings in C or C++ can be created.

Using Pointers(Both C and C++): We actually create string literals by creating an array of pointers.

// C++ program to demonstrate array of strings using

// 2D character array

#include <bits/stdc++.h>

using namespace std;

int main()

{

// Initialize array of pointer

const char *colour[4] = { "Blue", "Red", "Orange", "Yellow" };

// Printing Strings stored in 2D array

for (int i = 0; i < 4; i++)

cout << colour[i] << "\n";

return 0;

}

Output:

Answered by sakshidabral27
1

Answer:

There are two ways:

1) String a="hello everyone";

2)String a;

System.out.println("Enter string");

a=sc.nextLine();

hope it helps!

plz mark brainliest!

Similar questions