SlideShare a Scribd company logo
STUDY C LANGUAGE
WITH
ARAFAT BIN REZA
INTRODUCTION OF C LANGUAGE
• What is C Language?
• C is a general-purpose, procedural, imperative computer programming language.
• C is the most widely used computer language.
• If you are new to programming, C is a good choice to start your programming journey.
INTRODUCTION OF C LANGUAGE
• C has now become a widely used professional language for various reasons −
• 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
INTRODUCTION OF C LANGUAGE
• A C program basically consists of the following parts −
• Preprocessor Commands
• Functions
• Variables
• Statements & Expressions
• Comments
MY FIRST PROGRAM IN C LANGUAGE .
• #include <stdio.h>
•
• int main()
• {
• /* my first program in C */
• printf("Hello, World! n");
•
• return 0;
• }
MY FIRST PROGRAM IN C LANGUAGE .
Let us take a look at the various parts of the above program −
1. The first line of the program #include <stdio.h> is a preprocessor command, which tells a C compiler to
include stdio.h file before going to actual compilation.
2. The next line int main() is the main function where the program execution begins.
3. The next line /*...*/ will be ignored by the compiler and it has been put to add additional comments in
the program. So such lines are called comments in the program.
4. The next line printf(...) is another function available in C which causes the message "Hello, World!" to
be displayed on the screen.
5. The next line return 0; terminates the main() function and returns the value 0.
BASIC SYNTAX
• Tokens in C
• the following C statement consists of five tokens −
• printf("Hello, World! n");
1. Bracket- a.() b.{} c.[] d.<>
2. Semicolons- The semicolon is a statement terminator. each individual statement must be ended with a
semicolon. It indicates the end of one logical entity.
Given below are two different statements −
printf("Hello, World! n");
return 0;
BASIC SYNTAX
3. Comments- Comments are like helping text in your C program and they are ignored by the compiler.
There are three types of Comments , they are :
a. /* */ b. // c.///
4. Identifiers- A C identifier is a name used to identify a variable, function, or any other user-defined item. An
identifier starts with a letter A to Z, a to z, or an underscore '_' followed by zero or more letters, underscores,
and digits.
C does not allow punctuation characters such as @, $, and % within identifiers. C is a case-sensitive programming
language. Thus, Manpower and manpower are two different identifiers in C.
Here are some examples of acceptable identifiers −
mohd zara abc move_name a_123
myname50 _temp j a23b9 retVal
BASIC SYNTAX
5. Keywords- The following list shows the reserved words in C. These reserved words may not be used as
constants or variables or any other identifier names.
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
BASIC SYNTAX
6. Whitespace - A line containing only whitespace, possibly with a comment, is known as a blank line, and
a C compiler totally ignores it.
Whitespace is the term used in C to describe blanks, tabs, newline characters and comments. 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. Therefore, in the following statement −
int age;
DATA TYPES
1. Char
2. unsigned char
3. signed char
4. Int
5. unsigned int
6. Short
7. unsigned short
8. Long
9. unsigned long
10. float
11. double
12. long double
VARIABLES
• Type Description
• Char-Typically a single octet(one byte). This is an integer type.
• Int-The most natural size of integer for the machine.
• Float-A single-precision floating point value.
• Double-A double-precision floating point value.
• Void-Represents the absence of type.
VARIABLE DEFINITION
1. type variable_list;
2. type variable_name = value;
1.EXAMPLE:
• int i, j, k;
• char c, ch;
• float f, salary;
• double d;
2. EXAMPLE:
extern int d = 3, f = 5; // declaration of d and f.
int d = 3, f = 5; // definition and initializing d and f.
byte z = 22; // definition and initializes z.
char x = 'x'; // the variable x has the value 'x'.
VARIABLE DECLARATION
• Example:
// Variable declaration:
extern int a, b;
extern int c;
extern float f;
EXAMPLE:
• #include <stdio.h>
• // Variable declaration:
• extern int a, b;
• extern int c;
• extern float f;
• int main () {
• /* variable definition: */
• int a, b;
• int c;
• float f;
•
• /* actual initialization */
• a = 10;
• b = 20;
•
• c = a + b;
• printf("value of c : %d n", c);
• f = 70.0/3.0;
• printf("value of f : %f n", f);
•
• return 0;
• }
FUNCTION
• // function declaration
• int func();
• int main() {
• // function call
• int i = func();
• }
• // function definition
• int func() {
• return 0;
• }
CONSTANTS
• Defining Constants
• There are two simple ways in C to define constants −
• Using #define preprocessor.
• Using const keyword.
• The #define Preprocessor:
• Given below is the form to use #define preprocessor to define a constant −
#define identifier value
EXAMPLE:
• #include <stdio.h>
• #define LENGTH 10
• #define WIDTH 5
• #define NEWLINE 'n'
• int main()
• {
• int area;
•
• area = LENGTH * WIDTH;
• printf("value of area : %d", area);
• printf("%c", NEWLINE);
• return 0;
• }
THE CONST KEYWORD
• You can use const prefix to declare constants with a specific type as follows −
• #include <stdio.h>
• int main() {
• const int LENGTH = 10;
• const int WIDTH = 5;
• const char NEWLINE = 'n';
• int area;
•
• area = LENGTH * WIDTH;
• printf("value of area : %d", area);
• printf("%c", NEWLINE);
• return 0;
• }
STORAGE CLASSES
• A storage class defines the scope (visibility) and life-time of variables and/or functions within a C
Program. They precede the type that they modify.
• We have four different storage classes in a C program −
• auto
• register
• static
• extern
THE AUTO STORAGE CLASS
• The auto storage class is the default storage class for all local variables.
• {
• int mount;
• auto int month;
• }
• The example above defines two variables with in the same storage class. 'auto' can only be used within
functions, i.e., local variables.
THE REGISTER STORAGE CLASS
• The register storage class is used to define local variables that should be stored in a register instead of
RAM. This means that the variable has a maximum size equal to the register size (usually one word) and
can't have the unary '&' operator applied to it (as it does not have a memory location).
• {
• register int miles;
• }
• The register should only be used for variables that require quick access such as counters. It should also
be noted that defining 'register' does not mean that the variable will be stored in a register. It means that it
MIGHT be stored in a register depending on hardware and implementation restrictions.
THE STATIC STORAGE CLASS
• The static storage class instructs the compiler to keep a local variable in existence during the life-time of
the program instead of creating and destroying it each time it comes into and goes out of scope.
Therefore, making local variables static allows them to maintain their values between function calls.
• The static modifier may also be applied to global variables. When this is done, it causes that variable's
scope to be restricted to the file in which it is declared.
• In C programming, when static is used on a global variable, it causes only one copy of that member to be
shared by all the objects of its class.
THE EXTERN STORAGE CLASS
• The extern storage class is used to give a reference of a global variable that is visible to ALL the program
files. When you use 'extern', the variable cannot be initialized however, it points the variable name at a
storage location that has been previously defined.
• When you have multiple files and you define a global variable or function, which will also be used in
other files, then extern will be used in another file to provide the reference of defined variable or
function. Just for understanding, extern is used to declare a global variable or function in another file.
OPERATORS
• Arithmetic Operators(+,−,*,/,%,++,--)
• Relational Operators(==,!= ,>,<,>=,<=)
• Logical Operators(&& ,||,! )
• Bitwise Operators( &, |, ^, ~,<<,>>)
• Assignment Operators(=,+=,-=,*=,/=,%=,<<=,>>=,&=,^=,|=)
• Misc Operators(sizeof(),&,*,? :)
DECISION MAKING
• Decision making structures require that the programmer
specifies one or more conditions to be evaluated or
tested by the program, along with a statement or
statements to be executed if the condition is determined
to be true, and optionally, other statements to be
executed if the condition is determined to be false.

