(e-mail address removed) wrote:
[..]
erm...how about if im using float...ant printf as %.0f..huhuhu but
still i dont know how to saparate those digit as shown uhuhu
BTW, what's "uhuhu" or "huhuhu"?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
huhuhu mean im crying..huhuhu almost 1 week im thinking on how to
saparate those number huhuhu
You were already given one way in another thread, with integer division.
Consider. What is
12345 / 10?
it is 1234
12345 / 100
123
what is the remainder of 12345 / 10?
45
to get the remainder, use 12345 % 10
That should be all you need to be able to write this. We will not do your
homework for you. You haven't show us ANY code that you've written to try
this.
ok i show my work..
but plss dont laugh at me coz im a newbie...
#include <stdio.h>
printf("please key in any 5 digit number:");
scanf("%f",&num);
for (int a=1 ; a<=5 ; a++)
{
printf("",a);
printf("\n%.0f", num);
}
huhu this is a beginner coding....
ok the problem is, i need to key in 56789 all togehther...so how to
make it saparated...
and where can i put the clue that u give- Hide quoted text -
can u suggest how to simplify this coding
//assignment//
#include <stdio.h>
void main()
{
int m1,m2,m3 ;
float sum1=0,sum2=0,sum3=0,total;
printf ("\n 1.Appetizers:Rm 4.00 (10%Discount)\n 2.salads:Rm
3.00 (10%Discount)\n 3.Soups:Rm 3.50 (20%Discount)
\n 4.Seafood:Rm 5.00 (08%Discount)\n 5.Chicken/Beef:Rm 8.50
(15%Discount)\n 6.Noodles/Rice:Rm 3.50 (20%Discount)\n
7.Vegetables:Rm 3.00 (25%Discount)\n 8.Pasta:Rm 5.00
(15%Discount)\n 9.Beverages:Rm 2.00 (20%Discount)\n 10.Lunch
special:Rm 5.50 (25%Discount)\n 11.Healthy Food:Rm 6.00
(15%Discount)\n 12.Others:Rm 2.50 (5%Discount) ");
printf ("\n please enter 3 of the code above:\n");
scanf ("%d\n%d\n%d" ,&m1,&m2,&m3);
switch (m1)
{
case 1 : printf("Appetizers:Rm 4.00");
sum1=4.00-(4.00*10/100);
break ;
case 2 : printf("salads:Rm 3.00");
sum1=3.00-(3.00*10/100);
break ;
case 3 : printf("Soups:Rm 3.50");
sum1= 3.50-(3.50*20/100) ;
break ;
case 4 : printf("Seafood:Rm 5.00");
sum1= 5.00-(5.00*8/100);
break ;
case 5 : printf("Chicken/Beef:Rm 8.50");
sum1= 8.50-(8.50*15/100);
break ;
case 6 : printf("Noodles/Rice:Rm 3.50");
sum1= 3.50-(3.50*20/100);
break ;
case 7 : printf("Vegetables:Rm 3.00");
sum1= 3.00-(3.00*25/100) ;
break ;
case 8 : printf("Pasta:Rm 5.00");
sum1= 5.00-(5.00*15/100);
break ;
case 9 : printf("Beverages:Rm 2.00");
sum1= 2.00-(2..00*20/100);
break ;
case 10 : printf("Lunch special:Rm 5.50") ;
sum1=5.50-(3.50*25/100) ;
break ;
case 11 : printf("Healthy Food:Rm 6.00");
sum1=6.00-(6.00*15/100) ;
break ;
case 12 : printf("Others:Rm 2.50");
sum1= 2.50-(2.50*5/100);
default: ("asasd");
}
switch (m2)
{
case 1 : printf("\nAppetizers:Rm 4.00");
sum2= 4.00-(4.00*10/100);
break ;
case 2 : printf("\nsalads:Rm 3.00");
sum2= 3.00-(3.00*10/100) ;
break ;
case 3 : printf("\nSoups:Rm 3.50");
sum2= 3.50-(3.50*20/100) ;
break ;
case 4 : printf("\nSeafood:Rm 5.00");
sum2= 5.00-(5..00*8/100);
break ;
case 5 : printf("\nChicken/Beef:Rm 8.50");
sum2= 8.50-(8..50*15/100) ;
break ;
case 6 : printf("\nNoodles/Rice:Rm 3.50");
sum2= 3.50-(3..50*20/100) ;
break ;
case 7 : printf("\nVegetables:Rm 3.00");
sum2= 3.00-(3.00*25/100);
break ;
case 8 : printf("\nPasta:Rm 5.00");
sum2=5.00-(5.00*15/100);
break ;
case 9 : printf("\nBeverages:Rm 2.00");
sum2=2.00-(2.00*20/100) ;
break ;
case 10 : printf("\nLunch special:Rm 5.50") ;
sum2= 5.50-(5..50*25/100);
break ;
case 11 : printf("\nHealthy Food:Rm 6.00");
sum2= 6.00-(6.00*15/100);
break ;
case 12 : printf("\nOthers:Rm 2.50");
sum2= 2.50-(2.50*5/100) ;
default
"asasd");
}
switch (m3)
{
case 1 : printf("\nAppetizers:Rm 4.00");
sum3=4.00-(4.00*10/100) ;
break ;
case 2 : printf("\nsalads:Rm 3.00");
sum3=3.00-(3.00*10/ 100);
break ;
case 3 : printf("\nSoups:Rm 3.50");
sum3=3.50-(3.50*20/100);
break ;
case 4 : printf("\nSeafood:Rm 5.00");
sum3= 5.00-(5.00*8/100);
break ;
case 5 : printf("\nChicken/Beef:Rm 8.50");
sum3=8.50-(8.50*15/100);
break ;
case 6 : printf("\nNoodles/Rice:Rm 3.50");
sum3=3.50-(3.50*20/100);
break ;
case 7 : printf("\nVegetables:Rm 3.00");
sum3= 3.00-(3.00*25/100) ;
break ;
case 8 : printf("\nPasta:Rm 5.00");
sum3= 5.00-(5..00*15/100 );
break ;
case 9 : printf("\nBeverages:Rm 2.00");
sum3=2.00-(2.00*20/100);
break ;
case 10 : printf("\nLunch special:Rm 5.50") ;
sum3= 5.50-(5.50*25/100) ;
break ;
case 11 : printf("\nHealthy Food:Rm 6.00");
sum3=6.00-(6.00*15/100);
break ;
case 12 : printf("\nOthers:Rm 2.50");
sum3=2.50-(2.50*5/ 100);
default: ("asasd");
}
total = sum1+sum2+sum3 ;
printf("\n\nTotal price after discount RM%.2f",total);
}
____________________________________________________________________________________________________
i think we can use looping....but im suck in looping huhuhu realy2
sory....- Hide quoted text -
- Show quoted text -