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

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

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;

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

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

Member Avatar for iamthwee

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?

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.

Member Avatar for iamthwee

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.

Member Avatar for iamthwee

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

Okay children, stop the name calling!
grunge man, you forgot to iclude <iostream>

#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++
}

lol funny

Okay children, stop the name calling!

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 <stdlib.h>
using namespace std;
#include <iostream>

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<<endl<<n;
cout <<endl<<d;
cout<<endl<<e;
cout<<endl<<l;
cout<<endl<<y;
cout <<endl<<t;
cout<<endl<<o;
cout<<endl<<m;
system ("pause"); 


return 0;
}

Do you mind using code tags?

what do u mean?

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

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

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.