A practical introduction to Pascal programming language - GIARA
A practical introduction to Pascal programming language - GIARA
A practical introduction to Pascal programming language - GIARA
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
A Practical Introduction <strong>to</strong> <strong>Pascal</strong> Programming LanguageExercise 3.29. Write a program that reads a sequence of integers and computes the number ofsubsequences of 3 positions so that their product would be a negative (stricly under zero) value.□⊡This problem is very similar <strong>to</strong> the one in the Exercise 3.26.Program 69: Exercise 3.29program c03e29;varn,prevInt,prevPrevInt:integer;counter:integer;beginwriteln(’Please input the sequence of integers ended by zero (0): ’);prevInt:=0;prevPrevInt:=0;counter:=0;repeat(* 1- Reading the next value *)read(n);(* 2- Updating the other variables *)if (prevPrevInt*n*prevInt=3*prevPrevReal*r) thencounter:=counter+1;prevPrevReal:=prevReal;prevReal:=runtil(r