diogoAlves

IFF/Introdução à Programação/Slide/Pag 32/Ex 2

Feb 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. //IFF - Introdução à Programação
  2. //Slide - Página 32 - Exercício 2
  3. #include<stdio.h>
  4. #include<locale.h>
  5.  
  6. int main(){
  7.     setlocale(LC_ALL,"Portuguese");
  8.     int i,n,num,maior,menor;
  9.     printf("Entre com a quantidade de números que serão inseridos: ");
  10.     scanf("%d",&n);
  11.     for (i=0;i<n;i++){
  12.         printf("Entre com o %dº valor: ",(i+1));
  13.         scanf("%d",&num);
  14.         if(i==0){
  15.             maior=num;
  16.             menor=num; 
  17.         }
  18.         if(maior<num) maior=num;
  19.         if(menor>num) menor=num;
  20.     }
  21.     printf("O maior valor foi %d e o menor foi %d.",maior,menor);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment