Use an array. The program should read 25 integers from a user. Each value should be between 5- 100 (5<-value<-100). As the user inputs values store all the values which are not a duplicate. Print all the array values at the end. Use the smallest possible array.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Use an array. The program should read 25 integers from a user. Each value should be between 5-
100 (5<-value<-100). As the user inputs values store all the values which are not a duplicate.
Print all the array values at the end. Use the smallest possible array.
Transcribed Image Text:Use an array. The program should read 25 integers from a user. Each value should be between 5- 100 (5<-value<-100). As the user inputs values store all the values which are not a duplicate. Print all the array values at the end. Use the smallest possible array.
Expert Solution
Step 1 Code required for implementation

Here is the C++ code to implement the above given task

 

#include <iostream>

#include <bits/stdc++.h>

    using namespace std;
   
    int main()
    {
        int arr[25]; 
        int f = 25;
        int a, b, d;
  
   
        //Asking the user to eneter the values of the array
        cout<<"Enter the values in array : ";
        for(a=0; a<f; a++)
        {
            cin>>arr[a];
        }
   
        // Find the duplicate values in array
   
        for(a=0; a<f; a++)
        {
            for(b=a+1; b<f; b++)
            {
                //checks for dupliacte values
                if(arr[a] == arr[b])
                {
                    for(d=b; d<f; d++)
                    {
                        arr[d] = arr[d + 1];
                    }
   
                    //remove the duplicate values and decerements them
                    f--; 
   
                    b--; // do not increment b if the values are shifiting
                }
            }
        }
   
        // Printing array after deleting duplicate values
   
        cout<<"\n The values of the array at the end : ";
        for(a=0; a<f; a++)
        {
            cout<<" "<<arr[a];
        }
   
        return 0;
    }

Step 2 Screenshot of the code

Note: Since i don't have C++ compiler in my PC, I am executing the code in online C++ complier 

Computer Engineering homework question answer, step 2, image 1

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY