Guest User

Untitled

a guest
May 26th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5.  
  6. int main (){
  7.     int *t1;
  8.     int size, i, tbiggest=0, tsmallest=10000000;
  9.    
  10.     srand(time(NULL));
  11.    
  12.     printf("Enter size of an array: ");
  13.     scanf("%d", &size);
  14.    
  15.     t1 = (int*)malloc(size * sizeof(int));
  16.    
  17.     printf("\nArray: \n");
  18.    
  19.     for(i=0; i<size; i++) t1[i] = rand()%100;
  20.     for(i=0; i<size; i++) printf("[%d]",t1[i]);    
  21.    
  22.     printf("\n\n");
  23.    
  24.     for(i=0; i<size; i++){
  25.              tbiggest = t1[i] > tbiggest ? t1[i] : tbiggest;
  26.              tsmallest = t1[i] < tsmallest ? t1[i] : tsmallest;
  27.     }
  28.    
  29.     printf("\nthe biggest value: %d\nthe smallest value: %d", tbiggest, tsmallest);
  30.    
  31.     printf("\n\n");
  32.    
  33.     system("pause");
  34.     return 0;
  35. }
Add Comment
Please, Sign In to add comment