multiplication tutorial

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2004
Posts: 12
Reputation: popo_prince is an unknown quantity at this point 
Solved Threads: 0
popo_prince popo_prince is offline Offline
Newbie Poster

multiplication tutorial

 
0
  #1
Mar 21st, 2004
i am in a class and find C++ a challenge. i have an assignment and this is what i have so far. i need help, because i am not too analytical.


#include <cstdlib>
#include <ctime>
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int (a, b);
int (a * b ) = result;
int result;

srand( (unsigned)time( NULL ) ); //set seed to sys time
for (int i = 1; i < 2; i++)
{
cout << 1 + rand() % (10 - 1 + 1)<< endl;
cout << 1 + rand() % (10 - 1 + 1)<< endl;//how do i put side beside each other with X's sign
}
return 0;
}
cin >> c
if (int a * int b) = int c
getline int c//do i need this
cout << "" ", is the correct answer."

if c != (int a * int c)
getline int c
cout << "" ", is not the correct answer."
// loop to try again
//option to exit either way



Use rand() to produce two positive one-digit integers.
The program should then output a question using the numbers.
The student then types the answer. The program checks the student’s answer.
If it is correct, print “Very good!”, and ask another multiplication question.
If the answer is wrong, print “No. Please try again.”, and let the student
try the same question repeatedly until the student gets it right.

should i use calling or pass by value?
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 763
Reputation: Phaelax is on a distinguished road 
Solved Threads: 38
Phaelax Phaelax is offline Offline
Master Poster

Re: multiplication tutorial

 
0
  #2
Mar 22nd, 2004
my c++ is a little rusty, stupid java!
I don't know what 'calling' is, but you shouldn't need to pass anything.

  1. DO
  2. int a = some random number
  3. int b = some random number
  4. int product = a*b;
  5. int answer = 0;
  6. bool correct = false;
  7.  
  8. while (!correct)
  9. cout <<"What is "<<a<<" times "<<b<<"?";
  10. cin >> answer;
  11.  
  12. if (answer == product)
  13. correct = true;
  14. else
  15. correct = false;
  16.  
  17. if (!correct)
  18. cout<<"Please try again.";
  19. else
  20. cout<<"Good job!";
  21. LOOP


I think I even mixed BASIC in there as well. You should get the idea though. I think you're trying to make this way more difficult than it needs to be.
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 12
Reputation: popo_prince is an unknown quantity at this point 
Solved Threads: 0
popo_prince popo_prince is offline Offline
Newbie Poster

Re: multiplication tutorial

 
0
  #3
Mar 22nd, 2004
thank you. i forgot about the bolean functions. that will make it easier. it will try to build this and make it work.
thanks phaelax
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC