Advertisement
gabbyshimoni

arrayExample10

Jun 2nd, 2018
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. /*
  2.   מציאת המספר הכי גדול מבין שני מערכים
  3. */
  4.  
  5. int num1[4] = {10, 20, 30, 60};
  6. int num2[4] = {9, 21, 29, 50};
  7. int Max = -999;
  8. void setup() {
  9.   Serial.begin(9600);
  10.   for (int i = 0; i < 4; i++) {
  11.     if (Max < num1[i]) {
  12.       Max = num1[i];
  13.     }
  14.   }
  15.   for (int j = 0; j < 4; j++) {
  16.     if (Max < num2[j]) {
  17.       Max = num2[j];
  18.     }
  19.   }
  20.   Serial.print("The largest number is:");
  21.   Serial.println(Max);
  22. }
  23.  
  24. void loop() {
  25.   // put your main code here, to run repeatedly:
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement