I hope to help me solution

Apr 16, 2015 at 2:02pm
Hello I hope to help me solution


------------------------


write a program to read an integer array a[20], and print out elements Of array regular and print out Elements Of Array in Reverse. note the result print out should be (a[0]= 1,.....)

write a program to read an float array a[20], and print out elements Of array regular and print out Elements Of Array in Reverse. note the result print out should be position in array and element in it (position 0 has element 10)
Apr 16, 2015 at 2:30pm
Please note, that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.
Apr 16, 2015 at 3:24pm
Break it down into small, testable steps.

1) Open a file and make sure it opens. Compile and run.
2) Create an integer variable and read in one value from the file. Output it. Compile and run. Make sure output is correct.
3) Create an array of integers. Make sure it compiles.
4) Repeat step #2 with the first element of your array rather than another int variable.
5) Do step #4 with the first and second elements.
6) Create a loop to do the first two elements.
... etc ...
Apr 16, 2015 at 5:22pm
Thank you
I want to learn programming please help me that code so that I can understand
Apr 16, 2015 at 5:34pm
See http://www.cplusplus.com/forum/beginner/8388/ - specifically kevinchkin's example code.
Last edited on Apr 16, 2015 at 5:35pm
Apr 16, 2015 at 6:57pm
Here's an example for u to speculate...

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
27
28
29
30
31
32
33
#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

int main ()
{
    int a[20];
    float b[20];
    srand (time (0));
    
    for (int I = 0; I < 20; I++)
    {
        a [I] = rand() % 100 + 1;
        b [I] = rand() % 99 + 0.25;
    }
    
    cout << "\nYour integers:\n";
    for (int I = 0; I < 20; I++)
        cout << "a[" << I << "] = " << a[I] << endl;
    
    cout << "\n\nYour integers in reverse order:\n";
    for (int I = 19; I >= 0; I--)
    cout << a[I] << ' ';
 
    
    cout << "\n\nYour float numbers:\n";
    for (int I = 0; I < 20; I++)
        cout << "Position " << I+1 << " has element " << b[I] << endl;
    
   return 0;
}


Happy coding ...
Last edited on Apr 16, 2015 at 6:58pm
Apr 16, 2015 at 8:45pm
Thank you
Topic archived. No new replies allowed.