Rapport TP1
Rapport TP1
Rapport TP1
EXERCICE1:
#include<stdio.h>
int main(){
float longeur,largeur,p,s;
p=2*(longeur+largeur);s=longeur*largeur;
EXERCICE2:
1)#include<stdio.h>
int main(){
int i=0;char c;
do{
printf("Devinette correcte");
2)#include<stdio.h>
int main(){
char c;
printf('a'<=c && c <='z' || 'A'<=c && c<='Z'? 'a'<=c && c <='z'? " c'est une lettre
minuscule" : "c'est une lettre Majuscule" : "Non c'est pas une lettre");
3)
#include<stdio.h>
int main(){
int jour;
do
while(jour<1 || jour>7);
switch(jour){
case 1: printf("Lundi");break;
case 2: printf("Mardi");break;
case 3: printf("Mercredi");break;
case 4: printf("Jeudi");break;
case 5: printf("Vendredi");break;
case 6: printf("Samedi");break;
case 7: printf("Dimanche");break;
default:break;
4)#include<stdio.h>
#include<math.h>
int main(){
float a,b,c,delta;
scanf("%f%f%f",&a,&b,&c);
delta=b*b-4*a*c;
printf(a==0? "La seule solution est : %f" : delta==0? "la seule solution est %f"
: delta>0? "Il y a
deux solutions %f et %f "
}
EXERCICE3:
1)#include<stdio.h>
#include<stdlib.h>
int main(){
char c,nb=0;
for(;;){
scanf(" %c",&c);
nb+=(c=='b');
if(c=='*')
break;
2)
#include<stdio.h>
int main(){
int i,valeur,max,pos;
for(i=0;i<5;i++){
scanf("%d",&valeur);
if(i==0){
max=valeur;pos=0;
else{
max=max<valeur? valeur:max;pos=i;
3)
#include<stdio.h>
#include<math.h>
int main(){
int i,n;
for(i=2;i<=sqrt(n);i++)
if(n%i==0)
EXERCICE4:
1)#include<stdio.h>
int main(){
int N,nb=0;
printf( N==nb? "%d est un nombre parfait " : "%d est nombre imparfait %d",N);
2)#include<stdio.h>
int nb=0;
return n==nb;
int main(){
int N;
scanf("%d",&N);
for(int i=1;i<N;i++)
EXERCICE5:
#include<stdio.h>
int nn=0,nm=0;
int main(){
int n,m;
EXERCICE6:
1)
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
printf("Exercice6Q1(%d)= %d",n,U(n));
2)
#include<stdio.h>
int U(int n){
int main(){
for(int i=0;i<100;i++)
printf("[%d] ",U(i));
EXERCICE7:
1)
#include<stdio.h>
int main(){
int n;float x;
printf("Suite(%d) = %f",n,Suite(n,x));
EXERCICE8:
1)#include<stdio.h>
int main(){
int n;
printf("Factorielle(%d) = %d",n,factoriel(n));
2)
#include<stdio.h>
#include<math.h>
float s=0;
for(int i=0;i<=n;i++)
s+=pow(x,i)/factoriel(i);
return s;
int main()
int n;
float x;
scanf("%d%f",&n,&x);
3)
#include<stdio.h>
#include<math.h>
while(abs(fabs(pow(x,k)/factoriel(k)-pow(x,k)/factoriel(k+1))>pow(10,-6))){
s+=pow(x,k)/factoriel(k);k++;
}
return s;
int main(){
float x;
scanf("%f",&x);
EXERCICE9:
#include<stdio.h>
#include<math.h>
float SommeInverseCarree(){
while(abs(1/pow(n,2)-1/pow(n+1,2))>10E-6)
{s+=1.0/(n*n);n++;}
return s;
int main(){