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

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

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

  1. Profile photo of k v swaroop

    #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

    ReplyReport user
  2. vivek rawat

    sir how can I make a program of that series:
    1-2+3-4+5-6…..n terms

    Reply
  3. a program in turbo c that accepts 20 numbers then display how many numbers are odd, even, and how many numbers are divisible by 3

    Reply
  4. write a java to find no. is divisible by 3 if it is then write c, also if it is divusible by 5 then write m and if both write cm
    Condition take no. of range from 1-100

    Reply
  5. ali hamad

    how i answer this question in c program
    “write a C program to get input in an array and add the numbers divisible by 11 and 46 .
    plz answer this question tomorrow the last day for submission , plz plz plz

    Reply
    • anand kumar

      #include

      int main()
      {
      int num;
      int i;
      int sum=0;

      printf(“enter the amount of elements of array\n”);
      scanf(“%d”,&num);
      int my_love_simran[num];

      printf(“now enter the values of array\n”);
      for(i=0;i<num;i++)
      {
      scanf("%d",&my_love_simran[i]);
      }
      for(i=0;i<num;i++)
      {
      if((my_love_simran[i]%11==0) && (my_love_simran[i]%46==0) )
      {
      printf("%d :: is divisible by both 11 and 46\n",my_love_simran[i]);
      sum=sum+my_love_simran[i];
      }
      else
      {
      printf("%d :: is neither divisible by 11 nor by 46\n",my_love_simran[i]);

      }
      }

      printf("sum of all numbers which are divisible by both 11 and 46 is\n");
      printf("%d",sum);

      return 0;
      }

      Reply
  6. Md. Osman

    #include
    int main()

    {
    int num;
    printf(“Enter a number”);
    scanf(“%d”,&num);
    if((num % 3 == 0) && (num % 5 == 0))
    {
    printf(“num is divisible by 3 and 5″);
    }
    else
    {
    printf(” num is not divisible by 3 and 5″);
    }
    return 0;
    }

    Reply
  7. Abdul quader khan

    How to write a program
    Write a program to accept an integer from the user and check whether it is divisible by 2 only or a divisible of 3 only or by both or neither divisible by 2 and 3

    Reply

Leave a Reply