Please help with exam assignment

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
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
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
closed account (48T7M4Gy)
Reporting me only draws attention to the sound advice given. Thankyou for the red flag.
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
Its so cosy in here with everyone reporting each other
From the example you gave it seems like you are doing factorials, is that true?
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
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
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
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.
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?
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.
This is working on potency system or power? to the power of ...
No its not spanish, I am from central europe
Last edited on
So I have to use for loop and declare i in it with some conditions ?
Last edited on
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.
I think I will have to have some C++ epiphany rather if I want to pass this exam..
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. :)
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
Topic archived. No new replies allowed.