Professional Documents
Culture Documents
And
‘C’ Program.
Why ‘C’ ?
‘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 Program.
Symbols.
Constants,
Variables,
And Instructions
Keywords
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.
e.g. 488.22 +3.211e-4
+85.23 5.6e4
-11.20
Data types declaration.
• 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