Programming in C UNIT1
Programming in C UNIT1
⮚ Overview of C
⮚ History and features of C
⮚ Structure of C program
⮚ Creating and executing a C program
⮚ Compilation process in C
Basic structure of C
Creating and Executing a C program
• Stage 2 Preprocessor
• Stage 3 Compiler
Linker
• Stage 4
Loader
• Stage 5
Execution
• Stage 6
Unit 1 :
C Programming Basic Concepts
• Introduction
• C Character Set
• Tokens
• Keywords
• Identifiers
• Constants
• Variables
• Data Types
• Declaration of Variables
• Assigning Values to Variables
• Defining Symbolic Constants
• Defining Variables as a Constant
2. C Programming Basic Concepts
• Introduction
English C Language
Words and
Numbers Constants, Variables, Operators, Keywords
Paragraphs Programs
add,
6. The maximum length of an identifier is 31 characters
Constants
Primary Secondary
Array,
Numeric Character Structure,
Pointer,
Union,
Enum etc
Integer Real Single String
Character
INPUT AND OUTPUT WITH C
Description
S NO. Format Specifier Type
getch() function reads a single character from the from the keyboard by the user but doesn’t display that character on the
console screen and immediately returned without pressing enter key.
This function is declared in conio.h(header file). getch() is also used for hold the
screen.
Syntax:
getch();
or
variable-name = getch();
getche():
getche() function reads a single character from the keyboard by the user and displays it on the console screen and
immediately returns without pressing the enter key. This function is declared in conio.h(header file).
getchar():
The getchar() function is used to read only a first single character from the keyboard
whether multiple characters is typed by the user and this function reads one character at
one time until and unless the enter key is pressed. This function is declared in
stdio.h(header file)
putchar():
The putchar() function is used to display a single character at a time by passing that
character directly to it or by passing a variable that has already stored a character. This
function is declared in stdio.h(header file)
gets():
gets() function reads a group of characters or strings from the keyboard by the user and these characters get stored
in a character array. This function allows us to write space-separated texts or strings. This function is declared in
stdio.h(header file).
Syntax:
char str[length of string in number]; //Declare a char type variable of any length
gets(str);
puts():
In C programming puts() function is used to display a group of characters or strings which is already stored in a
character array. This function is declared in stdio.h(header file).
Syntax:
puts(identifier_name );
putch():
putch() function is used to display a single character which is given by the user and that character prints at the
current cursor location. This function is declared in conio.h(header file)
Syntax:
putch(variable_name);
Formatted I/O vs Unformatted I/O
These functions allow us to take input These functions do not allow to take
1 or display output in the user’s desired input or display output in user desired
format. format.
These are used for storing data more These functions are not more user-
3
user friendly friendly.
printf(), scanf, sprintf() and sscanf() are getch(), getche(), gets() and puts(), are
5
examples of these functions. some examples of these functions.