If Condition Programs Set 2

Question: 6

Write a C program to take input for a number check and print whether the number is multiple of 7 or 11 or not?

sol:

#include <stdio.h>
 int main()
 {
     int a;
     printf("Enter any no ");
     scanf("%d",&a);
     if(a%7==0 || a%11==0)
         printf("number is multiple of 7 or 11");
     else
         printf("number is not multiple 7 or 11");
     return 0;
 }

Output:

case 1:
Enter any no 25
number is not multiple 7 or 11
case 2:
Enter any no 55
number is multiple of 7 or 11

Question: 7

Write a C program to take input for a number check and print whether the number is multiple of 7 and 11 or not?

Sol:

#include <stdio.h>
 int main()
 {
     int a;
     printf("Enter any no ");
     scanf("%d",&a);
     if(a%7==0 && a%11==0)
         printf("number is multiple of 7 and 11");
     else
         printf("number is not multiple 7 and 11");
     return 0;
 }

Output:

case 1:
Enter any no 55
number is not multiple 7 and 11
case 2:
Enter any no 77
number is multiple of 7 and 11

Question: 8

Write a C program to take input for a number check and print whether the number is multiple of 5 or not?

sol:

#include <stdio.h>
 int main()
 {
     int a;
     printf("Enter any no ");
     scanf("%d",&a);
     if(a%5==0)
         printf("number is multiple of 5");
     else
         printf("number is not multiple 5");
     return 0;
 }

Output:

case 1:
Enter any no 23
number is not multiple 5
case 2:
Enter any no 25
number is multiple of 5

Question: 9

Write a C program to take input for a number check and print whether the number is multiple of 5 or 7 or not?

#include <stdio.h>
 int main()
 {
     int a;
     printf("Enter any no ");
     scanf("%d",&a);
     if(a%5==0 || a%7==0)
         printf("number is multiple of 5 or 7");
     else
         printf("number is not multiple 5 or 7");
     return 0;
 }

Output:

case 1:
Enter any no 25
number is multiple of 5 or 7
case 2:
Enter any no 21
number is multiple of 5 or 7
case 3:
Enter any no 29
number is not multiple 5 or 7

Question: 10

Write a C program to take input for a number check and print whether the number is multiple of 5 and 7 or not?

Sol:

#include <stdio.h>
 int main()
 {
     int a;
     printf("Enter any no ");
     scanf("%d",&a);
     if(a%5==0 && a%7==0)
         printf("number is multiple of 5 and 7");
     else
         printf("number is not multiple 5 and 7");
     return 0;
 }

Output:

case 1:
Enter any no 25
number is not multiple 5 and 7
case 2:
Enter any no 77
number is not multiple 5 and 7
case 3:
Enter any no 35
number is multiple of 5 and 7

C Language Programming Tutorial

C Language Tutorial Home     Introduction to C Language     Tokens     If Condition      goto statement and Labelname     Switch Statements     For loop     While Loop     Do while loop     break and continue     Functions     Recursion     Inbuild Functions     Storage Classes     Preprocessor     Arrays     Pointers     Structures and Unions     File Handling     Projects