Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m doing a project that allows the user to enter 20 numbers between 10 and 100

ID: 3534563 • Letter: I

Question

I'm doing a project that allows the user to enter 20 numbers between 10 and 100 using a single-subscripted array. The program reads in the 20 numbers and prints it only if it's not a duplicate of a number already used.

The output has to appear in the following format;


Enter 20 integers between 10 and 100:

22 56 78 94 22 94 38 10 11 12 22 12 13 14 15 16 17 88 88 77

The nonduplicates values are;

22 56 78 94 38 10 11 12 13 14 15 16 17 88 77


I already did the code but it keeps printing it out in a different order than what the output needs to be.

here is my code.


#include<stdio.h>

#define SIZE 15

int main()

{

int arry[ SIZE ];

//int arry[ SIZE ];

int i, pass, hold;

//printf("Enter 20 numbers: ");

//scanf_s("%d ", &arry);

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

{

scanf("%d", &arry[i]);


}

/* Bubble Sort */

for( pass = 1; pass < SIZE; pass++ )

{

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

{

if( arry[ i ] > arry[ i + 1 ] )

{

hold = arry[ i ];

arry[ i ] = arry[ i + 1 ];

arry[ i + 1 ] = hold;

}

}

}

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

{

if( arry[ i ] == arry[ i + 1 ] )

{

continue;

}

else

{

printf("%d ", arry[ i ] );

}

}

printf( " " );

}

Explanation / Answer

//try this instead

http://ideone.com/VbpGax

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote