Looking for NEET / JEE Coaching? Enquire Now
You must Sign In to post a response.
  • Category: Programming

    Differentiation between ÷ and % operator in C with example.


    Preparing for engineering degree exam? want to get a solution for difference between logical and relational operators on C? Here, our ISC experts shall provide with the main differences and relevant examples to resolve the concerns.

    Following is a question that was asked in the question paper of II/IV B.Tech Degree Examinations,
    (April/May 2015)conducted by Acharya Nagarjuna University for subject Object Oriented Programming Systems, Semester-II

    Q) Differentiate the ÷ operator with % operator illustratively. Enumerate the logical and relational operators in C. Compare their precedence values. [7 Marks]
  • Answers

    2 Answers found.
  • Hello there,

    The oprator "÷" is an division operator in coding it is used as "/" and "%" is the modulus operator.

    "/" operator divides the value and give you the quotient as output where as "%" operator is know as modulus it gives you the remainder as the result.

    Example for "÷"(/) operator:
    12 / 3 = 4
    Here 4 is the output i.e. the quotient.

    Example for "%" operator:
    12 % 3 = 0
    Here 0 is the output i.e. the remainder.

    Thank you.

  • C language supports variety of operators. The different categories of operators supported by C language are as follows.
    1) Mathematical/Arithmatic operators
    2) Relational operators
    3) Logical operators
    4) Short-hand assignment operators
    5) Increment/decrement operators
    6) Conditional operator
    7) Bitwise operators
    the ÷ operator and % operator are the operators from mathematical operators. ÷ operator is used to obtain quotient and % operator is used to obtain remainder, when one number is divided by another number.
    Let us see one example. Below is the program which shows use of ÷ and % operators. In C language ÷(division) operator is shown by / sign and modulus operator is shown by % sign.

    Please include and header files before main function.
    //PROGRAM TO ILLUSTRATE USE OF DIVISION AND MODULUS OPERATOR.
    #include
    #include
    void main(void)
    {
    int a,b,rd,rr;
    clrscr();
    printf("Enter any two numbers\n");
    scanf("%d%d",&a,&b);
    rd=a/b;
    rr=a%b;
    printf("\nResult of division(a/b)which is quotient is %d",rd);
    printf("\nRemainder after division is %d",rr);
    getch();
    }

    Different logical operators are AND(&&), OR(||) and NOT(!) operators. Logical operators AND and OR are used when more than two conditions are required to combine together to get the result.
    In case of AND operator, when all the conditions are true then and then only final answer is true.
    Let us see one daily life example to understood AND operator. If teacher declared that if Raju and Abhi comes, then I will teach the class. In this case the class will be conducted only when both Raju and Abhi comes. In rest of the cases class will not be conducted.
    In case of OR operator, when any one of the condition is true then final answer is true.
    Let us see one daily life example to understood OR operator. If teacher declared that if Raju or Abhi comes, then I will teach the class. In this case the class will not be conducted only when both Raju and Abhi did not comes. In rest of the cases class will be conducted.
    In case of NOT operator, it changes the current state of variable or expression. If current state of expression/variable is true then after applying NOT operator it changes to false and vice-versa.
    if((var=='a')||(var=='e')||(var=='i')||(var=='o')||(var=='u')) is called as logical expression.
    Different relational operators are <(less than), >(greater than), <=(less than or equal to), >=(greater than or equal to), ==(comparison). !=(Not equal to).
    Normally relational operators are used to check the relation between two entities.
    e.g. if Abhay is 17 years college student then to check whether Abhay is eligible for voting or not? we use age>=18 condition. Here age>=18 is a relational expression.

    Precedence means priority of operators. Precedence of relational operators is higher than logical operators.


  • Sign In to post your comments