#include <stdio.h>
int main()
{
int x, y, amount, isPrime, sum=0;
printf("Enter the total bill amount : ");
scanf("%d", &amount);
for(x=2; x<=amount; x++)
{
isPrime = 1;
for(y=2; y<=x/2 ;y++)
{
if(x%y==0)
{
isPrime = 0;
break;
}
}
if(isPrime==1)
{
sum += x;
}
}
printf("The discount value for the bill amount %d = %d", amount, sum);
return 0;
}
Comments
Leave a comment