A Logical Problem Which you almost confuse your Brain!!!
Coding Question:
You go to a Shop you have only 100 INR. In that Shop, There is 3 types of Chocolates, one is 5 INR , another is 0.75 INR and the other is 0.25 INR. You must spend 100 INR with total 100 Chocolates only. Do not exceed or Deceed 100 Chocolates and 100 INR also you must buy all three Chocolates. Find How many Chocolates that you buy by spending 100 INR completely.
Code:
#include <stdio.h>
void main()
{
float a,b,c;
int i,j,k;
for(i=1;i<=100;i++)
{
for(j=1;j<=100;j++)
{
for(k=1;k<=100;k++)
{
a = 5*i;
b = 0.75*j;
c = 0.25*k;
if((i+j+k) == 100 && (a+b+c) == 100)
{
printf("how many 5 rs choco:%d\n",i);
printf("how many .75 rs choco:%d\n",j);
printf("how many .25 rs choco:%d\n",k);
printf("how much 5 rs choco:%.2f\n",a);
printf("how much .75 rs choco:%.2f\n",b);
printf("how much .25 rs choco:%.2f\n",c);
printf("***************\n");
}
}
}
}
}
OUTPUT:
how many 5 rs choco:6 how many .75 rs choco:93 how many .25 rs choco:1 how much 5 rs choco:30.00 how much .75 rs choco:69.75 how much .25 rs choco:0.25 *************** how many 5 rs choco:8 how many .75 rs choco:74 how many .25 rs choco:18 how much 5 rs choco:40.00 how much .75 rs choco:55.50 how much .25 rs choco:4.50 *************** how many 5 rs choco:10 how many .75 rs choco:55 how many .25 rs choco:35 how much 5 rs choco:50.00 how much .75 rs choco:41.25 how much .25 rs choco:8.75 *************** how many 5 rs choco:12 how many .75 rs choco:36 how many .25 rs choco:52 how much 5 rs choco:60.00 how much .75 rs choco:27.00 how much .25 rs choco:13.00 *************** how many 5 rs choco:14 how many .75 rs choco:17 how many .25 rs choco:69 how much 5 rs choco:70.00 how much .75 rs choco:12.75 how much .25 rs choco:17.25 ***************
I just coded using C you can do this with any other Languages. By Coding this you can find 5 solutions because 5 times 100 chocoloates and INR came. Therefore these are the Solutions....
0 comments: