Skip to main content

C tutorial #lecture4



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


Values fed by user. 

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

Popular posts from this blog

Python tutorial - #6 (Control statements)

Control Statements When we write a simple program, generally it executes line by line and this execution are called sequential execution. This type of execution is suitable only for developing simple programs. It is not suitable for developing complex programs. To develop a program which contains complex logic. Then we need to execute statements according to our requirement for this we uses Control statements in which we can control the statements according to our need.  ➠ There are types of control statements in Python:- a) If... statements b) If... else.. Statements c) If...elif....else.. Statements  d) While loop  e) For loop f) Nested loop  g) Else suit h) Continue statements  i) Break statements j) Pass statements  k) Assert statements l) Return statements  ↷If... statements    Syntax:-  if condition:                 Statements Here, at first...

Control structures in c #part 1 ( if statement)

The control strucures are the statements that are used to alter the flow or sequence of excecution of program.  There are basically two types of control strucures:                   1. Decision making statements a) if statement          b) if -else statement          c) switch statement 2. Loop constructs: a) for loop     b) while loop           c) do-while loop We will also study about break, continue and go to in subsequent lectures Here we will cover if statement.  Firatly u need to know the symbols for various conditions they are called relational operators.  1. ==  means here "equal to " 2. <= means here "less than Or equal to" 3. >= means here "greater than Or equal to" 4.  ! = means " Not equal to" Now u are euipped  enough to learn loops.  Let's be...

Python tutorial - #5 (Operators in Python)

Membership Operators This operator helps us to check an element is found in a sequence or not. It gives there result in Boolean value (True or False). ➥There are two types of Membership operator :- a) in b) not in ➢in membership operator This membership operator returns True if an element is found in a sequence and it returns  False When an element is not found in a sequence. Program - #1 ➢not in membership operator This membership operator returns True if an element is not found in a sequence and it returns False if an element is found in a sequence. Program = #2 Identity Operators This operator helps us to check whether two element are same or not. Actually, this operator compares the memory location of two object, if the memory locations are same then objects are also same otherwise the objects are not same.                                      ...