Question: C How to program (8th edition) 6.15 (Duplicate Elimination) Use a one-dimension array to solve the following problem. Read in 20 numbers, each of which

C How to program (8th edition)

6.15 (Duplicate Elimination)

Use a one-dimension array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, print it only if it's not a duplicate of a number already read. Provide for the "worst case" in which all 20 numbers are diffrent. Use the smallest possible array to solce this problem.

help debugging and correcting code to compile and display non pduplicate values

#include

#define SIZE 20

int main()

{

int arrayList[SIZE] = { 0 };

int i;

int tDupli;

int count = 0;

int rDupli;

int value;

printf_s("Enter 20 numbers between 10 and 100(Inclusive): ");

for(i=0; i <= SIZE - 1; i++)

{

rDupli = 0;

scanf_s("%d", &value);

while (value < 10 || value >100)

{

puts(" ");

printf_s("Invalid Value. Re-Enter Value: ");

scanf_s("%d", &value);

}

for(tDupli = 0; tDupli < count; tDupli++)

{

if (value == arrayList[tDupli])

{

rDupli += 1;

break;

}

}

if (!rDupli)

{

arrayList[count++] = value;

}

}

puts(" ");

printf_s("Values that do not repeat are: ");

puts(" ");

for(i = 0; i < SIZE && arrayList[i] != 0; i++)

{

printf_s("%d ", arrayList[i]);

}

puts(" ");

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!