Computer Science, asked by nkpradeepkumar28, 2 months ago

Write a program to get integer input from the user and print "FOOBAR" if the
number is divisible by 3 & 5 and print "F00" if the number is divisible by 3 and
print "BAR" if the number is divisible by 5 and print "NONE" if the number is not
divisible by 3 and 5.
Sample testcases
Input 1
Output 1
15
F00BAR
Input 2
Output 2
45
F00BAR
Input 3
Output 3
9
FOO
Input 4
Output 4
11
NONE​

Answers

Answered by harshvirsing55
12

Answer:

\blue{\fbox{\tt PROGRAM IN PYTHON LANGUAGE}}

num=int(input('ENTER YOUR NO.='))

if num%3==0 and num%5==0:

   print('F00BAR')

elif num%3==0:

   print('F00')

   

elif num%5==0:

   print('BAR')    

else:

   print('NONE')

\blue{\fbox{\tt O U T P U T S}}

1.

ENTER YOUR NO.=15

F00BAR

2.

ENTER YOUR NO.=45

F00BAR

3.

ENTER YOUR NO.=9

F00

4.

ENTER YOUR NO.=4

NONE

\orange{\tt Hope it will} \green{\tt help you.}

Attachments:
Answered by ankhidassarma9
0

Answer:

#include<stdio.h>

int main()

{

 int i, num;

   //Asking for input

 printf("Enter the  number: ");

 scanf("%d", &num);

     if (num % 3 == 0 && num % 5 == 0)

   {

     printf(" FOOBAR %d ", num);

   }

   else {

       if(num % 3 == 0)

       printf(" FOO %d ", num);

       else{

       if (num % 5 == 0)

       printf(" Bar %d ", num);

       else

       printf(" None %d ", num);

       }

   }

 return 0;

}

Explanation:

Input : 15

Output : FOOBAR    15

Input : 45

Output : FOOBAR    45

Input : 9

Output : FOO   9

Input : 11

Output : None    15

Similar questions