write a program in q basic to check wether a no. is divisible by 5 or not.
Answers
CLS
INPUT “ENTER ANY NUMBER”; N
IF N MOD 5 = 0 THEN
PRINT N; IS DIVISIBLE BY 5”
ELSE
PRINT N; IS NOT DIVISIBLE BY 5”
END IF
END
USING SUB PROCEDURE
DECLARE SUB CHECK (N)
CLS
INPUT “ENTER ANY NUMBER”; N
CALL CHECK (N)
END
SUB CHECK (N)
IF N MOD 5 = 0 THEN
PRINT N; IS DIVISIBLE BY 5”
ELSE
PRINT N; IS NOT DIVISIBLE BY 5”
END IF
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION CHECK$ (N)
CLS
INPUT “ENTER ANY NUMBER”; N
PRINT N; “IS “; CHECK$(N) ; “BY 5”
END
FUNCTION CHECK$ (N)
IF N MOD 5 = 0 THEN
CHECK$ = “DIVISIBLE”
ELSE
CHECK$ = “NOT DIVISIBLE”
END IF : END FUNCTION
C Program to Identify whether a number is divisible by 5 or not:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int number;
printf("Enter the number: ");
scanf(' %f", &number);
if (number % 5 == 0)
{
printf("The Number is divisible by 5");
}
else
{
printf("The number is not divisible by 5");
}
return 0;
}
Hope it Helps,
Thank You