944,164 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2291
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Mar 30th, 2006
0

program help

Expand Post »
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;
)
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster
grunge man is offline Offline
169 posts
since Mar 2006
Mar 30th, 2006
0

Re: program help

n = k*3;
In this line, what are the values of n and k ?
Did you put that line in the right place?
Reputation Points: 11
Solved Threads: 0
Light Poster
Nedals is offline Offline
43 posts
since Dec 2005
Mar 30th, 2006
0

Re: program help

Quote 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;
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Mar 30th, 2006
0

Re: program help

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
Reputation Points: 10
Solved Threads: 2
Junior Poster
grunge man is offline Offline
169 posts
since Mar 2006
Mar 30th, 2006
0

Re: program help

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
Reputation Points: 10
Solved Threads: 2
Junior Poster
grunge man is offline Offline
169 posts
since Mar 2006
Mar 31st, 2006
0

Re: program help

Quote 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?
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Mar 31st, 2006
0

Re: program help

Quote 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.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Mar 31st, 2006
0

Re: program help

Quote 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.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Mar 31st, 2006
0

Re: program help

Try this?

C++ Syntax (Toggle Plain Text)
  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. }
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Mar 31st, 2006
0

Re: program help

Okay children, stop the name calling!
grunge man, you forgot to iclude <iostream>
C++ Syntax (Toggle Plain Text)
  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. }
Reputation Points: 625
Solved Threads: 211
Posting Virtuoso
Ene Uran is offline Offline
1,704 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: images?
Next Thread in C++ Forum Timeline: Looking up and displaying values in linked lists





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC