Array Input Output


//array.cpp
//To input number into an array and output after.
//-----------------------------------------------------
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
int main()
{
            const int MAXCNT = 10;  // Constant
            float arr[MAXCNT], x;  // Array, temp. variable
            int i, cnt;           // Index, quantity
            cout   << "Enter up to 10 number \n"
                   << "(Quit with a letter):" << endl;
            for(i = 0; i <MAXCNT && cin >> x; ++i)
            arr[i] = x;
            cnt = i;
            cout << "The given number:\n" << endl;
            for(i = 0; i < cnt;++i)
                  cout << setw(10) << arr[i];
            cout << endl;
            getch();
            return 0;
}                  

Comments

Popular posts from this blog

Animasi Lucu C++

Sistem Sensor dan Robotika

DDL Part II