i DESPERATELY NEED some help in my CASE STUDY

so I'm using Borland Turbo c++ coz that is what my whole class is using...
i can't seem to correctly create codes for a certain problem...

>>> Using C++ program, enter series of five (5) numbers . Determine the position of the 5 inputted numbers...
>EXAMPLE OUTPUT<

Data Entry: 1,3,5,7,9
The First Digit is : 1
The second Digit is: 3
The third Digit is: 5
and so on...

can someone please hep me create a code using array?
PLEASE PLEASE PLEASE...
No, not create...

But I will help you.

1
2
3
4
5
6
7
8
9
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 

That's all you'll need to know.
Last edited on
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...
The formatting functions were not used properly.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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]);
      else if(i == 1)
         printf("\n The Second digit is: %i", array_mo[i]);
      else if(i == 2)
         printf("\n The Third digit is: %i", array_mo[i]);
      else if(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;
}

And use code tags.
Last edited on
Topic archived. No new replies allowed.