More Related Content

PPTX
C language 2
PDF
Managing I/O operations In C- Language
PPTX
Introduction to C programming
PPTX
Overview of c language
PPTX
Lesson 7 io statements
PPTX
C LANGUAGE - BESTECH SOLUTIONS
PPSX
Complete C programming Language Course
DOCX
Basic structure of c programming
C language 2
Managing I/O operations In C- Language
Introduction to C programming
Overview of c language
Lesson 7 io statements
C LANGUAGE - BESTECH SOLUTIONS
Complete C programming Language Course
Basic structure of c programming

What's hot (20)

PDF
C language
PPT
Structure of a C program
PDF
User_Defined_Functions_ppt_slideshare.
PPTX
structure of a c program
PPT
C language Unit 2 Slides, UPTU C language
DOC
Storage classess of C progamming
PDF
C language for Semester Exams for Engineers
PPTX
C language ppt
PPTX
C Language (All Concept)
DOC
C notes diploma-ee-3rd-sem
PPT
Introduction to c programming
PPTX
Looping and switch cases
PPTX
Basic c programming and explanation PPT1
PPT
Fundamental of C Programming Language and Basic Input/Output Function
PPTX
Ch4 Expressions
PPTX
Ch9 Functions
PPT
The smartpath information systems c pro
PDF
Advanced C Language for Engineering
DOC
ODP
OpenGurukul : Language : C Programming
C language
Structure of a C program
User_Defined_Functions_ppt_slideshare.
structure of a c program
C language Unit 2 Slides, UPTU C language
Storage classess of C progamming
C language for Semester Exams for Engineers
C language ppt
C Language (All Concept)
C notes diploma-ee-3rd-sem
Introduction to c programming
Looping and switch cases
Basic c programming and explanation PPT1
Fundamental of C Programming Language and Basic Input/Output Function
Ch4 Expressions
Ch9 Functions
The smartpath information systems c pro
Advanced C Language for Engineering
OpenGurukul : Language : C Programming
Ad

