[go: up one dir, main page]

0% found this document useful (0 votes)
18 views21 pages

Lecture1 CSE

Uploaded by

Md. Alim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views21 pages

Lecture1 CSE

Uploaded by

Md. Alim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

CSE 411: Introduction to

Computer Language
By
Md. Monir Hossain
Lecturer
Department of Computer Science & Engineering
E-mail: monir.hossain.cse@sec.ac.bd

29-Sep-23 Computer Science & Engineering, SEC


Tentative Grading Scheme

• Attendance 10%
• Performance 10%
• Mid Term 20%
• Final Exam 40%
Recommended Textbook & Resources
1. Programming With C, Byron S Gottfried(Second Edition)

2. Tutorialspoint
Link: https://www.tutorialspoint.com/cprogramming/index.htm

3. Javapoint
Link: https://www.javatpoint.com/c-programming-language-tutorial

4. Programiz
Link: https://www.programiz.com/c-programming
5. Geeksforgeeks
https://www.geeksforgeeks.org/c-programming-language/
Course Objectives
• Programming basics and the fundamentals of C
• Data types in C
• Mathematical and logical operations
• Using if statement and loops
• Arranging data in arrays
• Implementing pointers
• File management and dynamic memory allocation
Phases of Computer Generations
Generations of Evolving
Time-Period
Computer Hardware
First Generation 1940s – 1950s Vacuum Tube Based

Second Generation 1950s – 1960s Transistor Based

Third Generation 1960s – 1970s Integrated Circuit Based

Fourth Generation 1970s – Present Microprocessor Based, VLSI

Artificial Intelligence Based,


Fifth Generation Present – Future
ULSI
Definition of a Computer Language
A computer language is a group of instructions that are used to create
computer programs. The main goal is to achieve human-computer
interaction.
• According to Wikipedia, there are more than 700 programming languages in the
world.

Types of Computer Languages


• Low Level Language: includes only 1’s and 0’s
• Machine Language: developed by only using binary numbers i.e., 0 and 1.
• Assembly Language: uses symbols, which are popularly known as mnemonics in
computer terminology to write the instructions.
• High Level Language: easily understood by Humans
High level programming language
Python Java
C++ C#
Visual Basic JavaScript
Object-oriented programming (OOP): is a computer programming
model that organizes software design around data, or objects, rather than
functions and logic. Pillars of OOPs-
1. Encapsulation 2. Data Abstraction
3. Polymorphism 4. Inheritance.

Example: JavaScript, C++, Java, and Python.


What is C?
• C is a general-purpose, procedural, high-level programming language
used in the development of computer software and applications, system
programming, games, web development, and more. C language was
developed by Dennis M. Ritchie at the Bell Telephone Laboratories in
1972. It is a powerful and flexible language which was first developed
for the programming of the UNIX operating System. C is one of the most
widely used programming language.
• C programming language is known for its simplicity and efficiency. It is
the best choice to start with programming as it gives you a foundational
understanding of programming.
It can be defined by the following ways:
1.Mother language
2.System programming language
3.Procedure-oriented programming language
4.Structured programming language
5.Mid-level programming language
6.Portability
7.Easy to Extend
Example!

#include <stdio.h>
int main() {
printf("Hello C Programming\n");
return 0;
}
Compilation process in C
Tokens in C
A token in C can be defined as the smallest individual element of the
C programming language that is meaningful to the compiler. It is the
basic component of a C program.
Input & Output function

• scanf() function
• The scanf() function is used for input. It reads the input data from
the console.

• printf() function
• The printf() function is used for output. It prints the given statement
to the console.
Variables in C
• A variable is a name of the memory location. It is used to store data.
Its value can be changed, and it can be reused many times.
• It is a way to represent memory location through symbol so that it
can be easily identified.
Example:
int a; Valid variable names: Invalid variable names:
float b;
char c; int a; int 2;
int _ab; int a b;
int a30; int long;
Rules for defining variables
• The first character of an identifier should be either an alphabet or an
underscore, and then it can be followed by any of the character, digit,
or underscore.
• It should not begin with any numerical digit.
• In identifiers, both uppercase and lowercase letters are distinct.
Therefore, we can say that identifiers are case sensitive.
• Commas or blank spaces cannot be specified within an identifier.
• Keywords cannot be represented as an identifier.
• The length of the identifiers should not be more than 31 characters.
• Identifiers should be written in such a way that it is meaningful,
short, and easy to read.
Keywords
A keyword is a reserved word. You cannot use it as a variable name,
constant name, etc. There are only 32 reserved words (keywords) in
the C language.

auto else long switch

break enum register typedef

case extern return union

char float short unsigned

const for signed void

continue goto sizeof volatile

default if static while

do int struct _Packed

double
Data Types in C
-type of data stored in a C program. Data types are used while
defining a variable or functions in C.

Types Data Types

Basic Data Type int, char, float, double

Derived Data Type array, pointer, structure, union

Enumeration Data Type enum

Void Data Type void


Basic Data Types
Data Types Memory Size Range

char 1 byte −128 to 127

signed char 1 byte −128 to 127

unsigned char 1 byte 0 to 255

short 2 byte −32,768 to 32,767

signed short 2 byte −32,768 to 32,767

unsigned short 2 byte 0 to 65,535

int 2 byte −32,768 to 32,767

signed int 2 byte −32,768 to 32,767

unsigned int 2 byte 0 to 65,535

short int 2 byte −32,768 to 32,767

signed short int 2 byte −32,768 to 32,767

unsigned short int 2 byte 0 to 65,535

long int 4 byte -2,147,483,648 to 2,147,483,647

signed long int 4 byte -2,147,483,648 to 2,147,483,647

unsigned long int 4 byte 0 to 4,294,967,295

float 4 byte

double 8 byte

long double 10 byte


Comments in C
Comments in C language are used to provide information about lines of
code. It is widely used for documenting code.

• Single line comments are represented by double slash \\.

• Multi-Line comments are represented by slash asterisk \* ... *\. It


can occupy many lines of code, but it can't be nested.
Comments in C
Escape sequence Meaning

\\ \ character

\' ' character

\" " character

\? ? character

\a Alert or bell

\b Backspace

\f Form feed

\n Newline

\r Carriage return

\t Horizontal tab

\v Vertical tab

\ooo Octal number of one to three digits

\xhh . . . Hexadecimal number of one or more digits

You might also like