Advertisement
davsank

Untitled

Apr 24th, 2011
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. int *build_array(int n)
  2. {
  3.     int *new_array,i,num;
  4.  
  5.     new_array = (int*)malloc(n*sizeof(int));
  6.  
  7.         if (new_array == NULL)
  8.         {
  9.             printf("Memory faild\n");
  10.             exit(1);
  11.         }
  12.         for (i = 0;i < n; i++)
  13.         {
  14.             printf("Enter number between -30 to 30\n");
  15.             scanf("%d",&num);
  16.             while (!((num <= 30) && (num >= -30)))
  17.             {
  18.                 printf("The number you entered is not in the designated limits\nplease enter again:\n");
  19.                 scanf("%d",&num);
  20.             }
  21.             new_array[i]=num;
  22.         }
  23.  
  24.         return new_array;
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement