C++ Basic Concepts

Add to Favourites
Post to:

Description
Description of C++ basic concepts

Comments
Presentation Transcript Presentation Transcript

C++ : C++ Basic Concepts By Maria Zapata

Important Features : Important Features C++ is built upon foundation of C. C++ was created to produce high performance for a specific type of CPU and operating system. C++ is the parent of JAVA. How C++ relates to Java?

Slide 3 : The main difference between C++ and Java is the type of environment for which each is designed. Java create portable programs and C++ can’t do the same because of the type of object code produced by the compiler. In the case of C++, the output from the compiler is machine code. Java compiles a program into a pseudocode, which is executed by a runtime system(JVM).

Slide 4 : Therefore, a Java program can run in any environment for which a JVM is available. Since the Java runtime systems stand between a program and CPU, the java programs are slower than the C++ programs. Java was developed in response to the unique programming needs of the online environments of the Internet, which is connected to many different types of CPU. If you want to create high-performance software, use C++. If you need to create highly portable software, use Java.

My first program : My first program #include using namespace std; int main() { int thisisanumber; cout<<“Please enter a number : “; cin>>thisisanumber; cout<<“You entered : “<

Slide 6 :

How does it work? : How does it work? #include using namespace std; int main() { int thisisanumber; cout<<“Please enter a number : “; cin>>thisisanumber; cout<<“You entered : “<

Variables : Variables ALL VARIABLES MUST BE DECLARED BEFORE THEY ARE USED Common types: int (range -32,768 through 32,767) float, double char Restrictions for variables: Must start with a letter (sometimes they may start with underline character _). They cannot match any C++ keyword Very important: The C++ language is a "case sensitive" language.

Using an Operator : Using an Operator C++ supports a full range of arithmetic operators : + Addition - Substraction * Multiplication / Division These operators work in C++ just like they do in algebra.

The following program uses the operator * to compute the area of a rectangle given its length and the width: : The following program uses the operator * to compute the area of a rectangle given its length and the width: //Using an operator #include using namespace std; int main() { int length; int width; int area; length = 7; width = 5; area = length * width; cout << “The area is “<

Fundamental Data Types : Fundamental Data Types

An interactive program : An interactive program #include using namespace std; int main() { int length; int width; cout<<“Enter the length : “; cin >>length; cout<<“Enter the width : “; cin >>width; cout<<“The area is “<

Program that converts feet to meters : Program that converts feet to meters #include using namespace std; int main() { double f; double m; cout <<“Enter the length in feet : “; cin >> f; m = f / 3.28; cout << f << “feet is “ << m << “ meters.”; } Here is a sample run: Enter the length in feet : 5 5 feet is 1.52439 meters.

Want to learn?

Sign up and browse through relevant courses.

Name:
Your Email:
Password:
Country:
Contact no:


Area code Number
Subjects you are interested in:
Word verification: (Enter the text as in image)


Sign Up Already a member? Sign In
I agree to WizIQ's User Agreement & Privacy Policy
7 Members Recommend
50 Followers

Your Facebook Friends on WizIQ

Give live classes, create & sell online courses

Try it free Plans & Pricing

Connect