SlideShare a Scribd company logo
1
C Programming Language
Group A
1. What is Programming Language? What down some salient
features of C Programming Language?
Ans: Computer Programming is simply writing down instructions for the computer
to follow. For stating the instructions, we need some language in which to state the
instructions. Unfortunately nature language such as English is insufficiently precise
for giving instructions to computers. Instead, we use special purpose languages
called programming Language. Thus programming Dan be defined as process of
writing, testing, debugging/troubleshooting and maintaining the source code of
computer programs.
Salient Features of C Programming
 C is a general purpose language i.e. it can be used for any type of
programming solution.
 It is a structured programming, so it provides a disciplined approach to write
the program.
 It has high level constructs, which gives users the programming efficiency.
 It can handle low level language, which gives the machine efficiency.
 It has a rich set of built-in functions and operators that can be used to write
any complex program.
 Program written in C are efficient and fast due to its variety of data types and
powerful operators.
2. What is C token? Explain the basic structure of a C program?
Ans: Individual word and punctuation marks are called C tokens. In a C program
the smallest individual units are known as C tokens. C has six types of tokens as
shown in Fig 2.
C Token
Keyword Identifier Constant String Special Symbol Operator
Fig 1: C Token.
2
Basic Structure of C Program
The basic structure of C is given in Fig 2.
Documentation section
Link section
Definition
Section
Global declaration section
main() function section
{
Declaration part
Executable
}
Sub program section
function 1
function 2
…………….
Fig 2: basic Structure of C program
 DocumentationSection
 It is set of Computer Line
 It includes Title Of Program, Author Name
 Data Used Or Summary Information
 Link Section
 It is also called Header File Declaration Section
 It Links Compiler to Link Functions From System Library
 Definition Section
 Defines Symbolic Constants
 Eg. #define Count 10
 Global DeclarationSection
 Variable that are accessed byone or more functions are called Global
Variable
 Global Variables are declared in this Section.
 Global Variables are always Declared outside of all Functions
 May Contain Function Definition
 Main Function Section
 User to start of actual C program.
 It include two parts as declaration part and executable part.
 Sub ProgramSection
 It has all User-defined Functions that are called in main
 User Defined Functions are generally placed immediately after main
3
3. Write down the steps of executing a C program. What are the
different forms of main statements C permits?
Ans: C program executes in 4 (four steps). This is given in Fig 3.
Create
program
Compile
program
Link
program
Execute
program
Fig 3: Executing of a C Program
 Creating a program
An editor like notepad or WordPad is used to create a C program. This file contains a
sourcecodewhich consists of executable code. The file should be saved as ‘*.c’
extension only.
 Compiling the program
The next step is to compile the program. The codeis compiled by using compiler.
Compiler converts executable codeto binary codei.e. object code.
 Linking a program to library
The object codeof a program is linked with libraries that are needed for execution of a
program. The linker is used to link the program with libraries. It creates a file with
‘*.exe’extension.
 Executing the program
The final executable file is then run by dos command prompt or by any other software.
Different Forms of main() Statement
C permits different forms of main statement. The following forms are allowed:
 main()
 main(void)
 int main()
 void main()
 void main(void)
 int main(void)
 main() and main(void)
The empty pair of parentheses main()and also the main(void) indicates that the
function has no argument.
 int main()
The statement intmain()indicates that the function returns an integer value to the
operating system.
 void main()
The statement void main() indicates that the function does not return any information
to the operating system.
 void main(void)
The statement void main(void) indicates that the function does not return any
information to the operating system and it has no argument.
4
 int main (void)
The statement intmain(void) indicates that the function returns an integer value to the
operating system and it has no argument.
4. Describe the purpose of #define and #include directive. Why
should not these directive end with a semicolon?
Ans: The #define Directive
A #define is a preprocessorcompiler directive and not a statement. Therefore
#define line should not end with a semicolon. Symbolic constants are generally
written in uppercaseso that they are easily distinguished from lowercase variable
names. #define instructions are usually placed at the beginning before the main()
function. Symbolic constants are not declared in declaration section.
The #include Directive
As mentioned earlier, C programs are divided into modules or functions. Some
functions are written by users, like us and many others are srored in the C library.
Library Functions are grouped category-wise and stored in different files known as
header files. If we want to access the functions stored in the library. It is necessary
to tell the compiler about the files to be accessed.
This is achieved by using the preprocessordirective #include as follows:
#include<filename>
filenameis the name of the library file that contains the required function
definition. Preprocessordirective are placed at the beginning of a program.
5. Draw a flow chart that shows the process of compiling and
running a C program.
Ans: The process of compiling and running a C program is given in Fig 4.
5
System ready
Program code Enter program
Source code
Edit source program
C compiler Compile source program
Yes
No Object code
System
library
Link with the system library
Executable object code
Input data Execute object code
Data errors Logic errors
No errors
Correct output
Srop
Fig 4: Process of Compiling And Running A C Program.
6. What is a tri-graph character? How are they useful?
Ans: Many non-English keywords do not support some special character. To
overcome this program, Table 1. ANCI C introduces the conceptof “tri-graph”
sequences to provide a way to enter certain characters that are not available in some
keyboards, each characters are known as “tri-graph” character. Table 2 shows the
trigraph character.
Syntax errors?
Logic & data
error
6
Letters Digits
Uppercase A….Z All decimal digits 0….9
Lowercase a….z
Special Characters
, comma & ampersand
. period ^ caret
; semicolon * asterisk
: colon - minus
? question mark + plus sign
‘ apostrophe < opening angle bracket(or less than
sign)
“ quotation mark > closing angle bracket(or greater than
sign)
!exclamation mark ( left parenthesis
/ slash ) right parenthesis
 backslash [ left bracket
~ tilde ] right bracket
_ under score { left brace
$ dollar sign } right brace
White Spaces
Blank space
Horizontal tab
Carriage return
New line
Table 1: C Character Set
Table 2: ANSI C Tri-graph Sequences
Tri-graph sequence Translation
??= # number
??( [ left bracket
??) ] right bracket
??< { left brace
??> } right brace
??! | vertical bar
??/  back slash
?? ^ caret
??- ~ tilde
6. What are the rules for declaring identifiers?
Ans: An identifier is a name. It can be the name of a variable, function, a structure
or union, a member of a struct, union or enum, a typedef name, a macro name or a
macro variable.
Example:
Sum, toal_marks,sub1, sub2.
7
Rules for Declaring an Identifier
 Identifier name must be a sequence of letter and digits and must begin with a
letter.
 The underscorecharacter (‘_’) is considered as letter.
 Names shouldn’t be a keyword (such as int, float, if, break, for etc).
 Both upper-case letter and lower-case letter characters are allowed.
However, they’re not interchangeable.
 No identifier may be keyword.
 No special characters, such as semicolon, period, blank space, slash or
comma are permitted.

More Related Content

PDF
Javanotes
PPTX
Octet rule, lewis structure and formal charge (NOCB)
DOCX
Instrumentation Lab. Experiment #4 Report: Op-Amps: Integrator, Differentiato...
PPTX
Electronegativity and bonding
PPTX
Naming compounds given their formula
PPTX
Bipolar Junction Transistor
PPTX
Basic Structural Modeling
PPT
Unijunction transistor (ujt)
Javanotes
Octet rule, lewis structure and formal charge (NOCB)
Instrumentation Lab. Experiment #4 Report: Op-Amps: Integrator, Differentiato...
Electronegativity and bonding
Naming compounds given their formula
Bipolar Junction Transistor
Basic Structural Modeling
Unijunction transistor (ujt)

What's hot (20)

PPTX
INTEGRAL TEST, COMPARISON TEST, RATIO TEST AND ROOT TEST
PPTX
Water Level Indicator Project Presentation
PPTX
Functions in python slide share
PPT
Frequency Meter : Working principle
PDF
L6 triac & diac
PDF
100 point score and activities
PDF
Water Level Indicator.pdf
PPT
Use Case Modeling
PPTX
Construction & E.M.F. eqn. of transformer
PPSX
Presentation on bjt configuration
PDF
Vacuum gauges explained
PPTX
Constructor and destructor in oop
PDF
Oose lab notes
PPTX
Functions and Modules.pptx
PPTX
C++ Overview PPT
PPTX
Function in C program
PPTX
Object oriented programming
PPT
Resonance in electrical circuits – series resonance
PPT
User Defined Functions
PDF
Algorithmic problem solving
INTEGRAL TEST, COMPARISON TEST, RATIO TEST AND ROOT TEST
Water Level Indicator Project Presentation
Functions in python slide share
Frequency Meter : Working principle
L6 triac & diac
100 point score and activities
Water Level Indicator.pdf
Use Case Modeling
Construction & E.M.F. eqn. of transformer
Presentation on bjt configuration
Vacuum gauges explained
Constructor and destructor in oop
Oose lab notes
Functions and Modules.pptx
C++ Overview PPT
Function in C program
Object oriented programming
Resonance in electrical circuits – series resonance
User Defined Functions
Algorithmic problem solving
Ad

Similar to C programming languag for cse students (20)

