Please help with exam assignment

Sep 5, 2016 at 3:44am
This is the assignment:
Create a program to calculate the product of the last digit integers from 100 to n , where the program first asks for integer .
Program should look like :
Enter number: 5
Entered number multiple of the last digit 100 to 105 is 120

Can anyone show me some way to solve this please I've looked for solutions but nothing
Sep 5, 2016 at 3:48am
closed account (48T7M4Gy)
Can anyone show me some way to solve this please I've looked for solutions but nothing
Hard work, study, reading your notes, revision are always good places to start. Follow that up with an attempt you can show us, even if it is just in general terms of how you plan to tackle it, is often a good move here too.

General questions like 'show me how to do it' are not the best move here because you probably need to talk to your teacher or tutor because they like to know if they have missed something or are being unreasonable.

By all means come up with something we can 'poke a stick at' and you'll be overwhelmed almost with the eagerness people here have to help a genuine trier.
Last edited on Sep 5, 2016 at 3:54am
Sep 5, 2016 at 3:48am
You should start doing it and when you're stuck you should come ask. This way you learn much faster. Try writing some of the code, we will be here if you have any questions
Last edited on Sep 5, 2016 at 3:56am
Sep 5, 2016 at 3:55am
closed account (48T7M4Gy)
Reporting me only draws attention to the sound advice given. Thankyou for the red flag.
Sep 5, 2016 at 3:59am
I reported nothing.

This is the code I have so far :
#include <iostream>

using namespace std;
int main()
{
int n , x1=100,x2, what;

cout <<"Enter number: " <<endl;
cin >> n ;

x2=x1+n;
cout<< " Entered number multple of the last digit " << x1 << " to " << x2 << " is " <<what<< endl;

return 0 ;

}

Cant figure out how does what part work exactly
Last edited on Sep 5, 2016 at 4:00am
Sep 5, 2016 at 4:01am
Its so cosy in here with everyone reporting each other
Sep 5, 2016 at 4:04am
From the example you gave it seems like you are doing factorials, is that true?
Sep 5, 2016 at 4:05am
Well I guess so , I think I have to devide or module that cin input , but not sure how to get 120 result
Last edited on Sep 5, 2016 at 4:08am
Sep 5, 2016 at 4:08am
But what happens when the entered number is 10? Will the result be zero as you are multiplying by the last interger which is 0? If so all the numbers after that will also be zero? Or am I being hard on the head? lol
Sep 5, 2016 at 4:11am
closed account (48T7M4Gy)
I know who the reporter was so I chose my words very carefully.

Moving on.

In the example, 'multiple' = 1 x 2 x 3 x 4 x 5 = 120. So you need something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

using namespace std;

int main()
{
   int n = 0;
   int x1 = 100;
   int x2 = 0;

   cout <<"Enter number: " <<endl;
   cin >> n ;

   x2 = x1 + n;
   //cout << "Entered number multiple of the last digit " << x1 << " to " << x2 << " is " <<what<< endl;

   // declare int product and set to 1
   // for all numbers i between x1 and x1 + n
   // get the last digit of i
   // multiply that last digit by product
   // keep going in loop until finished

   return 0 ;
}
Last edited on Sep 5, 2016 at 4:14am
Sep 5, 2016 at 4:13am
closed account (48T7M4Gy)
Also, as a hint use C++ modular arithmetic to get the last digit, and remeber if the last digit is zero the product will be zero regardless of how many factors are involved.
Sep 5, 2016 at 4:17am
I think that the google translator messed the question, maybe i know your language, is it spanish or portuguese? If so you can put the question in that language and I can help you better.

Also kemort, would you mind telling who the reporter is or what did I do wrong?
Sep 5, 2016 at 4:20am
closed account (48T7M4Gy)
The product of two numbers 'a' and 'b' is 'a x b', eg if a = 3 and b = 7, the product of a and b is 7 x 3 = 21

Using the example, the 5 numbers starting at x1 = 101 are 101, 102, 103, 104 and 105. The corresponding last digits extracted from those are 1, 2, 3, 4, and 5. The rest follows.
Sep 5, 2016 at 4:26am
This is working on potency system or power? to the power of ...
No its not spanish, I am from central europe
Last edited on Sep 5, 2016 at 4:28am
Sep 5, 2016 at 4:28am
So I have to use for loop and declare i in it with some conditions ?
Last edited on Sep 5, 2016 at 4:32am
Sep 5, 2016 at 4:32am
No its not to the power of its factorial, its represented with a number and this ! after the number. For example 5 factorial would be 5!, and also is the same with 1*2*3*4*5.
Sep 5, 2016 at 4:51am
I think I will have to have some C++ epiphany rather if I want to pass this exam..
Sep 5, 2016 at 5:39am
closed account (48T7M4Gy)
Yes, a for loop and i int and some conditions are an excellent idea.

First just get the value for n and print out the numbers in the range of values using you new loop. Leave the last digit calculation out until you get that part right.

Also, only concern yourself with multiplying the numbers, factorials and powers have nothing to do with this problem. :)
Sep 5, 2016 at 12:28pm
Leave this assignment for experts http://acewriters.org/ - just make sure your questions are to the point, and not of the "this is my homework, please solve it for me" nature so common in homework questions. Experienced programmers don't have much patience for the latter, because it shows the question's author isn't really trying to learn anything.

Try showing what have you done so far with your assignment and explaining which specific parts of it you have problems with or can't understand.
Last edited on Sep 6, 2016 at 6:36am
Topic archived. No new replies allowed.