Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6582333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:16:01+00:00 2026-05-25T16:16:01+00:00

#include <iostream> #include <math.h> using namespace std; int main() { int arraylength; int lastbig

  • 0
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int arraylength;
    int lastbig = 0;
    int lastsmall = 0;
    int temp = 0;
    int numofgroups = 0;
    double gg = 0;
    cout<<"Enter the number of numbers you are going to enter "<<endl;
    cin>>arraylength;
    int data[arraylength];
    for(int ahmet = 0;ahmet < arraylength;ahmet++)
    {
         cout<<"Enter the num no."<<ahmet+1<<endl;
         cin>>data[ahmet];
    }
    for(int bbm = 0;bbm < arraylength;bbm++)
    {
            if(data[bbm]>lastbig)
            {        
                     lastbig = data[bbm];
            }
    }
    cout<<"Biggest "<<lastbig<<endl;
    for(int ddr = 0;ddr < arraylength;ddr++)
    {
            if(data[ddr]<lastbig && lastsmall == 0)
            {
                 lastsmall = data[ddr];
            }
            else if(data[ddr]<lastsmall)
            {
                 lastsmall = data[ddr];
            }
    }
    cout<<"smallest "<<lastsmall<<endl;
    temp = lastbig-lastsmall;
    cout<<"Enter the number of groups you want"<<endl;
    cin>>numofgroups;
    gg = (double)temp/numofgroups;
    cout<<"gg ="<<gg;
    gg = ceil(gg);
    cout<<"gg ="<<gg<<endl;
    int z = 0;
    int lastnumleft = 0;
    struct groups {
           int min;
           int max;
           int membercount;
           }group[numofgroups];
           int tmp = lastsmall;
    for(int dinghy = 0;dinghy<numofgroups;dinghy++)
    {
        if(dinghy == 0)
        {
             group[dinghy].min = tmp;
             group[dinghy].max = tmp + ((int)gg - 1);
             tmp = tmp + (int)gg;
        }
        else{
                 group[dinghy].min = tmp;
                 group[dinghy].max = tmp+((int)gg-1);
                 tmp = tmp + (int)gg;
                 }
    }
    for(int jpn = 0;jpn<numofgroups;jpn++)
    {
        for(int mtr = 0;mtr<arraylength;mtr++)
        {
            if(data[mtr]>group[jpn].min&&data[mtr]<group[jpn].max)
            {
                group[jpn].membercount++;
            }                                                                 
        }
    }
    for(int dingil = 0;dingil<numofgroups;dingil++)
    {
        if(!group[dingil].membercount){
        group[dingil].membercount = 0;
        }
    }
    for(int xyz = 0;xyz<numofgroups;xyz++)
    {
            cout<<group[xyz].min<<" - "<<group[xyz].max<<" "<<group[xyz].membercount<<endl;
    }
    cin.ignore();
    cin.get();
    return 0;
}

This program actually does the calculations needed for making a histogram member count of groups and min max of numbers but i cant group the numbers can you help me 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:16:01+00:00Added an answer on May 25, 2026 at 4:16 pm
    #include <iostream>
    #include <math.h>
    
    using namespace std;
    
    int main()
    {
        int arraylength;
        int lastbig = 0;
        int lastsmall = 0;
        int temp = 0;
        int numofgroups = 0;
        double gg = 0;
        cout<<"Enter the number of numbers you are going to enter "<<endl;
        cin>>arraylength;
        int *data = new int[arraylength];
        for(int ahmet = 0;ahmet < arraylength;ahmet++)
        {
            cout<<"Enter the num no."<<ahmet+1<<endl;
            cin>>data[ahmet];
        }
    
        for(int bbm = 0;bbm < arraylength;bbm++)
        {
            if(data[bbm]>lastbig)
            {        
                     lastbig = data[bbm];
            }
        }
        cout<<"Biggest "<<lastbig<<endl;
    
        for(int ddr = 0;ddr < arraylength;ddr++)
        {
            if(data[ddr]<lastbig && lastsmall == 0)
            {
                 lastsmall = data[ddr];
            }
            else if(data[ddr]<lastsmall)
            {
                 lastsmall = data[ddr];
            }
        }
    
        cout<<"smallest "<<lastsmall<<endl;
        temp = lastbig-lastsmall;
        cout<<"Enter the number of groups you want"<<endl;
        cin>>numofgroups;
        gg = (double)temp/numofgroups;
        cout<<"gg ="<<gg;
        gg = ceil(gg);
        cout<<"gg ="<<gg<<endl;
        int z = 0;
        int lastnumleft = 0;
    
        struct groups {
               int min;
               int max;
               int membercount;
        }*group;
    
        group = new groups[numofgroups];
        int tmp = lastsmall;
    
        for(int dinghy = 0;dinghy<numofgroups;dinghy++)
        {
            if(dinghy == 0)
            {
                group[dinghy].min = tmp;
                group[dinghy].max = tmp + ((int)gg - 1);
                tmp = tmp + (int)gg;
            }
            else
            {
                 group[dinghy].min = tmp;
                 group[dinghy].max = tmp+((int)gg-1);
                 tmp = tmp + (int)gg;
            }
        }
    
        for(int jpn = 0;jpn<numofgroups;jpn++)
        {
    
     //need to initialize as it has some garbage value and that is what it is printing out.  
    
            group[jpn].membercount = 0;
    
            for(int mtr = 0;mtr<arraylength;mtr++)
            {
    
     // note the equalities as you need to include the first and the last numbers
    
                if(data[mtr]>=group[jpn].min&&data[mtr]<=group[jpn].max)
                { 
                   group[jpn].membercount++;
                }                                                                 
            }
        }
        for(int dingil = 0;dingil<numofgroups;dingil++)
        {
            if(!group[dingil].membercount){
                group[dingil].membercount = 0;
            }
        }
    
        for(int xyz = 0;xyz<numofgroups;xyz++)
        {
            cout<<group[xyz].min<<" - "<<group[xyz].max<<" "<<group[xyz].membercount<<endl;
        }
        cin.ignore();
        cin.get();
        return 0;
    }
    

    It’ll work fine now 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include <iostream> using namespace std; int main() { double u = 0; double w
#include <iostream> #include <vector> using namespace std; int main() { vector< vector<int> > dp(50000,
#include <iostream> #include <math.h> #include <cstdlib> using namespace std; void circle(int x, int y,
my code: #include <iostream> using namespace std; int main() { int n=5; int a[n][n];
#include<iostream> using namespace std; class A { int a; int b; public: void eat()
#include <iostream> using namespace std; class Base { public: Base(){cout <<Base<<endl;} virtual ~Base(){cout<<~Base<<endl;} virtual
#include <iostream> #include <string> #include <fstream> using namespace std ; string strWord( int index
edit: I am implementing an algorithm in c++. #include<iostream> #include<math.h> #include<string> using namespace std;
Please let us consider following code: #include <iostream> using namespace std; union{ int i;
#include <iostream> using namespace std; // This first class contains a vector and a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.