Array 1 Dimensi

Example 1:
#include <iostream.h>
#include <conio.h>

main()
{

int x;
int number[ ] = {1,2,3,4,5,6,7,8,9};
char character[ ] = {'H','E','L','L','O'};

clrscr();

for(x=0;x<9;++x)
{
cout <<"\nData [" <<x <<"] = "< number[x];
}
cout<<"\n";

for(x=0;x<5;++x)
{
cout <<"\nData ["<<x<<"] = "<< character[x];
}

getch();
}
Example 2:
#include <iostream.h>
#include <conio.h>

main()
{

int number[3];
char character[3];
int index;

clrscr();

//Number
cout <<"\n****************";
cout <<"\n* INPUT NUMBER *";
cout <<"\n****************";
//input
for(index=0;index<3;index++)
{
cout <<"\nData "<<index+1 <<" = ";
cin >>number[index];
}
cout <<"\n";
//output
for(index=0;index<3;index++)
{
cout <<"\nData ke-"<<index+1 <<"] = " <<number[index];
}

//Character
cout <<"\n*******************";
cout <<"\n* INPUT CHARACTER *";
cout <<"\n*******************";
//input
for(index=0;index<3;index++)
{
cout <<"\nData "<<index+1 <<" = ";
cin >>character[index];
}
cout <<"\n";
//output
for(index=0;index<3;index++)
{
cout <<"\nData "<<index+1 <"] = " <<character[index];
}

getch();
}

Posted in . Bookmark the permalink. RSS feed for this post.

Leave a Reply

Search

Support by Blogger ITN | Converted by LiteThemes.com