C++ Basic Tutorial

Views:
 
Category: Education
     
 

Presentation Description

Assignmenthelp.net provides excellent online help services in C++ programming Assignment Help assignmenthelp.net/c-plus-plus.php

Comments

Presentation Transcript

C++ Tutorial: 

C++ Tutorial

C++ program : 

C++ program #include <iostream.h> int main() { //variable declaration //read values input from user //computation and print output to user return 0; } www.assignmenthelp.net

Hello world program: 

Hello world program The Hello world program in C++. #include <iostream.h> int main() { cout << “Hello world!”; return 0; } www.assignmenthelp.net

Variable declaration: 

Variable declaration type variable-name; Meaning: variable <variable-name> will be a variable of type <type> Where type can be: int //integer double //real number char //character Example: int a, b, c; double x; int sum; char my-character; www.assignmenthelp.net

Input statements: 

Input statements cin >> variable-name; Meaning: read the value of the variable called <variable-name> from the user Example: cin >> a; cin >> b >> c; cin >> x; cin >> my-character; www.assignmenthelp.net

Output statements: 

Output statements cout << variable-name; Meaning: print the value of variable <variable-name> to the user cout << “any message “; Meaning: print the message within quotes to the user cout << endl; Meaning: print a new line Example: cout << a; cout << b << c; cout << “This is my character: “ << my-character << “ he he he” << endl; www.assignmenthelp.net

If statements: 

If statements if (condition) { S1; } else { S2; } S3; condition S1 S2 S3 True False www.assignmenthelp.net

Boolean conditions: 

Boolean conditions Comparison operators == equal != not equal < less than > greater than <= less than or equal >= greater than or equal Boolean operators && and || or ! not www.assignmenthelp.net

C++ (if example): 

C++ (if example) #include <iostream.h> void main() { int I, j, k; cin >> i >> j >> k; if (i <=j) { cout << “min is “ << i << endl; } else { cout << “ min is “ << j << endl; } cout << “Output?” << endl; } www.assignmenthelp.net

While statements: 

While statements while (condition) { S1; } S2; condition S1 S2 True False www.assignmenthelp.net

While example: 

While example //read 100 numbers from the user and output their sum #include <iostream.h> void main() { int i , a, sum; sum=0; i =1; while ( i <= 100) { cin >> a; sum = sum + a; i = i+1; } cout << “sum is “ << sum << endl ; } www.assignmenthelp.net

PowerPoint Presentation: 

Thank You Programming Project Help Any Time From Anywhere 24x7 Hr www.assignmenthelp.net Email Us at : support@assignmenthelp.net