Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //IFF - Programação Estruturada
- //Lista de Exercícios 0 - Exercício 7
- #include<stdio.h>
- void calcular(int n[], int x){
- int maior=0, menor=0;
- for(int i=0;i<x;i++){
- if(i==0){
- menor=n[i];
- maior=n[i];
- }
- if(n[i]<menor) menor=n[i];
- if(n[i]>maior) maior=n[i];
- }
- printf("A soma do maior(%d) e menor(%d) valores: %d\nSubtração: %d",maior,menor,(maior+menor),(maior-menor));
- }
- int main(){
- setbuf(stdout,NULL);
- int x=0;
- printf("Entre com o número de valores que são introduzidos: ");
- scanf("%d",&x);
- int n[x];
- for(int i=0;i<x;i++){
- printf("Entre com o %d° valor: ",i+1);
- scanf("%d",&n[i]);
- }
- calcular(n,x);
- }
Advertisement
Add Comment
Please, Sign In to add comment