#include<stdio.h>
#include<stdlib.h>
#include<math.h>
main()
{
int S,i,k,n;
k=0;
S=0;
printf(" donnez n = ");
scanf("%d",&n);
for(i=0;i<n+1;i++)
{
k=i*i;
S=S+k;
}
printf(" S = %d
",S);
system("pause"); }
Exercice 7
:
#include<stdio.h>
#include<stdlib.h>
main()
{
int a,b;
printf(" a = ");
scanf("%d",&a);
printf(" b = ");
scanf("%d",&b);
while(a*b!=0)
{
if(a>b) {
a=a-b;
}
else {
b=b-a;
}
}
if(a==0) {
printf(" le pgcd = %d
",b);
}
else {
printf(" le pgcd = %d
",a);
}
system("pause"); }
Commentaires
Enregistrer un commentaire