float b = 7.333;
printf("%8.4f\n",b);
//This is print 7.3330 with 8 character space and 4 decimal places.
☆ %c → prints character
☆ %d → prints interger
☆ %s → prints string
☆ %f → prints decimal numbers
☆ %l → prints long
☆ %lf → prints double
☆ %Lf → prints long double
//const keyword
#include <stdio.h>
int main()
{
const float b = 7.333;
b= 5.5;
return 0;
}
//error: assignment of read-only variable 'b'.
//This means that we cannot reassign value to a const variable.
//#define preprocessor
#include <stdio.h>
#deine PI 3.14
int main()
{
printf("%f",PI);
// prints 3.14000
return 0;
}
//There is no need to use ';' here.
☆ \t → Horizontal tab (space)
☆ \r → Vertical Tab
☆ \a → Alarm or Beep (Produces windows sound effect)
☆ \b → Backspace
☆ \f → Form Feed
☆ \n → New Line
☆ \r → Carriage Return
☆ \\ → Backslash
☆ \' → Single Quote
☆ \" → Double Quote
☆ \? → Question Mark
☆ \nnn → Octal Number
☆ \xhh → Hexadecimal Number
☆ \0 → Null
If we want some description of function that we are using in our programs then we can use comments to specify the function work.
The preprocessor removes all the comments and compresses the program code.
☆ single line comment → // this is single line comment.
☆ multi line comment → /* this is multi line comment
this is multi line comment */