Class 05

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

󾠲

Class 05
Introduction to the C Language

Objectives

To understand the structure of a C-language program.

To write your first C prrogram.

To introduce thbe include preprocessor command.

To be able to create good identifiers for objects in a program.

To be able to list, describe, and use the C basic data types.

To be able to create and use variables and constants.

To understand input and output concets.

To be ab le to use simple input and output statements.,

C is a structured programming language. It is considered a high-level language


because it allows the programmer to concentrate on the problem at hand and not
worry about the machine that the program will be using. That is another reason why

Class 05 1
it is used by software developers whose applications have to run on many different
hardware platforms.

Comments

/* */ this is used as a block comment while // is used as a single line comment

Rules for Identifiers

Class 05 2
First character must be alphabetic character or underscore.

Must consist only of alphabetic characters, digits, or underscores.

First 6 characters of an identifier are significant.

Cannout duplicate keyword.

Class 05 3
#include <stdio.h>

int main (int argc, const char * argv[])


{
int a, b, c, prod;
char name[80]; //ideal length daw ng arrary

printf("Name please: );
scanf("%s", name);
printf("Please enter three numbers:");
scanf("%d %d %d, &a, &b, &c);
prod = a*b*c;
printf("%s The product is %d\n", prod);
return 0;
}

source code —> machine code, object code, number code

Class 05 4
filename.c yung source code, then filename.exe ‘yung executive

output layout method

titignan mo ung output, aanalyze mo to make that program show that ganon

C Language Programming

Introduction

C is a general purpose language which is very closely associated with UNIX for
which it was developed in Bell Laboratories

Most of the programs of UNIX are written and run with the help of ‘C’

Many of the important ideas of ‘c’ stem are from BCPL by Martin Richards.

Why Name C was given to this language?

C programming language - structured and disciplined approach to program design

C supports functions that enables easy maintainability of code, by breaking


large file into smaller modules

Comments in C provides easy readability through the use of comments.

C is a powerful language

C programs built from:

Variable and type declaration

Functions

Statements

Expressions

Structure of C Programs

Class 05 5
before going and reading the structure of C programs we need to have a basic
knowledge of the followiung:

C’s character set

C’s keyword

The general structure of a ‘C’ program

How to end a statement

Free format language

Header files and library functions

The Keywords

keywords are words that have special meaning to the C compiler

their meaning cannot be changed at any stance

serve as basic building blocks for

Class 05 6
Class 05 7
Class 05 8

You might also like