C Programming language

C Standard Library Function

Day 1: Introduction and brief history of C Programming language

Day 1: Advantages and Disadvantages of C, C Keywords, Data type modifiers in C

Day 1: Data types in C Programming language

Day 1: Secondary data types, Primitive and Non-primitive data types

Day 1: C Variables, C Constant, Format Specifiers in C

Day 2: Write first C program

Day 2: Flow of C program with example, main(), printf(), scanf()

Day 2: Operaters in C Programming language, Arithmetic operators

Day 2: Relational operators and Logical Operators in C Programming language

Day 2: Assignment, Increments and Decrement Operators in C Programming language

Day 3: Conditional statement: if else statement in C Programming language

Day 3: Conditional statement: switch statement in C Programming language

Day 3: Jump statements: return statement in C Programming language

Day 3: Jump statements: go to statement in C Programming language

Day 3: Jump statements: break statement in C Programming language

Day 3: Jump statements: continue statement in C Programming language

Day 4: Loops OR Iteration statement in C Programming language: for Loop

Day 4: Loops OR Iteration statement in C Programming language: while Loop

Day 4: Loops OR Iteration statement in C Programming language: do while Loop

Day 5: Array in C Programming language

Day 5: Access elements of Array in C Programming language

Day 5: One dimensional Array representation in memory using C Programming language

Day 5: Two dimensional Array representation in memory using C Programming language

Day 5: Multidimensional Array in C Programming language

Day 6: Function in C Programming language

Day 6: Definition, Declaration and Calling a Function in C Programming language

Day 6: Passing array to a function in C Programming language

Day 6: Calling Function in C Programming language : Call by value

Day 6: Calling Function in C Programming language : Call by reference

Day 6: Recursive Function in C Programming language

Day 6: Adding function to the library in C Programming language

Day 7: Pointer in C Programming language, How to use Pointer, Pointer declaration

Day 7: NULL Pointers in C Programming language

Day 7: Array of Pointers in C Programming language

Day 7: Pointer arithmetic in C Programming language

Day 7: Pointer to Pointer in C Programming language

Day 7: Pointer to Function in C Programming language: Passing pointers to functions

Day 7: Pointer to Function in C Programming language: Return pointer from functions

Day 8: Strings in C Programming language, Declaring String in C Programming language

Day 8: String functions in C Programming language

Introduction of Structure

Accessing the members of Structure

Structure With typedef Keyword and Use of sizeof function

Example of Structure

Dynamic memory allocation in C: Introduction

adplus-dvertising
Day 2 Operaters in C Programming language, Arithmetic operators
Previous Home Next

An operator is a symbol which helps the user give the command to computer, and computer to do a certain mathematical or logical manipulations. Operators are used in C language program to operate on data and variables. C has a rich set of operators which can be classified as:

  1. Arithmetic operator
  2. Relational Operators
  3. Logical Operators
  4. Assignment Operators
  5. Increments and Decrement Operators
  6. Conditional Operators
  7. Bitwise Operators
  8. Special Operators
Arithmetic Operators

Arithmetic operators means do the all arithmetic operations like as addition, subtraction, multiplication , division, modules etc. All the operators have almost the same meaning as in other languages. Both unary and binary operations are available in C language. Unary operations operate on a singe operand, therefore the number 5 when operated by unary will have the value 5.

OperatorMeaning
+Addition or Unary Plus
Subtraction or Unary Minus
*Multiplication
/Division
%Modulus Operator

Example

#include<stdio.h>//include header file stdio.h 
void main()//tell the compiler the start of the program 
{ 
int numb1, num2, sum, sub, mul, div, mod;//declaration of variables 
scanf (%d %d, &num1, &num2); //inputs the operands 
sum = num1+num2; //addition of numbers and storing in sum. 
printf(\n Thu sum is = %d, sum);//display the output
sub = num1-num2;//subtraction of numbers and storing in sub. 
printf(\n Thu difference is = %d, sub);           //display the output 
mul = num1*num2;//multiplication of numbers and storing in mul. 
printf(\n Thu product is = %d, mul);              //display the output 
div = num1/num2;//division of numbers and storing in div. 
printf(\n Thu division is = %d, div);             //display the output 
mod = num1%num2;//modulus of numbers and storing in mod. 
printf(\n Thu modulus is = %d, mod);              //display the output 
}

Integer Arithmetic

When an arithmetic operation is performed on two whole numbers or integers than such an operation is called as integer arithmetic. It always gives an integer as the result.

Let x = 20 and y = 5 be 2 integer numbers. Then the integer operation leads to the following results.

x+y=27
xy=15
x*y=100
x%y=0
x/y=4 

* In integer division the fractional part is truncated.

Floating point arithmetic

When an arithmetic operation is preformed on two real numbers or fraction numbers such an operation is called floating point arithmetic. The floating point results can be truncated according to the properties requirement. The remainder operator is not applicable for floating point arithmetic operands.

Let x=14.0 and y=4.0 
then 
x+y=18.0 
xy=10.0 
x*y=56.0 
x/y=3.50 

Mixed mode arithmetic

When one of the operand is real and other is an integer and if the arithmetic operation is carried out on these 2 operands then it is called as mixed mode arithmetic. If any one operand is of real type then the result will always be real thus 15/10.0 = 1.5

Previous Home Next