C program to check whether a number is divisible by 5 and 11; In this tutorial, we will learn how to check whether a number is divisible by 5 and 11 in c program with the help of if-else statement and conditional operators.
Algorithm and Programs to Check the Number is Divisible by 5 and 11 OR Not
- Algorithm to Check the Number is Divisible by 5 and 11
- C Program to Check the Number is Divisible by 5 and 11 using If Else Statement
- C Program to Check the Number is Divisible by 5 and 11 using Conditional Operator
Algorithm of Check the Number is Divisible by 5 and 11
Use the algorithm to write a c program to check whether a number is divisible by 5 and 11 or not; as follows:
- Step 1: Start.
- Step 2: Read a number from the user.
- Step 3: Check the a number is divisible by 5 and 11 using if else or conditional operators
- Step 4: Print result.
- Step 6:End.
C Program to Check the Number is Divisible by 5 and 11 using If Else Statement
/* C Program to Check the Number is Divisible by 5 and 11 */
#include<stdio.h>
int main()
{
int number;
printf("\n Please Enter any Number to Check whether it is Divisible by 5 and 11 : ");
scanf("%d", &number);
if (( number % 5 == 0 ) && ( number % 11 == 0 ))
printf("\n Given number %d is Divisible by 5 and 11", number);
else
printf("\n Given number %d is Not Divisible by 5 and 11", number);
return 0;
}
The output of the above c program; as follows:
Please Enter any Number to Check whether it is Divisible by 5 and 11 : 55 Given number 55 is Divisible by 5 and 11
C Program to Check the Number is Divisible by 5 and 11 using Conditional Operator
/* C Program to Check the Number is Divisible by 5 and 11 Using Conditional Operator */
#include<stdio.h>
int main()
{
int number;
printf("\n Please Enter any Number to Check whether it is Divisible by 5 and 11 : ");
scanf("%d",&number);
((number % 5 == 0 ) && ( number % 11 == 0 )) ?
printf("\n Given number %d is Divisible by 5 and 11", number) :
printf("\n Given number %d is Not Divisible by 5 and 11", number);
return 0;
}
The output of the above c program; as follows:
Please Enter any Number to Check whether it is Divisible by 5 and 11 : 55 Given number 55 is Divisible by 5 and 11