01 basic programming in c++

13
[email protected] Basic Programming in C++ Session 1

Upload: suyanto-jarwosuwito

Post on 09-Jun-2015

282 views

Category:

Technology


5 download

TRANSCRIPT

Page 1: 01 basic programming in c++

[email protected]

Basic Programming in C++

Session 1

Page 2: 01 basic programming in c++

[email protected]

C is developed by Dennis Ritchie

C is a structured programming language

C supports functions that enables easy maintainability of code, by breaking large file into smaller modules

Comments in C provides easy readability

C is a powerful language

Introduction to C Language

Page 3: 01 basic programming in c++

[email protected]

Basic Computer Model

Von Neumann Architecture

Page 4: 01 basic programming in c++

[email protected]

Programming Languages

+1300042774

+1400593419

+1200274027

LOAD A

ADD B

STORE C

C=A+B

Page 5: 01 basic programming in c++

[email protected]

Creating Programs

Source File

(High-Level Languages)

Object File

(Machine Languages)Executable

gcc –o hello hello.cnedit hello.c

Page 6: 01 basic programming in c++

[email protected]

Program Structure C + +

Page 7: 01 basic programming in c++

[email protected]

Structure of C + + Coding

Page 8: 01 basic programming in c++

[email protected]

Input

scanf

getchar

gets

Basic Commands C++

Output

printf

putchar

puts

Page 9: 01 basic programming in c++

[email protected]

Input

scanf(“%d”,&a);

Gets an integer value from the user and stores it under the name “a”

Output

printf(“%d”,a)

Prints the value present in variable a on the screen

Basic Commands C++

Page 10: 01 basic programming in c++

[email protected]

Single line comment

// (double slash)

Termination of comment is by pressing enter key

Multi line comment

/*….

…….*/

This can span over to multiple lines

Comments in C++

Page 11: 01 basic programming in c++

[email protected]

1./* Hello, world program */

2.#include <stdio.h>

3.

4.int main()

5.{

6. printf("hello, ");

7. printf("world\n");

8. return 0;

9.}

Simple Program

Page 12: 01 basic programming in c++

[email protected]

Type a program

Save it

Compile the program – This will generate an exe file (executable)

Run the program (Actually the exe created out of compilation will run and not the .c file)

In different compiler we have different option for compiling and running. We give only the concepts.

Running a C Program

Page 13: 01 basic programming in c++

[email protected]

Write a program to display your identity with a form below :------------------------------------------------------

AUTO BIOGRAFI------------------------------------------------------Name : <nama>Address : <alamat>Place of Birth : <tmp_lahir>Date of Birth : <tgl_lahir>Hobby : <hobby>------------------------------------------------------

Task 1