Sie sind auf Seite 1von 4

FEU-IT

ITE Department Introduction to Programming Machine Problem

Name: CHAN, PAULINE C. Date Performed: 10/21/17

Course/Yr: BSIT-WMA 1ST YR. SY.16-17 Date Submitted: 10/21/17

Class Schedule: SATURDAY, 1:00PM 3:50PM Score:

MP # 6

Using arrays

1. Write a program that will accept 10 integer numbers. Display the reverse order based from the
input of the user.
#include <iostream>
using namespace std;

int main()
{
int myArray[10];
int i;
for (i = 0; i < 10; i++)
{
cout << "Value for myArray[" << i << "]: ";
cin >> myArray[i];
}
for (i = 9; i >= 0; i--)
cout << i << ": " << myArray[i] << endl;

system("pause");
return 0;
}
FEU-IT
ITE Department Introduction to Programming Machine Problem

2. Write a program that will accept an integer number from 1-10. Display the numbers in words.
Example: 1 = ONE
#include <iostream>
using namespace std;

int main()
{
string myArray[10] = { "one", "two", "three", "four", "five", "six",
"seven", "eight", "nine", "ten" };
int i;
cout << "Enter an integer number from 1-10 to display the numbers in words:
";
cin >> i, myArray[i];
cout << endl << i << " = " << myArray[i - 1] << endl;

system("pause");
return 0;
}
FEU-IT
ITE Department Introduction to Programming Machine Problem

3. Create one 2-dimensional array. The array will consist of numbers from 1 to 10. And will also
contain the number in words. Display the values of the 2-dimensional array.
Sample output:
1 One
2 Two
3 Three

#include <iostream>
using namespace std;

int main()
{
string myArray[10] = { "one", "two", "three", "four", "five", "six",
"seven", "eight", "nine", "ten" };
int i;
for (i = 1; i <= 10; i++)
cout << i << " = " << myArray[i - 1] << endl;

system("pause");
return 0;
}
FEU-IT
ITE Department Introduction to Programming Machine Problem

Das könnte Ihnen auch gefallen