Skip to main content

C Program to Check a Whether a Number is Divisible by 5 or Not

 C Program to Check a Whether a Number is Divisible by 5 or Not

         In this program we will check a number entered by the user will be divisible by 5 or Not. We have solved this problem using if-else statement.



Program:


#include<stdio.h>
#include<conio.h>
int main()
{
    int x;
    printf("Enter a number");
    scanf("%d",&x);
    if(x%5==0)
        printf("The number %d is divisible by 5",x);
    else
        printf("The number %d is not divisible by 5",x);
    return 0;
}



Output:


C Program to Check a Whether a Number is Divisible by 5 or Not



NOTE: You Can Comment Your Code if you have solved differently and we will pin it in the comment section.  Let's Learn together. 


MOTTO: 

You Learn, I Learn together We Learn.

 

Comments

Popular posts from this blog

C Program to Print first N Even Natural Number/in Reverse Order

  C Program to Print first N Even Natural Number.     In this example, we will find and print the first N even natural. Here we have used for loop to solve this program.      What are Natural Numbers? Natural Numbers are all positive numbers starting from 1 to infinity.      For Example:  1,2,3,4,5,6,.............................,n are all natural numbers. What are Even Numbers? Even numbers are those numbers whose remainder is 0 when divided by 2.     For Example: 2,4,6,8,10,.....,n are all even numbers.   PROGRAM: #include <stdio.h> #include <conio.h> void   main () {      int   i , x ;      printf ( "Enter the value of N : " );      scanf ( " %d " ,& x );      for ( i = 1 ; i <= x ; i ++)     {          printf ( " %d " , 2 * i );     }      getch (); } OUTPUT: C Program to Print First N Even Natural Number in Reverse Order. PROGRAM 123 #include <conio.h> #include <stdio.h> int   main () {      int   i , x ;      printf

C Program to Generate and Print Fibonacci series upto a given inputted number

 C Program to Generate and Print Fibonacci series upto a given inputted number     In this example, we will generate and print fibonacci series upto a the upper limit entered by the user. To solve this problem we should have a proper concept on Fibonacci series and while loop.  What is a Fibonacci Series? Fibonacci series is the sum of the two preceding numbers, starting from 0 and 1.     For Example: 0,1,1,2,3,5,8,13,....,etc  PROGRAM #include <stdio.h> #include <conio.h> void   main () {      int   n , x1 , x2 , x3 = 0 ;      printf ( "Enter the limit upto which fibonacci series to be generated : " );      scanf ( " %d " ,& n );      x1 = 0 ;      x2 = 1 ;      printf ( " %d \t %d " , x1 , x2 );      x3 = x1 + x2 ;      while ( x3 <= n )     {          printf ( " \t %d " , x3 );          x1 = x2 ;          x2 = x3 ;          x3 = x1 + x2 ;     }      getch (); } OUTPUT: Enter the limit upto which fibonacci series to be g