program help

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

Join Date: Mar 2006
Posts: 163
Reputation: grunge man is an unknown quantity at this point 
Solved Threads: 2
grunge man grunge man is offline Offline
Junior Poster

program help

 
0
  #1
Mar 30th, 2006
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;
)
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 43
Reputation: Nedals is an unknown quantity at this point 
Solved Threads: 0
Nedals Nedals is offline Offline
Light Poster

Re: program help

 
0
  #2
Mar 30th, 2006
n = k*3;
In this line, what are the values of n and k ?
Did you put that line in the right place?
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: program help

 
0
  #3
Mar 30th, 2006
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;
)
You haven't even got the user input.

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;
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 163
Reputation: grunge man is an unknown quantity at this point 
Solved Threads: 2
grunge man grunge man is offline Offline
Junior Poster

Re: program help

 
0
  #4
Mar 30th, 2006
o now i get it thanks yor trigering back my memory um but hey i have another question what does endl mean and what would happen if you put the values 4 to k and 5 to n
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 163
Reputation: grunge man is an unknown quantity at this point 
Solved Threads: 2
grunge man grunge man is offline Offline
Junior Poster

Re: program help

 
0
  #5
Mar 30th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: program help

 
0
  #6
Mar 31st, 2006
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;
I don't think that compiles without errors?
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: program help

 
0
  #7
Mar 31st, 2006
Originally Posted by iamthwee
I don't think that compiles without errors?
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: program help

 
0
  #8
Mar 31st, 2006
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.
It's a joke my friend, I better stop because your fagish whining is getting me and everyone else depressed.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: program help

 
0
  #9
Mar 31st, 2006
Try this?

  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main()
  6.  
  7. {
  8. int k,n;
  9. k = 0;
  10. n = 0;
  11. cout<<"type a number";
  12. cin>>k;
  13. n=k*3;
  14. cout<<endl<<n;
  15.  
  16. system ("pause"); /* execute M$-DOS' pause command */
  17. return 0;
  18. }
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 1,546
Reputation: Ene Uran has a spectacular aura about Ene Uran has a spectacular aura about 
Solved Threads: 174
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Posting Virtuoso

Re: program help

 
0
  #10
Mar 31st, 2006
Okay children, stop the name calling!
grunge man, you forgot to iclude <iostream>
  1. #include <cstdlib> // system()
  2. #include <iostream> // cout, cin, endl
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int k, n;
  9.  
  10. cout<<"type a number: ";
  11. cin >> k;
  12. n = k*3;
  13. cout << "\ntimes three = " << n << endl;
  14.  
  15. system("PAUSE");
  16. return EXIT_SUCCESS; // optional with C++
  17. }
drink her pretty
Reply With Quote Quick reply to this message  
Reply

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




Views: 2037 | Replies: 16
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC