Hi all,please help me out,how to find occureces and scale in this situation?And what is wrong with diplay option,once it displays,the numbers are not in the same column. Thank you kindy.

#include "stdafx.h"

using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    int list[12];
    cout<<"Enter 12 values:\n";

    for(int i =0;i<12;i++)
    {
        cin>>list[i];

    }

    int option;
    do
    {
        system("CLS");

        cout<<"\n\n\n\n\n\n\n";
        cout<<"\t\t0. Dispaly\n";
        cout<<"\t\t1. Total\n";
        cout<<"\t\t2.Average\n";
        cout<<"\t\t3. Largest\n";
        cout<<"\t\t4. Smallest\n";
        cout<<"\t\t5. Occurances\n";
        cout<<"\t\t6. Scale\n";
        cout<<"\t\t99. Exit\n";

        cout<<"\t\t\tEnter option:\n";
        cin>>option;

        int total ,average,largest=0;
         int smallest=list[0];
        switch(option)
        {
        case 0:
                system("CLS");
        cout<<"\n\n\n";
        cout<<"\t\t\Contents of list\n";
        cout<<"\t\t_________________\t";

            for(int i=0;i<12;i++)
            {
                cout<<list[i]<<endl;

            }


            cin.get();cin.get();
                 break;

        case 1:
            system("CLS");
            cout<<"\n\n\n";
            total=0;

            for(int i=0;i<12;i++)
            {
                total = total + list[i];

            }
            cout<<total<<endl;
            cin.get();cin.get();

            break;

            case 2:
            system("CLS");
            cout<<"\n\n\n";
            total=0;
            for(int i=0;i<12;i++)
            {
                total = total + list[i];


            }
            average=total/12;
            cout<<"Average is:"<<average<<endl;

            cin.get();cin.get();

            break;
                case 3:
            system("CLS");
            cout<<"\n\n\n";

            for(int i=0;i<12;i++)
            {
                if(list[i]>largest)
                {
                    largest=list[i];

                }

            }
            cout<<"The largest value is:"<<largest<<endl;
            cin.get();cin.get();

            break;

                case 4:
                    system("CLS");
            cout<<"\n\n\n";


            for(int i=0;i<12;i++)
            {
                if(list[i]<smallest)
                {
                    smallest=list[i];

                }

            }
            cout<<"The smallest number is :"<<smallest<<endl;
            cin.get();cin.get();

            break;
                case 5:
            for(int i=0;i<12;i++)
            {
                cout<<"Option 5 is not implemented.";

            }

            cin.get();cin.get();

            break;
                    case 6:
            for(int i=0;i<12;i++)
            {
                cout<<"Option 6 is not implemented.";

            }

            cin.get();cin.get();

            break;

        case 99:

            break;



        }





    }while(option !=99);

    return 0;
}

Occurrences is easy enough with a map:

#include <iostream>
#include <map>

using namespace std;

int main()
{
    map<int, int> values;
    int x;

    while (cin >> x) {
        ++values[x];
    }

    for (auto it : values) {
        cout << it.first << ": " << it.second << '\n';
    }
}

For scale you'll need to specify. Do you mean the statistical dispersion? If so, what distribution are you looking for, if any?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.