2. What is C
C is a programming language
High-level programming language.
General purpose programming languages.
Advantages:
Readability: Programs are easy to read.
Maintainability: Programs are easy to maintain.
Portability: Programs are easy to port across different
computer platforms.
4/17/2015
3. Writing First C Program
The basic C program Contains
The #include directive
Comments
The main() function
The return statement
The newline character (n)
4/17/2015
4. Simple C Program
/*This is my 1st pgm*/ comment The C compiler ignores
comment. The purpose of comments is used to know what the
program do.
#include <stdio.h> include information about standard
library
main() define a function called main
that received no argument values
{ statements of main are enclosed in braces
printf("hello, worldn"); main calls library function printf
to print this sequence of characters.
n represents the newline character
}
4/17/2015
5. The main() Function
This is a very special function in C. Every C program
must have a main() function, and every C program
can only have one main() function.
The execution of your program always starts with the
main( ) function.
4/17/2015
6. Structure of a C Program
The essentials of C program
Expressions
Constants and variables
Statements
Statement blocks
C function types and names
Arguments to functions
The body of a function
Function calls
4/17/2015
7. Contd..,
Expressions: An expression is a combination of
constants, variables, and operators that are used to
denote computations.
Constants and Variables: As its name implies, a
constant is a value that never changes. A variable, on
the other hand, can be used to present different values.
Statements: A statement is a complete instruction,
ending with a semicolon.
4/17/2015
8. Contd..,
Statement Blocks: A group of statements can form a
statement block that starts with an opening brace ({)
and ends with a closing brace (}). A statement block is
treated as a single statement by the C compiler.
C Function: Functions are the building blocks of C
programs. Besides the standard C library functions,
you can also use some other functions made by you or
another programmer in your C program.
4/17/2015
9. Data Types and Keywords
Four data types of the C:
char data type single character
int data type used to specify the type of a variable
as an integer.
float data typefloating-point number contains a
decimal point.
double data typefloating-point number is of at
least 10 digits of precision4/17/2015
10. C Keywords
The C language reserves certain words that have
special meanings to the language. Those reserved
words are sometimes called C keywords.
You should not use the C keywords for your own
variable, constant, or function names in your
programs.
4/17/2015