Similar to C language (20)

PPTX
C language updated
PPT
Chapter-2 edited on Programming in Can refer this ppt
PPTX
C PROGRAMING.pptx
PPT
cs8251 unit 1 ppt
PDF
C programming notes
PDF
UNIT1 PPS of C language for first year first semester
PDF
C programming notes.pdf
PPT
Lecture 01 2017
PPTX
LESSON1-C_programming (1).GRADE 8 LESSONpptx
PDF
Learn c language Important topics ( Easy & Logical, & smart way of learning)
PPTX
Programming in C.pptx
PPTX
unit2.pptx
PPT
490450755-Chapter-2.ppt
PPT
490450755-Chapter-2.ppt
PPTX
Computer programming(CP)
PPTX
Lec 02 Introduction to C Programming.pptx
PPTX
C programming Training in Ambala ! Batra Computer Centre
PPTX
Aniket tore
PPTX
Lecture 1 progrmming with C
DOCX
fds unit1.docx
C language updated
Chapter-2 edited on Programming in Can refer this ppt
C PROGRAMING.pptx
cs8251 unit 1 ppt
C programming notes
UNIT1 PPS of C language for first year first semester
C programming notes.pdf
Lecture 01 2017
LESSON1-C_programming (1).GRADE 8 LESSONpptx
Learn c language Important topics ( Easy & Logical, & smart way of learning)
Programming in C.pptx
unit2.pptx
490450755-Chapter-2.ppt
490450755-Chapter-2.ppt
Computer programming(CP)
Lec 02 Introduction to C Programming.pptx
C programming Training in Ambala ! Batra Computer Centre
Aniket tore
Lecture 1 progrmming with C
fds unit1.docx
Ad

More from Arafat Bin Reza (7)

PPTX
C# Class Introduction.pptx
PPTX
C# Class Introduction
DOCX
Inventory music shop management
PPTX
C language 3
PDF
Sudoku solve rmain
DOCX
string , pointer
PPTX
final presentation of sudoku solver project
C# Class Introduction.pptx
C# Class Introduction
Inventory music shop management
C language 3
Sudoku solve rmain
string , pointer
final presentation of sudoku solver project

Recently uploaded (20)

