escort tekirdağ escort tokat escort muğla escort ordu escort sivas escort kuşadası escort kıbrıs
C Programming

C program with if..else statement

C program to check whether a number is divisible by Aor B or both. If it is divisible by A, print “Aim”, if it is divisible by B, print “High” and if by both print” Aim Both”.

#include<stdio.h>
void main()
{
    int num, a,b;
    printf("Enter the value for num:");
    scanf("%d", &num);
    printf("Enter the value for a:");
    scanf("%d", &a);
    printf("Enter the value for b:");
    scanf("%d", &b);
    
    if((num%a==0)&&(num%b!=0))
    {
        printf("AIM");
    }
    else if((num%b==0)&&(num%a!=0))
    {
        printf("HIGH");
    }
    else if((num%a==0)&&(num%b==0))
    {
        printf("AIM BOTH");
    }
}

Output:

Enter the value for num:8
Enter the value for a:4
Enter the value for b:3
AIM

Get more stuff
in your inbox

Subscribe to our newsletter and get interesting stuff and updates to your email inbox.

Bibith K Mathew (born on 29 July 1998) is an Indian Internet entrepreneur. He is best known as the CEO and Managing Director of TalkBate Digital Partners.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.