English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Have to produce printf statement by using below equation.
x, y, z are integers and a, b ,c are lengths, both previously defined in my code into a printf statment such that printf produces in form:

x*a + y*b +z*c = total length used

so output would look like

0*65 + 0*50 + 1*35 = 35

2006-09-06 03:37:14 · 2 answers · asked by Anonymous in Science & Mathematics Mathematics

2 answers

printf("%d*%d + %d*%d + %d*%d = %d",x,a,y,b,z,c,x*a+b*y+c*z);

2006-09-06 07:34:17 · answer #1 · answered by dutch_prof 4 · 1 0

sum=x*a+y*b+z*c;
printf("%d * %d + %d * %d + %d * %d= %d", x,a,y,b,z,c,sum);

where sum is used to store sum of above expression

2006-09-06 10:43:36 · answer #2 · answered by Abhijit D 3 · 1 0

fedest.com, questions and answers