Some basic programs of Operators in c language

What is Operators in c language?

An operator is a symbol that operates on a value or a variable. In operator is simply a symbol that is used to perform operations. There can be many types of operations like arithmetic, logical, bitwise, etc.

There are following types of operators to perform different types of operations in C language.
  • Arithmetic Operators

  • Relational Operators

  • Shift Operators

  • Logical Operators

  • Bitwise Operators

  • Ternary or Conditional Operators

  • Assignment Operator

Arithmetic Operators

1-Write a program of Arithmetic Operaters in C language.

#include <stdio.h>

#include<conio.h>

int main ()

{
int a = 9, b = 4, c;
c = a+b;
printf ("a+b = %d \n",c);
c = a-b;
printf ("a-b = %d \n",c);
c = a*b;
printf ("a*b = %d \n",c);
c = a/b;
printf ("a/b = %d \n",c);
c = a%b;
printf ("Remainder when a divided by b = %d \n",c);
return 0;
}
c operaters, Programming 5 axis cnc, java web services rest, java spring tutorial, java rest api,java point, java virtual machine, java executor framework, java for windows 7, restful  web services java, java web services soap, java 8 download, programming game ai by example, programming questions in java, programming quotes, programming for problem solving, programming with mosh, programming near me, programming in visual basic, programming python pdf, programming r, programming aptitude test, c program to find sum of n numbers using for loop, c program to find sum of n numbers using function, sum of numbers from 1 to 100 in c, c program for sum of two numbers, c program to find multiples of a number, c program to find sum of n numbers using array, c program to find sum of 10 numbers using function, how to find multiples of a number in c++,
Operaters in c language

Output:-
a+b = 13
a-b = 5
a*b = 36
a/b = 2
Remainder when a divided by b=1

2- Write a program of increment and decrement operators in C language.


#include <stdio.h>

#include<conio.h>

int main ()

{

int a = 10, b = 100;

float c = 10.5, d = 100.5;

printf ("++a = %d \n", ++a);

printf ("--b = %d \n", --b);

printf ("++c = %f \n", ++c);

printf ("--d = %f \n", --d);

return 0;

}

Output:-

++a = 11

--b = 99

++c = 11.500000

++d = 99.500000

Some basic C language program using while loop ,study easy

3- Write a program of assignment operators in C language.


#include <stdio.h>

#include<conio.h>

int main ()

{

int a = 5, c;

c = a;

printf ("c = %d\n", c);

c += a;

printf ("c = %d\n", c);

c -= a;

printf ("c = %d\n", c);

c *= a;

printf ("c = %d\n", c);

c /= a;

printf ("c = %d\n", c);

c %= a;

printf ("c = %d\n", c);

return 0;

}

Output:-

c = 5

c = 10

c = 5

c = 25

c = 5

c = 0

4- Write a program of relational operators in C language.


#include <stdio.h>

#include<conio.h>

int main ()

{

int a = 5, b = 5, c = 10;

printf ("%d == %d is %d \n", a, b, a == b);

printf ("%d == %d is %d \n", a, c, a == c);

printf ("%d > %d is %d \n", a, b, a > b);

printf ("%d > %d is %d \n", a, c, a > c);

printf ("%d < %d is %d \n", a, b, a < b);

printf ("%d < %d is %d \n", a, c, a < c);

printf ("%d != %d is %d \n", a, b, a != b);

printf ("%d != %d is %d \n", a, c, a != c);

printf ("%d >= %d is %d \n", a, b, a >= b);

printf ("%d >= %d is %d \n", a, c, a >= c);

printf ("%d <= %d is %d \n", a, b, a <= b);

printf ("%d <= %d is %d \n", a, c, a <= c);

getch();

}

Output:-

5 == 5 is 1

5 == 10 is 0

5 > 5 is 0

5 > 10 is 0

5 < 5 is 0

5 < 10 is 1

5 != 5 is 0

5 != 10 is 1

5 >= 5 is 1

5 >= 10 is 0

5 <= 5 is 1

5 <= 10 is 1
Some basic C language program using do while loop concept in C , C++ and java

Post a Comment

0 Comments