S11as

octave mul before sum after

Apr 11th, 2020
396
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. m = 5;
  2. printf(strcat("element count = ", num2str(m),"\n"));
  3. x = [1, 2, 0, 8,9];
  4.  
  5. for i = 1:length(x)
  6.   printf(strcat("x[",num2str(i), "]= ",num2str(x(i)), "\n" ));
  7.  endfor
  8.  
  9. mul = 1
  10. sum = 0
  11. flag = 0
  12. for i = x  
  13.   if(i == 0)
  14.     flag = 1;
  15.     continue;
  16.   else
  17.     if(!flag)
  18.       mul *= i;
  19.     else
  20.       sum += i;
  21.     endif
  22.   endif
  23. endfor
  24.  
  25. printf(strcat("composition before 0 = ",num2str(mul), "\n"));
  26. printf(strcat("sum after 0 = ",num2str(sum), "\n"));
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×