Newline operator:
It is a formatting operator used to make the text appear on new line
It is always used between "&".
Printf() and scanf() functions:
When we calculate something say a particular sum or if we need to display something in the screen then we use printf () function.
To use this function we need to include <stdio. h> file first to use both functions.
General format of printf is
Printf("<format strings>", <list of variables>) ;
Format strings contain some format specifiers like given below:
%f for printing real value.
%d for printing integer values
%c for printing character value.
Let's understand the use through the code:
We are converting rupees into dollars
![]() |
source code |
![]() |
Output. |
Printf can not only print values of variables but it can also print results of an expression but using these expressions is optiional.
See the code below to get the idea.
![]() |
Output |
& operator :
It is 'address of ' operator and it tells the compiler the location of memory to store the value assigned to the variable.
Scanf() function:
To make any program more general. We should be able to enter values of variables more than one time as per our choice. So scanf() comes to serve us over here.
Format of scanf is as same as that of printf
Let's understand its use through the code below
![]() |
Source code to input values of a and c from user |
![]() |
Code is asking user to input values |
Conclusions:
1. U learnt about newline operator
2. U learnt in depth about printf and scanf functions.
Did u find c language easy ??
Was it helpful?
Comments
Post a Comment