You need to Register First!

Before you Log-in...




 
HomePortalCalendarGalleryFAQSearchMemberlistUsergroupsRegisterLog in
Sample design and thinking of Something new Graphical design.... To all member's of this website please Fill up the form of your Personal Information for Special Reference of our Forum thank you!
For non-member just post your comment in the chatbox. Thanks for Visiting our site.
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Latest topics
» Adobe Photoshop CS6 portable
Mon Nov 28, 2016 7:06 pm by Kuteshikimi

» Adobe Photoshop CS3 portable
Mon Nov 28, 2016 7:04 pm by Kuteshikimi

» ADODC Datagrid
Fri Jul 06, 2012 8:22 am by Kuteshikimi

» Programming Language
Fri Jul 06, 2012 8:12 am by Kuteshikimi

» History of C++
Fri Jul 06, 2012 8:11 am by Kuteshikimi

» Part of a C++ Syntax
Fri Jul 06, 2012 8:09 am by Kuteshikimi

» TURBO C++ Operators
Fri Jul 06, 2012 8:08 am by Kuteshikimi

» Adding 3 Number
Fri Jul 06, 2012 8:05 am by Kuteshikimi

» C++ Sample System
Fri Jul 06, 2012 8:03 am by Kuteshikimi

ENGINEERING.COM GAMES
Top 100 Games
Game Site Top 100


Most active topic starters
Kuteshikimi
 
imbaBOY
 
Top posters
Kuteshikimi
 
imbaBOY
 
markeeh17
 
Top posting users this month
Top posting users this week
Visitor’s Unique Page-View
Visitor Counter
Visitor Counter
Visitor’s
free counters
Globe
Similar topics

Share | 
 

 Part of a C++ Syntax

View previous topic View next topic Go down 
AuthorMessage
Kuteshikimi
Admin
Admin
avatar

Posts : 41
Join date : 2011-09-01
Age : 27
Location : Cavite City, Philippines

PostSubject: Part of a C++ Syntax   Fri Jul 06, 2012 8:09 am

 PREPROCESSOR DIRECTIVES

To start off, we have the preprocessor directives at the topmost part of C++ program. This is where all functions are imported or, in C++ terms, “included”. Without it you won’t be able to execute any command at all, since commands are always included from other functions. This is very important because without it, the command getch() will not execute properly since it was imported from conio.h.

Code: #include <conio.h>


conio stands for “console input/output” an “H-file” because its extension is .h
“h” signifies a header file.

Code: #include<iostream.h>


iostream stands for input/output an “H-file” because its extension is .h
“h” signifies a header file.



 FUNCTIONS
Are lines of code grouped that performed several tasks in a program. They are easily recognizable because names are immediately followed by parenthesis. The number of functions found in a C++ program can range from 1 to as many as the user desires.
The main() function, as long as main() is present , the program will still compile and run- assuming all the codes inside the main() functions can stand on their own and are not cross-referencing other functions.


 DATA TYPES
When we declare variables, we also declare the variables data type and determines what kind of values it can store within itself. When a program that has a variable declared within it is run, OS reserves memory locations to hold these variables.


DATA TYPES CODE EXAMPLE
integer int 1,2,3,4,5,6...
float float 13.1,3.14..
character char A,b,c,d,e…

• INTERGER – holds whole number.
• FLOAT- holds decimal numbers.
• CHARACTER –can store single character.

VARIABLE AND CONSTANT

• Variable- Change values throughout the program- you can think of variables as containers whose contents can change and be accessed for future use.
(HOLDS SINGLE VALUE)

• Constant - should be given initial values. Retain that same value throughout the program; values cannot be change during the execution of the program.
(FIXED VALUE)

• Identifier – is the variable name, or how you present it in your program code.
Example. studentsAge, grade;

Rules in declaring variables or naming identifiers :
1.) Identifier can only contain letters, numbers, dollar sign($), and underscore.
2.) Identifier cannot start in numbers.
3.) If the identifier is consist of two or more words, the words must be considered as one, by making them connected with underscore, or just remove the spaces.
4.) Identifiers are case sensitive.


EXAMPLE OF IDENTIFIER

VALID INVALID
num1 1num
numOne num one
$econdName3 myN@m?
your_Name yo-ur/Na*me
fName float
love2love "love,love"


 STATEMENTS

A statement is an instructional code that commands the computer to do certain action upon its execution. A semicolon ( signifies the end of an statement. The declaration of a variable in a function is also considered as a statement since the entire line of code ends with a semicolon.

 COMMENTS

Comments- are lines of code that are not executed during the program. They are used either to give a brief labeling and explanation to lines of codes or to temporarily disable lines of code during the development phase. There are two kinds of comments that C++ utilizes.
• Single-line Comment – a double slash (//) at the beginning of a line of code disables the entire statement and considers it merely as a comment
• Multi-line Comment – several lines of code can be disabled by placing the code block between a slash- asterisk (/*) and an asterisk-slash (*/)

Example of variable declarations “int studentsAge”; where int is a data type
And studentsAge is the variable.

CODING GUIDELINES

 Use comments for documentation and readability.
 White spaces are ignored.
 Indent for readability .


 THE COUT AND CIN STATEMENTS

cout - statement outputs all the variables or constants that are declared in it.

Syntax: cout <<“C++ is cool!\ n”;

cin – statement asks for an input from the user. Create a new C++ program with the following lines of code and observed what happens;

#include <iostream.h>
#include <conio.h>

main()
{
int int1;
cout<<“\n Enter an integer : \n”;
cin>>int1;
cout<<int1;
getch();
return 0;
}
Back to top Go down
View user profile http://kuteshikimi.forumtl.com
 
Part of a C++ Syntax
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Jakey - Oh, Brother! - Part 2 - Responsibilities
» Labours Legacy
» Part 3 Proposed Soul-ution - James Taylor loves Vets too- Annette Hartlen this song is for you ! :)
» Máy bay chiến đấu part 6
» Máy bay chiến đấu part 4

Permissions in this forum:You cannot reply to topics in this forum
 :: FORUM :: Datacom Institute of Computer Technology :: C++-
Jump to: