Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

how do i: Write a program to input 2 numbers, first and diff. The program will then create a one-dimensional array of 16 elements in an arithmetic sequence which is printed out.  For example, if first is 21 and diff = 5, the arithmetic sequence will be:  21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96

Computer Science
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

since you didn't specified any language so here's a program in python first = input('Enter the first number: ') diff = input('Enter the difference among the numbers: ') count=0 while count < 16: print first first = first + diff count+=1
int output[] = new output[16]; for (int i=0, i<16, i++) { output[i] = first + (diff * i); } It helps to ask a more specific question so we know what you're stumped on exactly and if you need to know something in a particular language or if psuedo code is suitable. I've answered above only what I guess would be the most trivial part of your problem, in a C#/Java-like language.
First thing to tell scherniak, please specify the language you use. So, other can help you.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Thanks a alot! How can i do the same with a 2d array (in java)?
Be more specific - what exactly do you want to do with the 2d array?
input 2 numbers, first and diff. The program will then create a two-dimensional array of 4x4 in an arithmetic sequence which is printed out. For example, if first is 21 and diff = 5, the arithmetic sequence will be: 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96
for(int i = 0;i<4;i++) { for(int j = 0; j<4; j++) { output[i][j] = (cant figure out what to put here) } }
Ah okay. output[i][j] = first + (diff * ((i * 4) + j) );
also... how can i reverse the diagonals? eg. have no idea how to approach this 96 26 31 81 41 71 66 56 61 51 46 76 36 86 91 21
Here's one way you could do it: for(int i = 0;i<4;i++) { for(int j = 0; j<4; j++) { if (i==j) { output[i][j] = first + (diff * ( ((3-i) * 4) + (3-j) ); } else { output[i][j] = first + (diff * ((i * 4) + j) ); } } }

Not the answer you are looking for?

Search for more explanations.

Ask your own question