Go to your University || Python Lab || DSA Lab || AI & Machine Learning Lab || Linux Lab || OOPs Lab || DBMS Lab || JAVA Lab ||| Free Online Tutorials ||| 
companies for Campus Placement || Logical Reasoning || Quantitative Aptitude || General English || Technical-MCQ and Interview Questions || HR Interview Questions

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.6k points)
edited by
 
Best answer

Operators in C

Arithmetic Operators : An arithmetic operator performs mathematical operations such as addition, subtraction, multiplication, division etc on numerical values (constants and variables).

OperatorMeaning of Operator
+addition or unary plus
-subtraction or unary minus
*multiplication
/division
%remainder after division (modulo division)

Assignment Operators : An assignment operator is used for assigning a value to a variable. The most common assignment operator is =

OperatorExampleSame as
=a = ba = b
+=a += ba = a+b
-=a -= ba = a-b
*=a *= ba = a*b
/=a /= ba = a/b
%=a %= ba = a%b

Relational Operators : A relational operator checks the relationship between two operands. If the relation is true, it returns 1; if the relation is false, it returns value 0.Relational operators are used in decision making and loops.

OperatorMeaning of OperatorExample
==Equal to5 == 3 is evaluated to 0
>Greater than5 > 3 is evaluated to 1
<Less than5 < 3 is evaluated to 0
!=Not equal to5 != 3 is evaluated to 1
>=Greater than or equal to5 >= 3 is evaluated to 1
<=Less than or equal to5 <= 3 is evaluated to 0

 Logical Operators : An expression containing logical operator returns either 0 or 1 depending upon whether expression results true or false. Logical operators are commonly used in decision making in C programming. 

OperatorDescriptionExample
&&Called Logical AND operator. If both the operands are non-zero, then the condition becomes true.(A && B) is false.
||Called Logical OR Operator. If any of the two operands is non-zero, then the condition becomes true.(A || B) is true.
!Called Logical NOT Operator. It is used to reverse the logical state of its operand. If a condition is true, then Logical NOT operator will make it false.!(A && B) is true.

Bitwise Operators :During computation, mathematical operations like: addition, subtraction, multiplication, division, etc are converted to bit-level which makes processing faster and saves power.Bitwise operators are used in C programming to perform bit-level operations.

OperatorsMeaning of operators
&Bitwise AND
|Bitwise OR
^Bitwise exclusive OR
~Bitwise complement
<<Shift left
>>Shift right

 Program 

#include <stdio.h>

#include<conio.h>

void main()

{

    int a = 9,b = 4, c,d=10,result;

    clrscr();

    

    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);

    c = a;      // c is 5

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

    c += a;     // c is 10 

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

    c -= a;     // c is 5

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

    c *= a;     // c is 25

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

    c /= a;     // c is 5

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

    c %= a;     // c = 0

    printf("c = %d\n", 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);

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

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

    

     result = (a == b) && (d > b);

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

    result = (a == b) && (d < b);

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

    result = (a == b) || (d < b);

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

    result = (a != b) || (d < b);

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

    result = !(a != b);

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

    result = !(a == b);

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

   getch();

}

Output

output


For more Kerala Technological University(KTU) CSE-I Sem Programming in C Lab Experiments Click Here


Online Courses & Fee

  1. AI, ML & Deep Learning - INR 3000/- (80% OFF)
  2. Web development using python (Django) - INR 2000/- (80% OFF)

FREE Online Certification Courses or Tutorials

  1. Python Programming
  2. Machine Learning Using Python
  3. Linux/Unix
  4. Data Structures and Algorithms(DSA)
  5. Database Management System(DBMS)
  6. Object Oriented Programming(OOPs) using C++
  7. Java Programming
  8. C Programming

[[ CALL - 07976731765 ]]

Details

Study Resources

Related questions

  Realize your learning potential with courses starting at ₹ 420
 Placements:   List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Online Free Training:  MACHINE LEARNINGPython Programming | Database Management System(DBMS) | Object Oriented Programming(OOPs) using C++ | Data Structures and Algorithms(DSA) | Java Programming | Linux/Unix | C Programming
Exams: List of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG) | JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Goeduhub
About Us | Contact Us   Social::   |  | 
...