6

You have three dice each side is numbered as 1,2,3,4,5,6 .you have to take a number from user check that number as sum of any side number of these three dice.like we take number as 5 then the possibility are (1,1,3) (1,2,2) (1,3,1) (2,1,2) (2,2,1) (3,1,1) and is 6 possibility. So write to a program for that. You can write program in c.

#include <stdio.h>

int main()
{

int i, j, n, isPrime; //isPrime is used as flag variable
/* Reads upper limit to print prime */ printf(“Find prime numbers between 1 to : “); scanf(“%d”, &n);
printf(“\nAll prime numbers between 1 to %d are:\n”, n);
/* Finds all Prime numbers between 1 to n */ for(i=2; i<=n; i++)
{
/* Assume that the current number is Prime */ isPrime = 1;
/* Check if the current number i is prime or not */ for(j=2; j<=i/2; j++)
{
/*
* If i is divisible by any number other than 1 and self
* then it is not prime number
*/ if(i%j==0)
{
isPrime = 0; break;
}
}
/* If the number is prime then print */ if(isPrime==1)
{
printf(“%d is Prime number\n”, i);
}
}
return 0;
}

Output:-

Find prime numbers between 1 to : 100
All prime numbers between 1 to 100 are:
2 is Prime number
3 is Prime number
5 is Prime number
7 is Prime number
11 is Prime number
13 is Prime number
17 is Prime number
19 is Prime number
23 is Prime number
29 is Prime number
31 is Prime number
37 is Prime number
41 is Prime number
43 is Prime number
47 is Prime number
53 is Prime number
59 is Prime number
61 is Prime number
67 is Prime number
71 is Prime number
73 is Prime number
79 is Prime number
83 is Prime number
89 is Prime number
97 is Prime number

Admin Changed status to publish January 3, 2023