C++ Array 1

//lh3.googleusercontent.com/-K5UKWzgJhmU/AAAAAAAAAAI/AAAAAAAACdI/CN3nwiBZsGE/s512-c/photo.jpg
November 27, 2016




anda hanya diperintahkan memasukkan panjang limit yang di inginkan, jadi misalnya anda memasukkan 2 makan anda menginput nilai sebanyak 2 kali.
selamat mencoba.


#include <iostream>

using namespace std;

main()
{
    int x[6],limit;
    char nama[6][20];
    char npm[6][20];


    cout<<"masukkan limit = ";
    cin>>limit;

    for(int a=0;a<=limit-1;a++)
    {
        cout<<"nama"<<a+1<<"=";
        cin>>nama[a];
        cout<<"npm"<<a+1<<"=";
        cin>>npm[a];
    }
    cout<<endl;

    cout<<"NO"<<"\t"<<"NAMA"<<"\t"<<"NPM"<<endl;
    for(int a=0;a<=limit-1;a++)
    {
        cout<<a+1<<"\t"<<nama[a]<<"\t"<<npm[a];
        cout<<endl;
    }


Related Post

SUBSCRIBE TO OUR NEWSLETTER

closed