C Online Compiler
Example: Compare the Triplets in C Programming
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Compare the Triplets in C Programming #include <stdio.h> int main() { int s=0; printf("Enter size of the array::\n"); scanf("%d", &s); int arr1[s], arr2[s]; int i=0; printf("\nEnter the %d elements of the first array::\n", s); while (i<s) { scanf("%d", &arr1[i]); i++; } i=0; printf("\nEnter the %d elements of the second array::\n", s); while (i<s) { scanf("%d", &arr2[i]); i++; } // It will compare the triplates 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 printf("\nTriplate position:: %d %d", x1, x2); return 0; }
3 17 28 30 99 16 8
Output
Clear
ADVERTISEMENTS