Horje
how to take space separated input in c++ Code Example
how to take space separated input in c++
string z,s;
 while (true)
    {
      cin>>z;
      s+=z;
      if(cin.peek()=='\n')
      break;
    }
................................
	        OR\/
.................................
string s;
getline(cin,s);
input n space separated integers in c++
int main() {
int sum = 0;
cout << "enter number" << endl;
int i = 0;
while (true) {
    cin >> i;
    sum += i;
    //cout << i << endl;
    if (cin.peek() == '\n') {
        break;
    }
    
}

cout << "result: " << sum << endl;
return 0;
}
how to convert n space separated integers in c++
int i, n, arr[100];

scanf("%d", &n);
for (i = 0; i < n; ++i)
    scanf("%d", &arr[i]);




Cpp

Related
length of array in cpp Code Example length of array in cpp Code Example
Palindrome Checker Code Example Palindrome Checker Code Example
min heap priority queue c++ Code Example min heap priority queue c++ Code Example
check if set contains element c++ Code Example check if set contains element c++ Code Example
reverse string c++ Code Example reverse string c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7