int array[20]; //Declares an array of 20 cells in memory
int value;
std::cin >> value; //Inputted integer is assigned to value
for(int i = 0; i < 20; i++) //Loop through entire array
array[i] = i; //Access and assign a value to the array at position i
std::cout << array[3]; //Print cell value
hey... here's what I have done so far... the only error is, it doesn't print or recognize the inputted number...
#include <stdio.h>
int array_mo[5];
int i;
int main (void)
{
for ( i=0 ; i<5 ; i++ )
{
printf("Data Entry:");
scanf("%d",&array_mo[i]);
}
for(i=0;i<5;i++)
{
if(i==0)
printf("\n The First digit is:", array_mo[i]);
else if(i==1)
printf("\n The Second digit is:", array_mo[i]);
else if(i==2)
printf("\n The Third digit is:", array_mo[i]);
else if(i==3)
printf("\n The Fourth digit is:", array_mo[i]);
else
printf("\n The Fifth digit is:", array_mo[i]);
}
return 0;
}
i mean, when it says: "The first digit is:" it's blank... as well as the others...
int array_mo[5];
int i;
int main (void)
{
for (i = 0; i < 5; i++)
{
printf ("Data Entry %i: ", i);
cin >> array_mo[i];
}
for(i = 0; i < 5; i++)
{
if(i == 0)
printf("\n The First digit is: %i", array_mo[i]);
elseif(i == 1)
printf("\n The Second digit is: %i", array_mo[i]);
elseif(i == 2)
printf("\n The Third digit is: %i", array_mo[i]);
elseif(i == 3)
printf("\n The Fourth digit is: %i", array_mo[i]);
else
printf("\n The Fifth digit is: %i", array_mo[i]);
}
return 0;
}