Vous êtes sur la page 1sur 2

Reponse au devoir libre:

 Realise par: Naouil Saad et Nachid Mohamed Reda.

EXERCICE1:
#include<iostream>
using namespace std;
int main(){
int a;
int somme=0;
int sommefinale=0;
cout<<"a=" ;
cin>>a;
while(a>0){
sommefinale+=a%10;
a/=10;
}
while(sommefinale>9){
somme=sommefinale;
sommefinale=0;
}
While(somme>0){
Sommefinale+=somme%10;
}
Cout<<sommefinale<<endl;
Return 0;
}

EXERCICE2:
#include<iostream>
Using namespace std;
Int main(){
Int n;
Int p;
Int faut=1;
Int position=0;
do{
cout<<"donner n>0<<endl;
cin>>n;
if(n<=0){
faut++ ;
}
}while(n<=0);
While(n>0){
P=n%10;
n/=0;
cout<<" le chiffre a la position "<<pisition<<" depuis la droite est "<<p<<endl;
positin ++;
}
cout <<" le programme se termine apres "<<faut<< " tentatives "<<endl;
return 0;
}

EXERCICE3:
#include <iostream>
Using namespace std;
Int main(){
Int n;
Int m=0;
cout<<"donner un nombre n"<<endl;
cin >>n;
while(n>0){
m=m*10+n%10;
n/=10;
}
Cout<<"l'inverse de votre nombre est "<<m;
Return 0;
}

EXERCICE4:
#include < iostream>
using namespace std;
int main(){
long int n;
long int b=1;
long int c=0;
cout<<" donner uyn nombre reel "<<endl;
cin>n;
while(n>b){
c++;
b=b*c;
}
If(n==b){
cout <<" le nombre "<<n<<" est un factoriel de nombre "<<c <<endl;
}else{
Cout<<n<<" n’est pas un factoriel ";
}
Return 0;
}

Vous aimerez peut-être aussi