![]() |
What is C ?
C programming language is the basic and first level procedural oriented programming language. Those who want to learn programming C language is the perfect platform to begin with. It was designed by Dennis Ritchie in the year 1969 and 1973 . C language is a mid level programming language which is widely used in developing applications like system software, application software , embedded software, mobile applications and etc. It was introduced mainly because to write system level programming and code for operating systems.
The C Character Set
Alphabets A,B,………………………Z;a,b,……………………….z
Digits 0,1,2,3,4,5,6,7,8,9
Special symbols ! @ # % ^ & * ( ) _ – + = | \{ }, [ ], < > ” , ? / .
Digits 0,1,2,3,4,5,6,7,8,9
Special symbols ! @ # % ^ & * ( ) _ – + = | \{ }, [ ], < > ” , ? / .
‘C ‘ Tokens:
In ‘C’ program the smallest individual units are called as tokens.
There are six types of tokens:
1. Identifiers.
2. Keywords
3. Constants
4. Strings
5. Operators
There are six types of tokens:
1. Identifiers.
2. Keywords
3. Constants
4. Strings
5. Operators
C Keywords
Keyword are the words whose meaning has already been explained to the C Compiler. There are only 32 keywords available in C.
auto | break | Case | Char | Const | continue |
default | do | double | else | enum | extern |
float | for | goto | if | int | long |
register | return | short | signed | sizeof | static |
struct | switch | typedef | union | unsigned | void |
volatile | while |
Calculation of simple interest..
#include<stdio.h>
int main()
{
int p,n;
float r,s;
p=1000;
n=3;
r=8.5;
/*formula of simple interest */
s=p*n*r/100;
printf("%f\n",s);
return 0;
}
Let us understand in detail this program..
There are some certain rules must be use in C .
a) Each instruction in C program indicate how it has to be written as a separate statement .b) The statement in a program must appear in the same order in which we wish them to be executed.
c) Blank space may be inserted between two words to improve the readability of the statement .
d) All statement should be in lower case latter.
e) C has no specific rules for the position at which a statement is to be written in a given line.
f) Every C statement must be end with a semicolon (;). Thus ; acts as a statement terminator.
What is main()
When the operating system runs a program in C, it passes control of the computer over to that program. This is like the captain of a huge ocean liner handing you the wheel. Aside from any fears that may induce, the key point is that the operating system needs to know where inside your program the control needs to be passed. In the case of a C language program, it’s the main() function that the operating system is looking for.
What is printf()
printf() i a library function defined under stdio.h header file. this function is used to print something in the console. this function is a integer type function which means this function returns an integer to the caller function. printf() returns the number of characters it has printed in the console.
so,
printf("5");
here printf() will return 1 as printf() is printing only one character (5). we can use different fromat specifier to print different data types in different format,i.e. in exponential format,integer format,character format.
Let so,
printf("5");
here printf() will return 1 as printf() is printing only one character (5). we can use different fromat specifier to print different data types in different format,i.e. in exponential format,integer format,character format.