Write a program to accept 3 marks and print whether the given candidate is pass or fail using logical operators.

/* Write a program to accept 3 marks and print whether the given candidate is pass

or fail using logical operators.*/

#include <stdio.h>

void main()

{

    int m1,m2,m3;

    printf("Enter the mark1 : ");

    scanf("%d",&m1);

    printf("Enter the mark2 : ");

    scanf("%d",&m2);

    printf("Enter the mark3 : ");

    scanf("%d",&m3);

    printf("Evaluating using AND (&) operator:=\n");

    if(m1>=40 && m2>=40 && m3>=40)

    {

        printf("Pass\n");

    }

    else

    {

        printf("Fail\n");

    }

    printf("Evaluating using OR(||) operator:=\n");

    if(m1<40 || m2<40 || m3<40)

    {

        printf("Fail\n");

    }

    else

    {

        printf("Pass\n");

    }

    printf("Evaluating using AND (&&) and NOT (!) operators:=\n");

    if(!(m1>=40 && m2>=40 && m3>=40))

    {

        printf("Fail\n");

    }

    else

    {

        printf("Pass\n");

    }

    getch();

}

Comments

Popular posts from this blog

Write a program to accept numerator and denominator and find the remainder without using modulus (%) operator using do..while loop.