-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ026.c
More file actions
41 lines (35 loc) · 960 Bytes
/
Copy pathQ026.c
File metadata and controls
41 lines (35 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Escreva um programa que leia 4 numeros inteiros positivos e verifique se eles formam, na ordem em que foram informmados,
uma PA, PG, duas ao mesmo tempo ou nenhum tipo de progressão.*/
#include <stdio.h>
int PA(int n1, int n2, int n3, int n4){
if (n2-n1 == n3-n2 == n4-n3){
printf("Eh uma PA\n");
}
else{
printf("Nao eh uma PA\n");
}
}
int PG (int n1, int n2, int n3, int n4){
if (n1/n2 == n2/n3 == n3/n4){
printf("Eh uma PG\n");
}
else{
printf("Nao eh uma PG\n");
}
}
int ambosDois(int n1, int n2, int n3, int n4){
if ((n2-n1 == n3-n2 == n4-n3) && n1/n2 == n2/n3 == n3/n4){
printf("Eh uma PA e uma PG\n");
}
else{
printf("Ou um ou outro.\n");
}
}
int main(void){
int n1, n2, n3, n4;
printf("Insira quatro numeros inteiros: ");
scanf("%d%d%d%d", &n1, &n2, &n3, &n4);
PA(n1,n2,n3,n4);
PG(n1,n2,n3,n4);
ambosDois(n1,n2,n3,n4);
}