Write an interactive C program to remove the duplicates in an array from the list of "N" numbers given. I am bit confused because it's not giving me the correct output and I'm not able to debug the code. please help because program not giving the required output. gives incorrect values for case 2, code runs well if I just don't do it without switch case
#include<stdio.h>
int main()
{
int arr[10], size, i , j=0, temp, choice, k=0;
printf("Enter the size of array:\n");
scanf("%d", &size);
printf("Enter the numbers in array:\n");
for(i=0; i<size; i++)
{
scanf("%d", &arr[i]);
}
/*sorting the array numbers */
for(i=0; i<size; i++)
{
for(j=i+1; j<size; j++)
{
if(arr[i]>arr[j])
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
/*sorting completed*/
printf("---------------------------------------------------\n");
printf("---------------------------------------------------\n");
printf("\tEnter 1 print sorted array.\n");
printf("\tEnter 2 print array without duplicats.\n");
printf("---------------------------------------------------\n");
printf("---------------------------------------------------\n");
scanf("%d", &choice);
switch(choice)
{
case 1: for(i=0; i<size; i++)
{
printf("%d- %d\n", i, arr[i]);
}
break;
case 2: for(i=0; i<size; i++)
{
if(arr[k]!=arr[i+1])
{
arr[k] = arr[i];
k++;
}
}
printf("\nk=%d\n",k);
for(i=0; i<k; i++)
{
printf("%d\n", arr[k]);
}
break;
default: printf("Invalid Choice made!");
}
}
please help