| | |
multiplication tutorial
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2004
Posts: 12
Reputation:
Solved Threads: 0
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?
#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?
•
•
Join Date: Mar 2004
Posts: 802
Reputation:
Solved Threads: 40
my c++ is a little rusty, stupid java!
I don't know what 'calling' is, but you shouldn't need to pass anything.
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.
I don't know what 'calling' is, but you shouldn't need to pass anything.
C++ Syntax (Toggle Plain Text)
DO int a = some random number int b = some random number int product = a*b; int answer = 0; bool correct = false; while (!correct) cout <<"What is "<<a<<" times "<<b<<"?"; cin >> answer; if (answer == product) correct = true; else correct = false; if (!correct) cout<<"Please try again."; else cout<<"Good job!"; 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.
![]() |
Similar Threads
Other Threads in the C++ Forum
- Previous Thread: Help with random number gen
- Next Thread: C++ Relcat/Attrcat catalog help
Views: 17828 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





