• Tidak ada hasil yang ditemukan

C Programming Language

N/A
N/A
Protected

Academic year: 2023

Membagikan "C Programming Language"

Copied!
11
0
0

Teks penuh

(1)

E A S Y T O L E A R N

C Programming Language

(2)

Why Choose C?

 Easy to learn

 Structured language

 It produces efficient programs.

 It can handle low-level activities.

 It can be compiled on a variety of computer platforms.

 C code runs nearly as fast as code written in

assembly language.

(3)

Applications of C

 Operating Systems

 Language Compilers

 Assemblers

 Text Editors

 Print Spoolers

 Network Drivers

 Modern Programs

 Databases

 Language Interpreters

 Utilities

(4)

C Program Structure

(5)

CPS(Cont..)

 A C program basically consists of the following parts:

 Preprocessor Commands

 Functions

 Variables

 Statements & Expressions

 Comments

(6)

C Basic Syntax

 Tokens:

A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol.

For example, the following C statement consists of five tokens:

printf("Hello, World! \n");

The individual tokens are:

printf (

"Hello, World! \n");

)

;

(7)

C Basic Syntax

 Semicolons ;

In C program, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity.

For example, following are two different statements:

printf("Hello, World! \n");

return 0;

Comments : Comments are like helping text in your C program and they are ignored by the compiler. They start with /* and terminates with the characters */ as shown below:

/* my first program in C */

We cannot have comments within comments and they do not occur

within a string or character literals.

(8)

C Basic Syntax

 Identifiers:

o

A C identifier is a name used to identify a variable, function, or any other user-defined item.

o

An identifier starts with a letter A to Z or a to z or an underscore _ followed by zero or more letters, underscores, and digits (0 to 9).

o

C does not allow punctuation characters such as @, $, and % within identifiers. C is a case sensitive programming language.

o

Thus, Manpower and manpower are two different identifiers in C.

o

Here are some examples of acceptable identifiers:

mohd zara abc move_name a_123

myname50 _temp j a23b9 retVal

(9)

C Basic Syntax

 Keywords:

The following list shows the reserved words in C.

These reserved words may not be used as constant or

variable or any other identifier names.

(10)

C Basic Syntax

Whitespace in C :

o A line containing only whitespace, possibly with a comment, is known as a blank line, and a C compiler totally ignores it.

o Whitespace is the term used in C to describe blanks, tabs, newline characters and comments.

o Whitespace separates one part of a statement from another and enables the compiler to identify where one element in a statement, such as int, ends and the next element begins.

o Therefore, in the following statement: int age;

o There must be at least one whitespace character (usually a space) between int and age for the compiler to be able to distinguish them.

o On the other hand, in the following statement:

fruit = apples + oranges; // get the total fruit

o No whitespace characters are necessary between fruit and =, or between = and apples, although you are free to include some if you wish for readability purpose.

(11)

Thank you

Referensi

Dokumen terkait

multiobjective problem. In this sense, it is necessary to the following results. Remark 2.1 The concepts of expected value, minimum variance, etc., weak and properly

Sodas contain sugar that is not necessary to the body and does not contain the vitamins and minerals the body needs.. Juices on the other hand other hand are considered healthy given

§24.2 The fundamental role of classes, class hierarchies, type checking, and programming itself §24.3 Uses of classes and class hierarchies, focussing on dependencies between

The amount of commonality between types that can be exploited by using inheritance and virtual functions is the litmus test of the applicability of object-oriented programming to

The following is the pseudocode and flowchart for a modification of our example: If it is raining, tell the user to get an umbrella.. Otherwise, say it

The following example demonstrates running Python interactively from the command line and then running the hello.py program.. Executing a

The previous chapters have all been using the View - based Application template available in the iPhone SDK because it is the simplest way to get started in iPhone programming. When

In the following code we prompt the user for the number of products to be entered, and then declare a pointer to an array in the dynamic memory space:.