how do u write this if then statment but in c++ if g=3282 then g=k;
to bad there wasnt a then like there is an else in c++

c and c++ does not use the "then" statement as some other languages do. The next statement or block following the if statement is executed when the if statement is true. Notice the use of the double '=' symbol which is the logical equal. A single '=' means assignment. Lots of people get tripped up on those differences -- even some old timers like me :o

if( g == 3282)
{
    // true condition
    g = k;
}
else
{
   // false statement
}

>how do u write this if then statment but in c++ if g=3282 then g=k;
Don't you have a book? Learning a language is extremely difficult without a proper reference available.

>to bad there wasnt a then like there is an else in c++
Why? "then" is typically used as a language defined parsing helper for the compiler, like the parentheses in C++. When the parser finds "if", it processes a conditional test until it finds the corresponding "then". Compare:

if a = b then
  <statements>
endif
if ( a == b ) {
  <statements>
}

It's pretty obvious that this framework is already in place in C++; it just doesn't use the same tokens.

Now, an interesting tidbit that's largely unrelated is that "then" isn't always used like that. In a stack based language like FORTH, the parsing trick isn't needed, and "then" is used as a conditional terminator (what other languages use "endif" for):

a b = if
  <statements>
then

whoa narue thats cool that there is an endif thanks um also thanks for all the advice u have given me it has taught me to have disipline during social speach

>whoa narue thats cool that there is an endif
Well, not in C++. But you can fake it with macros if you're a sadist:

#define then {
#define endif }

if ( a == b ) then
  <statements>
endif

But, don't do that. You won't be able to show your code to very many people before they lynch you. ;)

But, don't do that. You won't be able to show your code to very many people before they lynch you. ;)

You are absolutely right about that! I once worked on a large-team project where one of the programmers came from PASCAL -- he created almost everything in macros so that his c++ program looked just like a PASCAL program. After he left we all cursed him for that and rewrite his programs to remove those macros.

thats amasing so macros are suplimentations from other codes, but instead i allso agree that thats stupid. if u want to creat a program in another launge then u should just supliment that santax into an other programs santax instead of using macros, and ok i thought i got it but now im not shure um does this soud corect anyways though?
the { }brackets are sublimented for the then, so

(if a==b) /*then*/{a=2}

?

also i tried that here but it didnt work

if( g == 3282)
{g = k;}
else
{g=0}

here r the errors
C:\Dev-Cpp\Untitled2.cpp In function `int main(int, char**)':
37 C:\Dev-Cpp\Untitled2.cpp expected `;' before '}' token
here r the errors

see my previous post for example how to use the brackets. And put them on a separate line to make them easier to see -- helps understand the code better.

nvm ignore that one pleas answer the edited question above what u just wrote and pleas answere what i need to fix

>{g=0}
You need a terminating semicolon:

{g=0;}

These things are easier to see if you separate the statements from the brackets and use whitespace between tokens consistently:

if (g == 3282)
{
  g = k;
}
else
{
  g = 0;
}

but for me i am an html person so it is easy the other way for me but i see your point.
u know how u "niped" my other thread well is it posible for me to nip my own threads?

>but for me i am an html person so it is easy the other way for me but i see your point.
Well, HTML technically isn't a programming language, so now you're learning the real thing. :)

>is it posible for me to nip my own threads?
No, only forum moderators can lock threads. You can, however, mark your own thread as solved when you feel your question has been answered to your satisfaction. The option is just above the first post, to the right of the Advanced Reply button.

tecknickly it is a programing launguage because any computer launguage takes an input of text asined to a sirtian file type compiles it and sendes the out put to the monitor or out put device and it does all this through microprosessors converted from text to binary code to an output converter except in html it compiles over the internet server and out to the screen um and i know it is because xml 4.0 is an updated html programing launguage used in cell phones but feel free to corect me if i may be wrong

ya i know hyper text markup launguage but come on it does the same function any other lauguange does

with some exseptions

and there are a lot of exceptions :cheesy: you can't even do file i/o with it. the only useful thing HTML can be used for is displaying stuff in browser windows. (I'm not an HTML programmer).

actually with javascript/css/xml ect other stuff you can creat games and other stuff um question whats i/o mean um is it mean 1/0 on off functions?

>tecknickly it is a programing launguage
No, it's not, by any definition.

>but come on it does the same function any other lauguange does
Really? Do this with HTML:

for ( int i = 0; i < 10; i++ )
  cout<<"Repeat\n";

Give me a data structure, even a simple one, in pure HTML. Two *primary* requirements for any programming language are the manipulation of data, and control of the flow of execution. HTML can do neither because it's not designed to be a programming language. HTML is a file format that external programs (browsers) use to determine the appearance of text.

>>whats i/o mean

A general term that means Input/Output -- such as writing to and reading from files or some other device such as sockets, keybord, serial ports, cd drives, databases, etc.

>whats a data structure?
Array, linked list, binary search tree. Any structured collection of data.

>ok what type of data do u want it to be?
Integers will be fine. And a table doesn't count as it's a formatting directive for text, not a data structure, if that's what you were thinking. :)

nope wasnt thinking of a table at all ok to your service i have a verry good idea to do this and fine ill make it simple

here is the basic structure of it in c++

#include <stdlib.h>
using namespace std;
#include <iostream>
int main(int argc, char **argv)
{
int a,b,k;
cout<<"enter 1,2,or3";
cin>>k;
cout>>"enter 1,2,or3";
cin<<b;
a=k+b;
cout<<endl<<a:
system ("pause");
return 0;
}

after i get this corected and working ill start the html version of it so could u guys corect it for me?errors.
C:\Dev-Cpp\Untitled33.cpp In function `int main(int, char**)':
9 C:\Dev-Cpp\Untitled33.cpp no match for 'operator>>' in 'std::cout >> "enter 1,2,or3!"'
10 C:\Dev-Cpp\Untitled33.cpp no match for 'operator<<' in 'std::cin << b'

>The << and >> operators are not interchangeable. You also have a few other syntax errors and unnecessary stuff that can be removed:

#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
  int a,b,k;
  cout<<"enter 1,2,or 3";
  cin>>k;
  cout<<"enter 1,2,or 3";
  cin>>b;
  a=k+b;
  cout<<endl<<a;
  system ("pause");
}

ok narue it will take me about two days because im a little rusty on html right now is that ok?

This question has already been answered. Start a new discussion instead.