Program to find out whether a entered number is divisible by 3 and 5 or not

Friday, October 7th, 2011

This program find out whether a entered number is divisible by 3 and 5 or not.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "conio.h"
#include "stdio.h"
 
void main()
{
  int num;
  printf("\nEnter a number ");
  scanf("%d",&num);
  if(num%3==0)
  {
    if(num%5==0)
    {
      printf("\nThe number %d is divisible by 3 and 5");
    }
    else
    {
      printf("\nThe number %d is divisible by 3 but not by 5");
    }
  }
  else
  {
    printf("\nThe number %d is niether divisible by 3 nor by 5");
  }
getch();
}

Output:

Enter a number 21
 
Number is divisible by 3 but not by 5
Avatar of chitra

Author Name :
chitra

Total : 1 Comment


One Response to “Program to find out whether a entered number is divisible by 3 and 5 or not”

  1. k v swaroop says:

    #include

    void main()
    {
    int num;
    printf(“\nEnter a number “);
    scanf(“%d”,&num);
    if(num%3==0)
    {
    if(num%5==0)
    {
    printf(“\nThe number %d is divisible by 3 and 5\n”,num);
    }
    else
    {
    printf(“\nThe number %d is divisible by 3 but not by 5\n”,num);
    }
    }
    else
    {
    if(num%5==0)
    “tdiv.c” 31 lines, 507 characters

Leave a Reply

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: