CS 150 Introduction to C++ Programming - Spring 1998 

[ Home | Lecture Notes| WebTutor | WebTutor Site Map]


C++ Syntax and Semantics

Valid Statements


Syntax is the grammar of the language, that is the rules for constructing valid statements in that language.
If you break the rules the compiler will complain.

Semantics is what the statements mean, like calculating something or printing out a message.
Computers can't read your mind, so they don't help much if the meaning of your program is not what you wanted.

Let's start with some syntax.

2. Mark the following as either valid or invalid, Assume all variables are of type int (from exercise 3 p.88)

  Valid Invalid
x * y = c;
y = con;
const int x : 10;
int x:
a = b % c;
Choose one when done
   

Copyright chris wild 1998.
For problems or questions regarding this web contact [Dr. Wild (e-mail:wild@cs.odu.edu].
Last updated: February 22, 1998.