You are on page 1of 20

C Language

And
C Program.

Why C ?

Implements basic programming languages

concepts.
Structured programming language.
Developments of other PL requires core C
elements.
Unix, Linux and Windows in C.
Cellular phones and palmtop softwares.
Gaming frameworks.
Hardware devices interaction with max
performance.

Alphabets,
Digits,
Special
Symbols.

Program.

Constants,
Variables,
And
Keywords

Instructions

C Constants.
Primary Constants.

Integer Constants.
Real Constants.
Character Constants.
Secondary Constants.
Array.
Pointer.
Structures and Unions.
Enum.

Integer Constants.

e.g. 426
+756
-588 etc.
Character Constants.
e.g. E
h
=
8
Real Constants.
+3.211e-4
e.g. 488.22
5.6e4
+85.23
-11.20

Data types declaration.


int a; /* General declaration */
int a = 10; /* Valued Declaration */
float b = 12.6;
float b;
char c;
char c = y;

Maximum values of Data Types.


int requires 2 bytes to store in memory.

-32768 to 32767.
float requires 4 bytes to store.
-3.4e38 to 3.4e38.
char requires 1 byte to store.
A.Z and a.z also special symbols.
long int requires 4 bytes to store.
-2147483648 to 2147483647.
double requires 8 bytes to store.
-1.7e308 to 1.7e308.
long double requires 10 bytes to store.
-1.7e4932 to 1.7e4932.

Giving variable names (identifiers).


C is a case-sensitive language.
means a A.
All the alphabets are allowed.
All numbers are allowed but not at the
start.
e.g char a9, thyy; /* Valid */
char 5abc; /* Invalid */
Only special symbol _ (under score) is
allowed. e.g. int min_max;

Keywords.
auto
continue
enum
if
signed
typedef
volatile

break
default
extern
long
sizeof
union
near

case
do
float
register
static
unsigned
far

char
double
for
return
struct
void
asm

const
else
goto
short
switch
while

Operators.
Numerial operators.
Logical operators.
Relational operators.
Conditional operators.
Bitwise operators.

Numerical operators.
+
*
/
% =
--------------------------------------------e.g. int a, y = 10, x = 12;
float b;
a = y + 10;
b = x / 2;
a = a b;

Relational operators.
>

<

>= <=

==

!=

Logical operators.
&& ||

Conditional operators.
?

Boolean operators.
&

Expression and Statements.


int a = 10, j = 26;
float r = 5.22, t = 2.66 + 45.2 * 2;
float b = 1.02 , c = b / 2 + 5.2;
int d, e, f, g;
d = e = f= g = 50;
float alpha = 23.001, beta = 892.00;
float delta = alpha * beta / 3.2 alpha;
char h, i ;
h = D;
I = h;

Hierarchy of operations.
int i;
i = 5 * 6 8 + 9 (43 + 2) /5 5;
i = 30 8 + 9 45/5 5;
i = 30 8 + 9 9 5;
i = 22 + 0 5;
i = 17;

First C Program.
#include<stdio.h>
main()
{
int i = 10, j = 12;
float k, m = 12.6;
k = (i + j) / m;
printf(Input : %d %d %f, i, j, m);
printf(\nOutput : %f , k);
}
Input : 10 12 12.600000
Output : 1.746032

Basic I/O statements.


printf.
printf(<formal string>,<list of variables>);
e.g. printf(Hello world);
int i = 15;
printf(Value of i is : %d, i );

%d integer value.
%f float value.
%c character value

printf(%d %d %d, 3, 3+5, a+b*c);

Basic I/O statements.


scanf.
It accepts values from user in the form of
int / float / char / long / double.
e.g. int j,
char m;
float k;
scanf(%d%f%c, &j, &k, &m);

Compilation and Execution


Integrated Development Environment
(IDE).
editor + compiler.
Compiling C program
F9 / Alt F9 Compiling.
Ctrl F9 Executing.
Alt F5 Watching output.

Created By,
Mr. Tushar B Kute,
Lecturer in Information Technology,
K. K. Wagh Polytechnic, Nashik.
tbkute@gmail.com

You might also like