PPTX
chapter 1.pptx
PPTX
Unit-2_Getting Started With ‘C’ Language (3).pptx
PPTX
Basics of C Lecture 2[16097].pptx
PPTX
Introduction to C which deals with the basics of C
PPTX
Unit-1 (introduction to c language).pptx
PDF
C Programming Language Introduction and C Tokens.pdf
DOCX
Uniti classnotes
DOCX
UNIT 1 NOTES.docx
PDF
Introduction of c language
PPTX
C Programming UNIT 1.pptx
PPTX
C lang7age programming powerpoint presentation
PPT
Chapter-2 edited on Programming in Can refer this ppt
PPTX
PROGRAMMING IN C - SARASWATHI RAMALINGAM
DOCX
Chapter 3(1)
PDF
C PADHLO FRANDS.pdf
PPTX
UNIT 5 C PROGRAMMING, PROGRAM STRUCTURE
PDF
Introduction to C programming
PPTX
Introduction%20C.pptx
PPTX
structure of a c program - slideshare.pptx
PDF
C PROGRAMMING p-2.pdf
chapter 1.pptx
Unit-2_Getting Started With ‘C’ Language (3).pptx
Basics of C Lecture 2[16097].pptx
Introduction to C which deals with the basics of C
Unit-1 (introduction to c language).pptx
C Programming Language Introduction and C Tokens.pdf
Uniti classnotes
UNIT 1 NOTES.docx
Introduction of c language
C Programming UNIT 1.pptx
C lang7age programming powerpoint presentation
Chapter-2 edited on Programming in Can refer this ppt
PROGRAMMING IN C - SARASWATHI RAMALINGAM
Chapter 3(1)
C PADHLO FRANDS.pdf
UNIT 5 C PROGRAMMING, PROGRAM STRUCTURE
Introduction to C programming
Introduction%20C.pptx
structure of a c program - slideshare.pptx
C PROGRAMMING p-2.pdf
Ad

Recently uploaded (20)

PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Cell Structure & Organelles in detailed.
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
RMMM.pdf make it easy to upload and study
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Final Presentation General Medicine 03-08-2024.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
O7-L3 Supply Chain Operations - ICLT Program
Anesthesia in Laparoscopic Surgery in India
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Cell Structure & Organelles in detailed.
GDM (1) (1).pptx small presentation for students
Pharmacology of Heart Failure /Pharmacotherapy of CHF
RMMM.pdf make it easy to upload and study
Final Presentation General Medicine 03-08-2024.pptx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
VCE English Exam - Section C Student Revision Booklet
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Microbial diseases, their pathogenesis and prophylaxis
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
202450812 BayCHI UCSC-SV 20250812 v17.pptx
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx

C programming languag for cse students

  • 1. 1 C Programming Language Group A 1. What is Programming Language? What down some salient features of C Programming Language? Ans: Computer Programming is simply writing down instructions for the computer to follow. For stating the instructions, we need some language in which to state the instructions. Unfortunately nature language such as English is insufficiently precise for giving instructions to computers. Instead, we use special purpose languages called programming Language. Thus programming Dan be defined as process of writing, testing, debugging/troubleshooting and maintaining the source code of computer programs. Salient Features of C Programming  C is a general purpose language i.e. it can be used for any type of programming solution.  It is a structured programming, so it provides a disciplined approach to write the program.  It has high level constructs, which gives users the programming efficiency.  It can handle low level language, which gives the machine efficiency.  It has a rich set of built-in functions and operators that can be used to write any complex program.  Program written in C are efficient and fast due to its variety of data types and powerful operators. 2. What is C token? Explain the basic structure of a C program? Ans: Individual word and punctuation marks are called C tokens. In a C program the smallest individual units are known as C tokens. C has six types of tokens as shown in Fig 2. C Token Keyword Identifier Constant String Special Symbol Operator Fig 1: C Token.
  • 2. 2 Basic Structure of C Program The basic structure of C is given in Fig 2. Documentation section Link section Definition Section Global declaration section main() function section { Declaration part Executable } Sub program section function 1 function 2 ……………. Fig 2: basic Structure of C program  DocumentationSection  It is set of Computer Line  It includes Title Of Program, Author Name  Data Used Or Summary Information  Link Section  It is also called Header File Declaration Section  It Links Compiler to Link Functions From System Library  Definition Section  Defines Symbolic Constants  Eg. #define Count 10  Global DeclarationSection  Variable that are accessed byone or more functions are called Global Variable  Global Variables are declared in this Section.  Global Variables are always Declared outside of all Functions  May Contain Function Definition  Main Function Section  User to start of actual C program.  It include two parts as declaration part and executable part.  Sub ProgramSection  It has all User-defined Functions that are called in main  User Defined Functions are generally placed immediately after main
  • 3. 3 3. Write down the steps of executing a C program. What are the different forms of main statements C permits? Ans: C program executes in 4 (four steps). This is given in Fig 3. Create program Compile program Link program Execute program Fig 3: Executing of a C Program  Creating a program An editor like notepad or WordPad is used to create a C program. This file contains a sourcecodewhich consists of executable code. The file should be saved as ‘*.c’ extension only.  Compiling the program The next step is to compile the program. The codeis compiled by using compiler. Compiler converts executable codeto binary codei.e. object code.  Linking a program to library The object codeof a program is linked with libraries that are needed for execution of a program. The linker is used to link the program with libraries. It creates a file with ‘*.exe’extension.  Executing the program The final executable file is then run by dos command prompt or by any other software. Different Forms of main() Statement C permits different forms of main statement. The following forms are allowed:  main()  main(void)  int main()  void main()  void main(void)  int main(void)  main() and main(void) The empty pair of parentheses main()and also the main(void) indicates that the function has no argument.  int main() The statement intmain()indicates that the function returns an integer value to the operating system.  void main() The statement void main() indicates that the function does not return any information to the operating system.  void main(void) The statement void main(void) indicates that the function does not return any information to the operating system and it has no argument.
  • 4. 4  int main (void) The statement intmain(void) indicates that the function returns an integer value to the operating system and it has no argument. 4. Describe the purpose of #define and #include directive. Why should not these directive end with a semicolon? Ans: The #define Directive A #define is a preprocessorcompiler directive and not a statement. Therefore #define line should not end with a semicolon. Symbolic constants are generally written in uppercaseso that they are easily distinguished from lowercase variable names. #define instructions are usually placed at the beginning before the main() function. Symbolic constants are not declared in declaration section. The #include Directive As mentioned earlier, C programs are divided into modules or functions. Some functions are written by users, like us and many others are srored in the C library. Library Functions are grouped category-wise and stored in different files known as header files. If we want to access the functions stored in the library. It is necessary to tell the compiler about the files to be accessed. This is achieved by using the preprocessordirective #include as follows: #include<filename> filenameis the name of the library file that contains the required function definition. Preprocessordirective are placed at the beginning of a program. 5. Draw a flow chart that shows the process of compiling and running a C program. Ans: The process of compiling and running a C program is given in Fig 4.
  • 5. 5 System ready Program code Enter program Source code Edit source program C compiler Compile source program Yes No Object code System library Link with the system library Executable object code Input data Execute object code Data errors Logic errors No errors Correct output Srop Fig 4: Process of Compiling And Running A C Program. 6. What is a tri-graph character? How are they useful? Ans: Many non-English keywords do not support some special character. To overcome this program, Table 1. ANCI C introduces the conceptof “tri-graph” sequences to provide a way to enter certain characters that are not available in some keyboards, each characters are known as “tri-graph” character. Table 2 shows the trigraph character. Syntax errors? Logic & data error
  • 6. 6 Letters Digits Uppercase A….Z All decimal digits 0….9 Lowercase a….z Special Characters , comma & ampersand . period ^ caret ; semicolon * asterisk : colon - minus ? question mark + plus sign ‘ apostrophe < opening angle bracket(or less than sign) “ quotation mark > closing angle bracket(or greater than sign) !exclamation mark ( left parenthesis / slash ) right parenthesis backslash [ left bracket ~ tilde ] right bracket _ under score { left brace $ dollar sign } right brace White Spaces Blank space Horizontal tab Carriage return New line Table 1: C Character Set Table 2: ANSI C Tri-graph Sequences Tri-graph sequence Translation ??= # number ??( [ left bracket ??) ] right bracket ??< { left brace ??> } right brace ??! | vertical bar ??/ back slash ?? ^ caret ??- ~ tilde 6. What are the rules for declaring identifiers? Ans: An identifier is a name. It can be the name of a variable, function, a structure or union, a member of a struct, union or enum, a typedef name, a macro name or a macro variable. Example: Sum, toal_marks,sub1, sub2.
  • 7. 7 Rules for Declaring an Identifier  Identifier name must be a sequence of letter and digits and must begin with a letter.  The underscorecharacter (‘_’) is considered as letter.  Names shouldn’t be a keyword (such as int, float, if, break, for etc).  Both upper-case letter and lower-case letter characters are allowed. However, they’re not interchangeable.  No identifier may be keyword.  No special characters, such as semicolon, period, blank space, slash or comma are permitted.