|
OK guys well im sorta finished with my final project but i cant get it to work CORRECTLY. The program is to have a menu and ask the user to choose betweetn add, subtract, mult and divide. when they choose whatever one it will ask them a simple question. and if they get the correct answer or wrong answer it will ask them again if they want another problem. If they choose yes then it will give em another problem but if they choose no it will go back to the menu. I cant seem when they enter no it keeps say "enter another seed vaule" I want it to go back to the menu. Well here is the code. O and if they enter anything besides Y or N i need it to say sorry that is an incorrect choice. Here is the code:
#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;
int main()
{
int choice; float num1, num2, answer, correct;
char again;
unsigned seed;
do
{
cout << "\n\t\tSimple Math Tutor Menu\n\n";
cout << "1. Addition\n";
cout << "2. Subtraction\n";
cout << "3. Division\n";
cout << "4. Multiplication\n";
cout << "5. Quit The Program\n\n";
cout << "Please enter a choice: ";
cin >> choice;
if (choice <1 || choice >5)
{
cout << "Sorry that is an incorrect choice!"<<endl;
cout="" <<="" "please="" enter="" another="" choice="" "<<endl;
="" cin="">> choice;
}
cout<<"Enter a seed value: ";
cin>>seed;
srand(seed);
num1 = 1 + rand() % 10;
num2 = 1 + rand() % 10;
switch (choice)
{
case 1 : do
{
cout << "What is the sum of "<< num1 << " and " << num2 <<endl;
cin="">> answer;
correct = num1 + num2;
if ( answer == correct)
{
cout << "Congratulations you are correct!" <<endl;
}
="" else
="" {=""
="" cout="" <<="" "sorry="" that="" was="" incorrect"="" <<endl;
="" "the="" correct="" answer="" was:="" "="" "would="" you="" like="" to="" do="" another="" problem="" (y="" n)?="" ";
="" cin="">> again;
cout<<"\nEnter another seed value: ";
cin>>seed;
num1 = 1 + rand() % 10;
num2 = 1 + rand() % 10;
}while (again=='y' || again=='Y');
if (again != 'y' || again !='Y')
cout << "Sorry That is an incorrect choice" <
|
|
|
|
|
Just an FYI,
You might want to post in the forums for C++, this is Managed C++, which is code written to run on the .NET Framework.
Eventhough, you could comile with the /clr flag and run native C++ in the CLR, but the point is post in the right forum for better respones.
R.Bischoff
Tengas un buen dia
|
|
|
|
|
Here is the section out of my program that I am having problems with.
char first[20];
ifstream
fin;
openfile(fin);
char str[20];
char* trun;
char* trun2;
char *seps = "\0";
while (!fin.eof())
{fin.getline(str, 30, '\n');
fin.ignore(1);
cout<<str<<endl;
trun = strtok (str,seps);
cout<<"---"<<trun<<"---\n";
if (!doRetrieveVertex (graph, trun))
{doInsertVertex (graph, trun);}
strcpy(first, trun);
while (trun2 != NULL)
{ cout<<trun2;
trun2 = strtok (NULL, seps); \\Here
if (!doRetrieveVertex (graph, trun2))
doInsertVertex (graph, trun2);
cout<<"Internal while";
}
cout<<"External while";
}
If I comment out where it says "trun2 = strtok (NULL, seps);" Then it will run but it stays in an infinite loop inside that Internal while loop. But if I do not then I get a core dump. Please help me if you can it is due tomorrow. Thanks
James
|
|
|
|
|
1 2 50 3 70 4 23
2 1 50 3 34 4 75
3 1 70 2 34 4 80
4 1 23 2 75 3 80
Here is some sample data that we created and also I changed where seps is to " " so that it will break it into pieces. Basically what it is doing is getting the first line and then breaking off th efirst piece and retaining that and then breaking the others off and adding those. We are making a graph if you are wondering.
|
|
|
|
|
You can use your ifstream to read consecituve ints from your file directly without messing with this C ugliness.
And you asked in the wrong forum, this has nothing to do with MC++
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
You are accessing uninitialised memory for turn2 at
cout<
|
|
|
|
|
|
please visit http://www.apptemplate.com
|
|
|
|
|
i wanna ask how to link a dictionary wid my program if i want to code a dictionary in c++ and link it wid thesaurus as we can consult a word in MS word.
nayyab
|
|
|
|
|
Hello,
I just found this article :
http://www.codeproject.com/csharp/rotateimage.asp
but the code is in C#...
is it possible to use it in a Managed C++ project ?
and what do i have to do ?
thanks
|
|
|
|
|
Of course you can, they are both .NET langauges.
If the C# contents are in project form you want to just add the C# project to your MC++ solution.
If the C# contents you want are in .dll form, then you just add a reference to the C# .dll, from your MC++ solution.
If you don't know how to add projects/references view the SDK/VS.NET relevant documentation.
p.s. if the c# logic you want is embedded in an aspx, then just create a c# library and cutnpaste from aspx to your library.
R.Bischoff
Tengas un buen dia
|
|
|
|
|
thanks for all
it's working fine now
|
|
|
|
|
Does any one know how to map a network drive using manage c++?
|
|
|
|
|
all,
i was asking if i can develop an ASP.NET Pages with
MC++ or even the new C++/CLI
i know that someone post an article about this before, but as i can remember , someone reply and he wasn't recommending that approache,
thanks
|
|
|
|
|
|
Does anyone know where I can find low level I/O tutorials such as writting to the boot sector, or directly to the disk. I'm sure i need to do this using assembly, but any tutorial in the right direction would be a nice start. How about a tutorial to get system information, ie. drives, cpu, ram, etc, preferable not through windows, again, probably through assembly.
thanks
~Guyaton
|
|
|
|
|
guyaton wrote:
preferable not through windows,
This is the wrong board for that question. This is about MC++, that runs under CLR.
Try posting in an assembler programming forum.
R.Bischoff
Tengas un buen dia
|
|
|
|
|
I have visual c++ .net 2003 and am trying to add an MSchart to a form. I've selected it from the coms list and added it to the tool box. I then go to ad it to the form and get an AxImp.exe error message telling me it can't find AxInterop.OWC10.dll even though it's in the debug directory of the project. I have the same problem if I try using any other AxtiveX component, just a different dll in the error message.
|
|
|
|
|
i do not know any C++ so please explain in little detail this prob is from some one else who is very much in need--------------------------------------------------------------------------------
QUESTION: WRITE A C PROGRAM TO IMPLEMENT NATURAL DEDUCTION FOR MAX VARIABLES POSSIBLE??
YOU CAN ALSO EXPLAIN THE APPROACH TO SOLVE THE PROBLEM
HINT:I WAS TOLD APPROACH OF GAMING TREE SUITS THE PROBLEM BUT NOT HAVING MUCH KNOWLEDGE
OF TOPIC I WAS UNABLE TO IMPLEMENT IT.
OTHER APPROACHES ARE WELCOMED.
ABOUT THE TOPIC:
Natural deduction refers to related proof systems for several different kinds of logic, intended to be similar to the way people actually reason. Unlike many other proof systems, it has many rules and few axioms. Sequents in natural deduction have only one formula on the right side.
Natural Deduction has Introduction and Elimination Rules for each logical connective such as and depicted as "^" above. Justifications for each step shown in square brackets explicitly identify which previous lines in the proof are used, as well as which inference rule.
ITS RULES ARE
A B
------ [/\,intro]
A /\ B
A /\ B
------ [/\,elim]
A
A /\ B
------ [/\,elim]
B
A
------ [\/,intro]
A \/ B
B
------ [\/,intro]
A \/ B
A \/ B A => C B => C
---------------------- [\/,elim]
C
A <=> B
------- [<=>,elim]
A => B
A <=> B
------- [<=>,elim]
B => A
A => B B => A
-------------- [<=>,intro]
A <=> B
A => ff
------- [~,intro]
~A
A ~A
----- [~,elim]
B
ff
---- [efq]
A
A A => B
--------- [mp]
B
---- [true]
tt
------- [tnd]
A \/ ~A
ankit
|
|
|
|
|
If this was not a homework question, I might tell you the right forum to post it in.
Tell your 'friend' that he's screwed. Or invite 'him' to ask 'his' teacher for help, then try to solve it, and if still stuck, then you ( ooops.... he ) can post questions in the appropriate forum here.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Mr Ankit,
hope you don't like this comment and will beat hell out of me when you found me.
this is not a Homework solving Forum, try to build a application,if any problem persist every buddy in CP is helpful enough to solve your problem.
anyway,also this is not a right forum to post this type of problem.the right forum this is Visual C++.
but last not the least , I Too don't know about natural deduction
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I want a java ssl client to communicate nessusd server which is done in c and using SSL protocol (TLSv1) by using socket programing. If u have any idea about it pls mail me.
|
|
|
|
|
Hi guys,
I have created COM .dll in C# and regersterd it.
I want to refernce this dll from my C++ .NET application.
I know how to reference COM .dll in C#, but how to do it in C++.
Please help me.
|
|
|
|
|
|
It's simple; you do it in source code with the #using directive.
Then, the dll must be in the same directory as your application.
Alternatively, (assuming it has a Type Library) you could run the COM dll through TLBIMP.EXE, creating a .NET assembly, which is even more fun.
And, I think you have to use P/Invoke to use the unmanaged types and methods in your code. This is done with the [DllImport] atribute.
Read this:
http://msdn.microsoft.com/msdnmag/issues/03/07/NET/[^]
|
|
|
|