C++ Online Compiler
Example: Compare the Triplets C++ Program
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// Compare the Triplets C++ Program #include <iostream> using namespace std; int main() { int s=0; cout << "Enter size of the array::\n"; cin >> s; int arr1[s], arr2[s]; int i=0; cout << "\nEnter the " << s << " elements of the first array::\n"; while (i<s) { cin >> arr1[i]; i++; } i=0; cout << "\nEnter the " << s << " elements of the second array::\n"; while (i<s) { cin >> arr2[i]; i++; } // It will compare the triplets int x1=0, x2=0, l=s; while (l--) { if (arr1[l] > arr2[l]) x1++; if (arr1[l] < arr2[l]) x2++; } // It will print the final output cout << "\nTriplate position:: " << x1 << " " << x2; return 0; }
4 12 34 56 9 6 34 78 10
Output
Clear
ADVERTISEMENTS