I would love for this to be done in c language I would love

I would love for this to be done in c++ language.

I would love to be able to see this working so i could have a clearer understanding of c++.

Complete your code for this task within the function task5().

1. You need to implement code to output the following line to the screen:

–- Task 5 –-

2.In the main function display the following message:

Enter a list of space separated numbers, terminated with -1:

3. Add statements to the main function so that the program reads in a whole number integer from the keyboard and stores it in a variable named input.

4. Encapsulate the capture of the number within a loop that will continue processing numbers until it finds -1. Once the loop terminates display the following information:

The largest number is input The occurrence count of the largest number is input where input is the last value assigned to input.

5. Create two variables max and count. max stores the current max number and count stores its number of occurrences. Initially, assign the first number captured to max and 1 to count. Compare each subsequent number with max. If the number is greater than max, assign it to max and reset count to 1. If the number is equal to max, increment count by 1. Use the values stored in max and count to correctly complete the output of your program.

(Here are sample runs of the program below )

Sample 1 :

Task 5

Enter al ist of space separated numbers , terminated with 1: 3 5 2 5 5 5 1

The largest number i s 5

The occurrence count of the largest number i s 4

Sample 2 :

Task 5

Enter alist of space separated numbers , terminated with 1:

3654245455 1

The largest number is 6

The occurrence count of the largest number is 1

Solution

#include <iostream>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main()
{
   int * array= NULL;
   int * nonspace=NULL;
   int size,i=0,j=0;
   static int us=0;
   cout<<\"please enter the number of integer you wants to enter\ \";
   cin>>size;
   size=2*size;
   array= new int[size+1];
   int temp;
   cout<<\"please enter the element of array please seprate the number using space \ \"<<endl;
   for(i=0;i<size+1;i++)
   {
       cin>>temp;
       if(temp==-1)
       {
           *(array+i)=temp;
           us;
           cout<<\"You Ensert -1 now you can\'t entered the number more \ \"<<endl;  
       break;
       }
       else
       {
           *(array+i)=temp;
           us++;
   }      
   }
   //cout<<endl<<us<<endl;
   i=0;
   int t=0;
   int count=1;
   for(int i=0;i<us;i++)
{
if(*(array+i)>t)
{
t=array[i];
count=1;
   }
   else if(t==*(array+i))
   {
       count=count+1;
   }  
}
   cout<<endl<<\"the maximum element is :\"<<t<<\"\\t\"<<\"the occurence of maximum element is \"<<count<<endl;
  
   cout<<\"the Array Elements Are\"<<endl;
   for(i=0;i<us;i++)
   {
       cout<<*(array+i);
   }
return 0;
}

I would love for this to be done in c++ language. I would love to be able to see this working so i could have a clearer understanding of c++. Complete your code
I would love for this to be done in c++ language. I would love to be able to see this working so i could have a clearer understanding of c++. Complete your code

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site