| | |
program help
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2006
Posts: 163
Reputation:
Solved Threads: 2
um i just starded macking a simple program and i want the user to input a number when it says enter a number then i want it to say that number *3 is, enter then the answer will appear here is what i have and i dont know whats wrong with it
#include <stdlib.h>
using namespace std;
int main(int argc, char **argv)
{
int k,n;
n = k*3;
cout << "type a number";
cout << k << "times three is";
cin>>n;
system ("pause"); /* execute M$-DOS' pause command */
return 0;
)
#include <stdlib.h>
using namespace std;
int main(int argc, char **argv)
{
int k,n;
n = k*3;
cout << "type a number";
cout << k << "times three is";
cin>>n;
system ("pause"); /* execute M$-DOS' pause command */
return 0;
)
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
•
•
•
•
Originally Posted by grunge man
um i just starded macking a simple program and i want the user to input a number when it says enter a number then i want it to say that number *3 is, enter then the answer will appear here is what i have and i dont know whats wrong with it
#include <stdlib.h>
using namespace std;
int main(int argc, char **argv)
{
int k,n;
n = k*3;
cout << "type a number";
cout << k << "times three is";
cin>>n;
system ("pause"); /* execute M$-DOS' pause command */
return 0;
)
set up variables properly:
int k = 0;
int n = 0;
prompt the user:
cout << "type a freaking number --> ";
get the input
cin >> k;
multiply by three:
n = k*3;
then display the new result:
cout << endl << n;
•
•
Join Date: Mar 2006
Posts: 163
Reputation:
Solved Threads: 2
also i changed it now and there is still errors here is the program curently and its errors i cant figure out how to correct the errors ok here bye the way i have a dev c++ compiler
#include <stdlib.h>
using namespace std;
int main(int argc, char **argv)
{
int k,n;
k = 0;
n = 0;
cout<<"type a number";
cin>>k;
n=k*3;
cout<<endl<<n;
system ("pause"); /* execute M$-DOS' pause command */
return 0;
)
C:\Dev-Cpp\Untitled2.cpp In function `int main(int, char**)':
11 C:\Dev-Cpp\Untitled2.cpp `cout' undeclared (first use this function)
12 C:\Dev-Cpp\Untitled2.cpp `cin' undeclared (first use this function)
14 C:\Dev-Cpp\Untitled2.cpp `endl' undeclared (first use this function)
18 C:\Dev-Cpp\Untitled2.cpp expected primary-expression before ')' token
18 C:\Dev-Cpp\Untitled2.cpp expected `;' before ')' token
18 C:\Dev-Cpp\Untitled2.cpp expected `}' at end of input
C:\Dev-Cpp\Makefile.win [Build Error] [Untitled2.o] Error 1
#include <stdlib.h>
using namespace std;
int main(int argc, char **argv)
{
int k,n;
k = 0;
n = 0;
cout<<"type a number";
cin>>k;
n=k*3;
cout<<endl<<n;
system ("pause"); /* execute M$-DOS' pause command */
return 0;
)
C:\Dev-Cpp\Untitled2.cpp In function `int main(int, char**)':
11 C:\Dev-Cpp\Untitled2.cpp `cout' undeclared (first use this function)
12 C:\Dev-Cpp\Untitled2.cpp `cin' undeclared (first use this function)
14 C:\Dev-Cpp\Untitled2.cpp `endl' undeclared (first use this function)
18 C:\Dev-Cpp\Untitled2.cpp expected primary-expression before ')' token
18 C:\Dev-Cpp\Untitled2.cpp expected `;' before ')' token
18 C:\Dev-Cpp\Untitled2.cpp expected `}' at end of input
C:\Dev-Cpp\Makefile.win [Build Error] [Untitled2.o] Error 1
•
•
•
•
Originally Posted by server_crash
You haven't even got the user input.
set up variables properly:
int k = 0;
int n = 0;
prompt the user: <<syntax error
cout << "type a freaking number --> "; <<politeness error
get the input <<syntax error
cin >> k;
multiply by three: <<syntax error
n = k*3;
then display the new result: <<syntax error
cout << endl << n;
*Voted best profile in the world*
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
•
•
•
•
Originally Posted by iamthwee
I don't think that compiles without errors?
•
•
•
•
Originally Posted by server_crash
Wow. Your stupidity becomes more prevalent with each post. I know you're still pissed about me letting you know how stupid your other post is, but that's not reason to carry over into someone elses thread. If you have a problem, then PM me and stop your fagish whining.
*Voted best profile in the world*
Try this?
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main() { int k,n; k = 0; n = 0; cout<<"type a number"; cin>>k; n=k*3; cout<<endl<<n; system ("pause"); /* execute M$-DOS' pause command */ return 0; }
*Voted best profile in the world*
Okay children, stop the name calling!
grunge man, you forgot to iclude <iostream>
grunge man, you forgot to iclude <iostream>
C++ Syntax (Toggle Plain Text)
#include <cstdlib> // system() #include <iostream> // cout, cin, endl using namespace std; int main() { int k, n; cout<<"type a number: "; cin >> k; n = k*3; cout << "\ntimes three = " << n << endl; system("PAUSE"); return EXIT_SUCCESS; // optional with C++ }
drink her pretty
![]() |
Similar Threads
- Playing .Wav/MIDI files in a Visual Basic Program (Visual Basic 4 / 5 / 6)
- What's the HARDEST program you've written? (Computer Science)
- Cool little Program to disable startup programs (Windows NT / 2000 / XP)
- Program is shutting down right after program is executed (C++)
- 3d Program (Game Development)
Other Threads in the C++ Forum
- Previous Thread: images?
- Next Thread: Looking up and displaying values in linked lists
Views: 2037 | Replies: 16
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api array arrays based beginner binary bmp c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library lines linker list loop looping loops map math matrix memory newbie news number output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort spoonfeeding string strings struct temperature template templates text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






