CP-4.ppt - Computer Programming General form of a C program Program description#include directives int main constant declarations variable declarations

CP-4.ppt - Computer Programming General form of a C program...

This preview shows page 1 - 7 out of 20 pages.

Computer Programming
Image of page 1
General form of a C++ program // Program description #include directives int main() { constant declarations variable declarations executable statements return 0; }
Image of page 2
C++ compiler directives The #include directive tells the compiler to include some already existing C++ code in your program. The included file is then linked with the program. There are two forms of #include statements: #include <iostream> //for pre-defined files #include "my_lib.h" //for user-defined files
Image of page 3
C++ keywords Each keyword has a predefined purpose in the language. Do not use keywords as variable and constant names!! Exmples: bool, break, case, char, const, continue, do, default, double, else, extern, false, float, for, if, int, long, namespace, return, short, static, struct, switch, typedef, true, unsigned, void, while etc etc..
Image of page 4
C++ identifiers Variable: Location in memory where value can be stored An identifier is a name for a variable, constant, function, etc. Series of characters (letters, digits, underscores) Cannot begin with digit Are Case sensitive Cannot have special characters in them. Examples of valid identifiers: First_name, age, y2000, y2k Examples of invalid identifiers: 2000y, X=Y, J-20, ~Ricky,*Michael Identifiers are case-sensitive. For example: Hello, hello, WHOAMI, WhoAmI, whoami are unique identifiers.
Image of page 5
C++ comments Comments are explanatory notes Document programs Improve program readability Ignored by compiler
Image of page 6
Image of page 7

You've reached the end of your free preview.

Want to read all 20 pages?

  • Fall '18
  • Zia Ul Rehman
  • intvar

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes