C Programming from scratch : C Programming from scratch By Pruthwiraj Ghadge
Why C? : Why C? Design Structure.
Efficiency.
Portability.
Take C home.
Power and Flexibility.
Programmer Oriented
What you need? : What you need? A text Editor
A C compiler
Character Set : Character Set Alphabets [a-z] [A-Z]
Numbers [0-9]
Special Symbols ~ ‘ ! @ # % ^ & * ( ) _ - + = | \ { } [ ] : ; " ' < > , . ? /
Variable, Constant and Keyword : Variable, Constant and Keyword Variable :- An entity which can change in it’s value as per time and requirement.
Constant :- An entity which can not change in it’s value.
Keywords :- A predefined word which has its own meaning.
Types of Constants : Types of Constants Primary Constants
Integer
Float
Character
Secondary Constants
Array
Pointers
Structure
Union
Rules to write constant : Rules to write constant Integer
It must have at least 1 digit.
No decimal point.
Can be positive or negative.
By default positive.
No comma, blank space or special symbol allowed.
Rules to write constant : Rules to write constant Float
It must have at least 1 digit.
Decimal point.
Can be positive or negative.
By default positive.
No comma, blank space or special symbol allowed.
Rules to write constant : Rules to write constant Character
Single alphabet, a single digit or a single special symbol.
It has to be enclosed in a pair of single quotes.
Maximum length of character constant is 1 character.
Rules to write variable : Rules to write variable Any combination of alphabets, digits or an underscore..
Maximum length of variable name can be 31(TC).
Some compilers supports 247 characters long variable name.
First character must be an alphabet or an underscore.
No comma or blank space or any other special symbol other than underscore is allowed.
First Simple Program : First Simple Program #include
int main(void)
{
int num;
num = 1;
printf(“I am a simple ”);
printf(“computer.\n”);
printf(“My favorite number is %d because it is first.\n”,num);
return 0;
}
Structure of C Program : Structure of C Program
A little about printf() : A little about printf() These are two mostly used statements in program.
But these are not statements.
These are functions.
printf() is used to print the output.
As we have seen earlier printf() prints the data that is given to it.
Syntax :-
printf(“message”);
printf(“message + format specifier list”,param1,param2,…);
Questions? : Questions?
Thank You : Thank You