fork download
  1. #include <stdio.h>
  2. int main() {
  3. float arr[10];
  4. int i, j;
  5. int hasDuplicates = 0;
  6.  
  7. printf("Enter 10 float values:\n");
  8. for (i = 0; i < 10; i++) {
  9. printf("Value %d: ", i + 1);
  10. scanf("%f", &arr[i]);
  11. }
  12.  
  13. for (i = 0; i < 9; i++) {
  14. for (j = i + 1; j < 10; j++) {
  15. if (arr[i] == arr[j]) {
  16. hasDuplicates = 1;
  17. break;
  18. }
  19. }
  20. if (hasDuplicates) {
  21. break;
  22. }
  23. }
  24.  
  25. if (hasDuplicates) {
  26. printf("There are duplicate values in the array.\n");
  27. } else {
  28. printf("There are no duplicate values in the array.\n");
  29. }
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0s 5300KB
stdin
 
stdout
Enter 10 float values:
Value 1: Value 2: Value 3: Value 4: Value 5: Value 6: Value 7: Value 8: Value 9: Value 10: There are duplicate values in the array.