C PROGRAMMING
SEMESTER:- 2nd semester
SUBJECT:-COMPUTER APPLICATION
PREPARED BY :- A.P. Mohanty
Dept. of Science & Humanities
Introduction
Why Name 'C' was given to this
language?
ABOUT “C”
breaking large file into smaller modules
- Structured and disciplined approach to
program design.
Structure Of “C” Programs
C's Character Set
C does not use every character set and key found on
modern computers . The only characters that C - Language uses for its programs are as follows:
✔ + - / * =
The keywords
Basic Structure Of “C” Programs
#include<stdio.h> #include<conio.h>
void main()
{
-- other statements
}
Header Files
Indicates Starting of Program
Entry Point Of Program
Header files
Main function
Running a ‘C’ Program
“C” language TOKENS
Strin gs
Keywords in Ansi “C”
auto | double | register | switch |
break | else | return | typedef |
case | enum | short | union |
char | etern | signed | unsigned |
const | float | sizeof | void |
continue | for | static | volatile |
default | goto | struct | while |
do | if | int | long |
The Identifiers
sensitive)
Constants
CONSTANTS
Numeric constants
Character constants
Integer
Constants
Real Constants
Single Character
Constants
String
Constants
Constants Examples
DECLARATIONS
name and possibly the initial value of the
variable.
What Are Variables in C?
x = a + b
z + 2 = 3(y - 5)
Naming Variables
Case Sensitivity
area Area AREA
ArEa
are all seen as different variables by the compiler.
Declaring Variables
variable.
float area ;
int sum;
the value of the variable sum can be anything (garbage).
declared.
Data types in ‘ansi c’
Data Types- different attributes
Type | Size | Representation | Minimum range | Maximum range |
char, signed char | 8 bits | ASCII | -128 | 127 |
unsigned char | bool 8 bits | ASCII | 0 | 255 |
short, signed short | 16 bits | 2's complement | -32768 | 32767 |
unsigned short | 16 bits | Binary | 0 | 65535 |
int, signed int | 16 bits | 2's complement | -32768 | 32767 |
unsigned int | 16 bits | Binary | 0 | 65535 |
long, signed long | 32 bits | 2's complement | -2,147,483,648 | 2,147,483,647 |
unsigned long | 32 bits | Binary | 0 | 4,294,967,295 |
float | 32 bits | IEEE 32-bit | 1.175495e-38 | 3.4028235e+38 |
double | 32 bits | IEEE 32-bit | 1.175495e-38 | 3.4028235e+38 |
long double | 32 bits | IEEE 32-bit | 1.175495e-38 | 3.4028235e+38 |
Example of “C” Program
/* HELLO.C -- Hello, world */
#include <stdio.h> Void main()
{
printf("Hello, world\n");
Getch();
}