Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int *build_array(int n)
- {
- int *new_array,i,num;
- new_array = (int*)malloc(n*sizeof(int));
- if (new_array == NULL)
- {
- printf("Memory faild\n");
- exit(1);
- }
- for (i = 0;i < n; i++)
- {
- printf("Enter number between -30 to 30\n");
- scanf("%d",&num);
- while (!((num <= 30) && (num >= -30)))
- {
- printf("The number you entered is not in the designated limits\nplease enter again:\n");
- scanf("%d",&num);
- }
- new_array[i]=num;
- }
- return new_array;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement