Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- #include <time.h>
- int main (){
- int *t1;
- int size, i, tbiggest=0, tsmallest=10000000;
- srand(time(NULL));
- printf("Enter size of an array: ");
- scanf("%d", &size);
- t1 = (int*)malloc(size * sizeof(int));
- printf("\nArray: \n");
- for(i=0; i<size; i++) t1[i] = rand()%100;
- for(i=0; i<size; i++) printf("[%d]",t1[i]);
- printf("\n\n");
- for(i=0; i<size; i++){
- tbiggest = t1[i] > tbiggest ? t1[i] : tbiggest;
- tsmallest = t1[i] < tsmallest ? t1[i] : tsmallest;
- }
- printf("\nthe biggest value: %d\nthe smallest value: %d", tbiggest, tsmallest);
- printf("\n\n");
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment