0% found this document useful (0 votes)
40 views18 pages

Lecture Slide 02 - Basic Structure of C

This document serves as an introduction to the C programming language, outlining its history, features, and basic structure. It covers essential elements such as the main function, header files, and the use of comments in code. Additionally, it highlights the importance of an Integrated Development Environment (IDE) for programming in C.

Uploaded by

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

Lecture Slide 02 - Basic Structure of C

This document serves as an introduction to the C programming language, outlining its history, features, and basic structure. It covers essential elements such as the main function, header files, and the use of comments in code. Additionally, it highlights the importance of an Integrated Development Environment (IDE) for programming in C.

Uploaded by

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

Lecture 1:

Introduction

1
Structured Programming
Language Lab
Lecture 1 : Introduction
Engr. Md Arif Hasan
Chowdhury

Assistant Professor
Department of Computer Science and
Engineering
C Programming Language
 Mother language
 System programming language
 Procedure-oriented programming language
 Structured programming language
 Mid-level programming language
History of C
Language Year Developed By

Algol 1960 International Group

BCPL 1967 Martin Richard

B 1970 Ken Thompson

Traditional C 1972 Dennis Ritchie

K&RC 1978 Kernighan & Dennis


Ritchie

ANSI C 1989 ANSI Committee

ANSI/ISO C 1990 ISO Committee

C99 1999 Standardization


Committee
Features of C Language
Structure of C Program
/* Comments */ Comments are a way of explaining
what makes a program. The
compiler ignores comments and
used by others to understand the
code.
#include<stdio.h stdio is standard for input/output, this
> allows us to use some commands which Example Program
includes a file called stdio.h.
int/void main() int/void is a return value, which will be #include <stdio.h>
explained in a while.
main() The main() is the main function where int main()
program execution begins. Every C
program must contain only one main
/*This main Function*/
function. {
Braces Two curly brackets "{...}" are used to
printf("Hello
group all statements.. World!");
printf() It is a function in C, which prints text on return 0;
the screen. }
return 0 At the end of the main function returns
value 0.
#include <stdio.h>

int main() {
printf("Hello World!");
return 0;
}
C Programming
Lecture 4 : Variables ,
Data Types

Lecture notes : courtesy of Ohio Supercomputing Center, science and technolgy suppo
First Program
#include <stdio.h> Output :
int main()
{ Hello World!
/* My first program */
printf("Hello World! \n");

return 0;
}

 C is case sensitive.
 End of each statement must be marked with a semicolon (;).
 Multiple statements can be on the same line.
 White space (e.g. space, tab, enter, …) is ignored.
First Program
#include <stdio.h>
int main() Output :
{
/* My first program */ Hello World!
printf("Hello World! \n");

return 0;
}

 The C program starting point : main().


 main() {} indicates where the program actually starts and ends.
 In general, braces {} are used throughout C to enclose a block of
statements to be treated as a unit.
 COMMON ERROR: unbalanced number of open and close
curly brackets!
First Program
#include <stdio.h>
int main() Output :
{
/* My first program */ Hello World!
printf("Hello World! \n");

return 0;
}

 #include <stdio.h>
 Including a header file stdio.h
 Allows the use of printf function
 For each function built into the language, an associated header file
must be included.

 printf() is actually a function (procedure) in C that is used


for printing variables and text
First Program
#include <stdio.h>
int main() Output :
{
/* My first program */ Hello World!
printf("Hello World! \n");

return 0;
}

 Comments
 /* My first program */
 Comments are inserted between “/*” and “*/”
 Or, you can use “//”
 Primarily they serve as internal documentation for
program structure and function.
Why use comments?
 Documentation of variables, functions and
algorithms

 Ex) for each function, explain input and output of


the function, and what the function does.

 Describes the program, author, date,


modification changes, revisions,…
Header Files
 Header files contain definitions of functions and variables

 Preprocessor #include insert the codes of a header file into


the source code.

 Standard header files are provided with each compiler

 To use any of the standard functions, the appropriate header


file should be included.
 Ex) to use printf() function , insert #include <stdio.h>

 In UNIX, standard header files are generally located in the


/usr/include subdirectory
Header Files
#include <string.h>
#include <math.h>
#include “mylib.h”

 The use of brackets <> informs the compiler to


search the compiler’s include directories for
the specified file.

 The use of the double quotes “” around the


filename informs the compiler to start the
search in the current directory for the
specified file.
Execution
Environment

Optionally
under control
of a
Debugger

17
IDE
 Integrated Development Environment
 Editor
 Compiler
 Debugger
 Ex: Clion, Codelite, Code:Bcloks, Sublime
Text,VSCode

MS Visual C++ Xcode

18

You might also like