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