Write a program  that allows to enter 10 integers and say if these integers are

consecutive or not

******** In Algorithm ********

Algorithm Variables i,tab[10],test: integers Begin

test ← 0 write(" Enter an integer :") read(tab[1]) for i from 2 to 10 write("Enter an integer :") read(tab[i]) if( tab[i] < tab[i-1]) then test ← 1 next_if next_for

if(test = 0) then write("the elements are consecutive ") else write("the elements are not consecutive ") next_if End Result ==> 0 1 2 3 4 6 5 7 8 9 the elements are not consecutive

******** In language C ********

#include <stdio.h> #include <conio.h> int main() { int i,tab[10],test=0; printf(" Enter an integer :"); scanf("%d",&tab[0]); for(i=1;i<=9;i++){ printf(" Enter an integer :"); scanf("%d",&tab[i]); if ( tab[i] < tab[i-1]) test=1; } if (test==0) printf("the elements are consecutive "); else printf("the elements are not consecutive "); return 0; }


******** In C++ ********

#include <iostream> using namespace std; int main() { int i,tab[10],test=0; cout<<" Enter an integer :"; cin>>tab[0]; for(i=1;i<=9;i++){ cout<<" Enter an integer:"; cin>>tab[i]; if ( tab[i] < tab[i-1]) test=1; } if (test==0) cout<<"the elements are consecutive "; else cout<<"the elements are not consecutive"; return 0; }