Unit 1 Introduction To C Language
Unit 1 Introduction To C Language
Unit 1 Introduction To C Language
Introduction to
C Language
Introduction to C Language
Background,
C Programs,
Identifiers,
Data Types,
Variables,
Constants, Input / Output Statements
Arithmetic Operators and Expressions: Evaluating Expressions,
Precedence and Associativity of Operators, Type Conversions.
Background
6. Execute Loader
Loader puts program
in memory.
Disk ..
..
..
14
return (0);
}
– A way to exit a function
– return (0) means that the program terminated normally
– Right brace } indicates end of a block (of code)
– Here indicates end of main function has been reached
Comments
– Comments are like helping text in your C program and they
are ignored by the compiler. They start with /* and terminate
with the characters */ as shown below −
– \\ xyz
– /* my first program in C */
15
One feature present in all computer languages is the
IDENTIFIERS
identifier. Identifiers allow us to name data and other
objects in the program. Each identified object in the
computer is stored at a unique address. An identifier is a
name used to identify a variable, function, or any other
user-defined item.
RULES
1.An identifier starts with a letter A to Z, a to z, or an
underscore '_' followed by zero or more letters,
underscores, and digits (0 to 9).
2. There must not be any white space in the string.
3. And, all the subsequent characters after the first
character must not consist of any special characters like $,
Examples of Valid and Invalid Names
Some Strings
Use single quotes for character constants.
Use double quotes for string constants.
• Stdio.h
contains
declaration of
printf( ),
scanf( ),etc.
1. C Output
Example 1 Example 2
2. C Input Example 6: Float and Double Input/Output
gets( ) & puts( ) functions
• The gets() function
reads a line from
stdin(standard input)
into the buffer pointed
to by str pointer, until
either a terminating
newline or EOF (end of
file) occurs. The puts()
function writes the
string str and a trailing
newline to stdout.
Console Input/Output function access the three major files before the execution of a C
Program.
getchar() & putchar() functions