1.Introduction to C
1.Introduction to C
Objective:
1
Computer Program
▪ Computer Program
3
Computer Program
▪ Assembly Languages
• English-like abbreviations called mnemonics formed the basis
• Clearer to humans but incomprehensible to computers
• Need to translate to machine language using translator
programs called assemblers
Example: load salary
add bonus
store total
4
Computer Program
2. High Level Programming Languages
• Instructions look almost like English and mathematical notations
• Substantial tasks can be accomplished from a single statement
• Easy for humans to understand
• Translator programs convert high-level programming languages
into machine language
Example: total = salary + bonus;
• C, C++, Python, Visual Basic and Java are some of the high-level
programming languages
5
Program code Translation
▪ Translator
Object Code –
Source Code Translator Machine Language Code
6
History of C
▪ C language was evolved from two previous languages, BCPL and B by
Dennis Ritchie at Bell Laboratories in 1972.
▪ C initially became widely known as the developing language of the
UNIX operating system.
▪ C99 and C11 are revised standards for C programming language that
refines and expands the capabilities of C
7
Simple C Program
8
Simple C Program
/* First program in C This program displays a // function main begins program
message */ execution
#include <stdio.h>
9
Simple C Program Description
int main(void)
▪ Every C program has this main function, and it begins executing at main. “int” to left of main
indicates that the function returns an integer. “void” in parentheses indicates that main does not
receive any information
{
▪ Left brace , { , begins the body of every function.
▪ Functions ends with a corresponding right brace.
▪ The portion of the program between the braces is called a block.
printf(“Welcome to C”);
▪ Entire line is called a statement.
▪ It instructs the computer to perform an action.
▪ A statement must end with a semicolon.
▪ This statement prints a string of characters marked by the quotation marks on the screen
10
Simple C Program Description
Return 0;
12
More examples