Question-   use a one dimensional array to solve the following problem

Solution-

Question:- use a one dimensional array to solve the following problem. read in 20 numbers, each of which is between 10 and 100 inclusively. as each number is read, print it only if its not a duplicate of a number already read. provide for the worst case scenario in which all 20 numbers are different . use the smallest possible array to solve this problem.

 

Complete solution below-



#include<stdio.h>

#include<conio.h>

#include<stdio.h>

using namespace std;

//Main Function .. Excution starts here .

void main()

{

int arr[15],ik,j,k;

printf(" Enter  the 15 numbers between 10 to 100\n");

for(ik=0;ik<15;ik++)

{

scanf("%d",&arr[ik]);

}

for(ik=14;ik>=0;ik--)

{

for(j=(ik-1);j>=0;j--)

{

if(arr[ik]==arr[j])

{

arr[j]=NULL;

k=ik;

}

}

arr[k]=NULL;

}

for(ik=0;ik<15;ik++)

{

 

if(arr[ik]!=NULL)

 

{

 

printf("The Unique Number are  := %d \n",arr[ik]);

    }

}

getch();

}

Our Happy Testimonials

They are fast in responding to homework questions. they have the best technical writers. Thanks for helping me with my programming doubts.

studentDyana
5  stars image

I contact to disklib for homework, they help me out, despite there was some technical issue they gone through extra mile for me and provide me good quality work in first priority. 100% recommended.

studying on laptopAsif Waheed
5  stars image

Desklib's study resources are best & unique. Their study database is easy to access and easy to use.
100 % recommended.

library and studentsMike Taylor
5  stars image