PPT
Mechanical Engineering MATERIALS Selection
PPT
Project quality management in manufacturing
PDF
composite construction of structures.pdf
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
III.4.1.2_The_Space_Environment.p pdffdf
Mechanical Engineering MATERIALS Selection
Project quality management in manufacturing
composite construction of structures.pdf
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Fundamentals of safety and accident prevention -final (1).pptx
bas. eng. economics group 4 presentation 1.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Internet of Things (IOT) - A guide to understanding
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Safety Seminar civil to be ensured for safe working.
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Foundation to blockchain - A guide to Blockchain Tech
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
III.4.1.2_The_Space_Environment.p pdffdf

C language

  • 2. INTRODUCTION OF C LANGUAGE • What is C Language? • C is a general-purpose, procedural, imperative computer programming language. • C is the most widely used computer language. • If you are new to programming, C is a good choice to start your programming journey.
  • 3. INTRODUCTION OF C LANGUAGE • C has now become a widely used professional language for various reasons − • 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
  • 4. INTRODUCTION OF C LANGUAGE • A C program basically consists of the following parts − • Preprocessor Commands • Functions • Variables • Statements & Expressions • Comments
  • 5. MY FIRST PROGRAM IN C LANGUAGE . • #include <stdio.h> • • int main() • { • /* my first program in C */ • printf("Hello, World! n"); • • return 0; • }
  • 6. MY FIRST PROGRAM IN C LANGUAGE . Let us take a look at the various parts of the above program − 1. The first line of the program #include <stdio.h> is a preprocessor command, which tells a C compiler to include stdio.h file before going to actual compilation. 2. The next line int main() is the main function where the program execution begins. 3. The next line /*...*/ will be ignored by the compiler and it has been put to add additional comments in the program. So such lines are called comments in the program. 4. The next line printf(...) is another function available in C which causes the message "Hello, World!" to be displayed on the screen. 5. The next line return 0; terminates the main() function and returns the value 0.
  • 7. BASIC SYNTAX • Tokens in C • the following C statement consists of five tokens − • printf("Hello, World! n"); 1. Bracket- a.() b.{} c.[] d.<> 2. Semicolons- The semicolon is a statement terminator. each individual statement must be ended with a semicolon. It indicates the end of one logical entity. Given below are two different statements − printf("Hello, World! n"); return 0;
  • 8. BASIC SYNTAX 3. Comments- Comments are like helping text in your C program and they are ignored by the compiler. There are three types of Comments , they are : a. /* */ b. // c./// 4. Identifiers- A C identifier is a name used to identify a variable, function, or any other user-defined item. An identifier starts with a letter A to Z, a to z, or an underscore '_' followed by zero or more letters, underscores, and digits. C does not allow punctuation characters such as @, $, and % within identifiers. C is a case-sensitive programming language. Thus, Manpower and manpower are two different identifiers in C. Here are some examples of acceptable identifiers − mohd zara abc move_name a_123 myname50 _temp j a23b9 retVal
  • 9. BASIC SYNTAX 5. Keywords- The following list shows the reserved words in C. These reserved words may not be used as constants or variables or any other identifier names. 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
  • 10. BASIC SYNTAX 6. Whitespace - A line containing only whitespace, possibly with a comment, is known as a blank line, and a C compiler totally ignores it. Whitespace is the term used in C to describe blanks, tabs, newline characters and comments. 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. Therefore, in the following statement − int age;
  • 11. DATA TYPES 1. Char 2. unsigned char 3. signed char 4. Int 5. unsigned int 6. Short 7. unsigned short 8. Long 9. unsigned long 10. float 11. double 12. long double
  • 12. VARIABLES • Type Description • Char-Typically a single octet(one byte). This is an integer type. • Int-The most natural size of integer for the machine. • Float-A single-precision floating point value. • Double-A double-precision floating point value. • Void-Represents the absence of type.
  • 13. VARIABLE DEFINITION 1. type variable_list; 2. type variable_name = value; 1.EXAMPLE: • int i, j, k; • char c, ch; • float f, salary; • double d; 2. EXAMPLE: extern int d = 3, f = 5; // declaration of d and f. int d = 3, f = 5; // definition and initializing d and f. byte z = 22; // definition and initializes z. char x = 'x'; // the variable x has the value 'x'.
  • 14. VARIABLE DECLARATION • Example: // Variable declaration: extern int a, b; extern int c; extern float f;
  • 15. EXAMPLE: • #include <stdio.h> • // Variable declaration: • extern int a, b; • extern int c; • extern float f; • int main () { • /* variable definition: */ • int a, b; • int c; • float f; • • /* actual initialization */ • a = 10; • b = 20; • • c = a + b; • printf("value of c : %d n", c); • f = 70.0/3.0; • printf("value of f : %f n", f); • • return 0; • }
  • 16. FUNCTION • // function declaration • int func(); • int main() { • // function call • int i = func(); • } • // function definition • int func() { • return 0; • }
  • 17. CONSTANTS • Defining Constants • There are two simple ways in C to define constants − • Using #define preprocessor. • Using const keyword. • The #define Preprocessor: • Given below is the form to use #define preprocessor to define a constant − #define identifier value
  • 18. EXAMPLE: • #include <stdio.h> • #define LENGTH 10 • #define WIDTH 5 • #define NEWLINE 'n' • int main() • { • int area; • • area = LENGTH * WIDTH; • printf("value of area : %d", area); • printf("%c", NEWLINE); • return 0; • }
  • 19. THE CONST KEYWORD • You can use const prefix to declare constants with a specific type as follows − • #include <stdio.h> • int main() { • const int LENGTH = 10; • const int WIDTH = 5; • const char NEWLINE = 'n'; • int area; • • area = LENGTH * WIDTH; • printf("value of area : %d", area); • printf("%c", NEWLINE); • return 0; • }
  • 20. STORAGE CLASSES • A storage class defines the scope (visibility) and life-time of variables and/or functions within a C Program. They precede the type that they modify. • We have four different storage classes in a C program − • auto • register • static • extern
  • 21. THE AUTO STORAGE CLASS • The auto storage class is the default storage class for all local variables. • { • int mount; • auto int month; • } • The example above defines two variables with in the same storage class. 'auto' can only be used within functions, i.e., local variables.
  • 22. THE REGISTER STORAGE CLASS • The register storage class is used to define local variables that should be stored in a register instead of RAM. This means that the variable has a maximum size equal to the register size (usually one word) and can't have the unary '&' operator applied to it (as it does not have a memory location). • { • register int miles; • } • The register should only be used for variables that require quick access such as counters. It should also be noted that defining 'register' does not mean that the variable will be stored in a register. It means that it MIGHT be stored in a register depending on hardware and implementation restrictions.
  • 23. THE STATIC STORAGE CLASS • The static storage class instructs the compiler to keep a local variable in existence during the life-time of the program instead of creating and destroying it each time it comes into and goes out of scope. Therefore, making local variables static allows them to maintain their values between function calls. • The static modifier may also be applied to global variables. When this is done, it causes that variable's scope to be restricted to the file in which it is declared. • In C programming, when static is used on a global variable, it causes only one copy of that member to be shared by all the objects of its class.
  • 24. THE EXTERN STORAGE CLASS • The extern storage class is used to give a reference of a global variable that is visible to ALL the program files. When you use 'extern', the variable cannot be initialized however, it points the variable name at a storage location that has been previously defined. • When you have multiple files and you define a global variable or function, which will also be used in other files, then extern will be used in another file to provide the reference of defined variable or function. Just for understanding, extern is used to declare a global variable or function in another file.
  • 25. OPERATORS • Arithmetic Operators(+,−,*,/,%,++,--) • Relational Operators(==,!= ,>,<,>=,<=) • Logical Operators(&& ,||,! ) • Bitwise Operators( &, |, ^, ~,<<,>>) • Assignment Operators(=,+=,-=,*=,/=,%=,<<=,>>=,&=,^=,|=) • Misc Operators(sizeof(),&,*,? :)
  • 26. DECISION MAKING • Decision making structures require that the programmer specifies one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.