954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

program help

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
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;
)

grunge man
Junior Poster
170 posts since Mar 2006
Reputation Points: 10
Solved Threads: 2
 

n = k*3;
In this line, what are the values of n and k ?
Did you put that line in the right place?

Nedals
Light Poster
43 posts since Dec 2005
Reputation Points: 11
Solved Threads: 0
 

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 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;

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

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

grunge man
Junior Poster
170 posts since Mar 2006
Reputation Points: 10
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
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<

grunge man
Junior Poster
170 posts since Mar 2006
Reputation Points: 10
Solved Threads: 2
 

You haven't even got the user input.

set up variables properly:

int k = 0; int n = 0;

prompt the user: < "; <> k;

multiply by three: <

I don't think that compiles without errors?

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 
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.

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 
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 becauseyour fagish whining is getting me and everyone else depressed.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

Try this?

#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;
}
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

Okay children, stop the name calling!
grunge man, you forgot to iclude #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++
}

Ene Uran
Posting Virtuoso
1,723 posts since Aug 2005
Reputation Points: 625
Solved Threads: 213
 

lol funny
Okay children, stop the name calling!
[/code] yep ene uran u are right but i figured that out b4 u replied by looking at the questions in the dev c++ help guide but hey thanks any ways um now my program looks like this

#include
using namespace std;
#include

int main(int argc, char **argv)

{
int k,n,d,e,l,y,t,o,m;
k = 0;
n = 0;
cout<<"type a number";
cin>>k;

n=k*3;
d=n*3;
e=d*3;
l=e*3;
y=l*3;
t=y*3;
o=t*3;
m=o*3;
cout<

grunge man
Junior Poster
170 posts since Mar 2006
Reputation Points: 10
Solved Threads: 2
 

Do you mind using code tags?

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

what do u mean?

grunge man
Junior Poster
170 posts since Mar 2006
Reputation Points: 10
Solved Threads: 2
 
SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

o.... so i see um but im not a student im just learning it for my own im a do it yourself person but eaventhough im not a student i will folow the web sites rules and not ask questions b4 i figure parts of it out myself, and i will show more effort to cuz this teaches me dicipline well thanks but um could u now answer the question or do i have to do something first? i read it

grunge man
Junior Poster
170 posts since Mar 2006
Reputation Points: 10
Solved Threads: 2
 

nvm i figured out what u were saying i read the second one but where would u use the code tags?

grunge man
Junior Poster
170 posts since Mar 2006
Reputation Points: 10
Solved Threads: 2
 

use code tags anytime you are posting code to the board (or even text that you want to preserve indentation on as the board will eat it up otherwise)

Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You