Please, any shorter way to write this?

double a1, b1, c1,d1,e1;
a1=a*100/s;
b1=b*100/s;
c1=c*100/s;
d1=d*100/s;
e1=e/100/s;

Many thanks!
Use arrays and a loop:
1
2
3
double a1[5], a[5];
for (int i=0; i<5; i++)
    a1[i]= a[i]*100/s;
Last edited on
Anytime you're doing the same thing over and over, it begs the question, "Why aren't you using arrays and a loop?".
1
2
3
  double a[5], a1[5];  // a[0] = a, a[1]=b, etc.
  for (int (i=0;i<5;i++)
    a1[i] = a[i]*100/s;

Topic archived. No new replies allowed.