Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.14 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. void clearA(char clear_A_Array[], int num_A);
  6.  
  7. int main()
  8. {
  9.     srand((int) time(NULL));
  10.     int int_array[64];
  11.     int count;
  12.     char char_array[72];
  13.     float float_array[50];
  14.  
  15.  
  16.  
  17.  
  18.  
  19.     for(count=0; count < 64; count++) //int array
  20.     {
  21.        int_array[count] = rand()%(56) -13;
  22.     }
  23.  
  24.     for(count=0; count < 64; count+=2)
  25.     {
  26.        printf("Integer %d: %d\t\tInteger %d: %d\n", count, int_array[count], count+1, int_array[count+1]);
  27.     }
  28.  
  29.     printf("\n\n");
  30.     count=0; //reset count
  31.  
  32.     while(count < 72) //char array
  33.     {
  34.         char_array[count] = (char)(rand()%(16)+69);
  35.         char_array[count+1] = (char)(rand()%(16)+69);
  36.         printf("Character %d: %c\t\tCharacter %d: %c\n", count, char_array[count], count+1, char_array[count+1]);
  37.         count+=2;
  38.     }
  39.  
  40.     printf("\n\n");
  41.     count=0; //reset count
  42.  
  43.     do
  44.     {
  45.         float_array[count]=(((((((((((((rand()%(20045))- 1079)/((((100.00)))))))))))))));
  46.         float_array[count+1]=(((rand()%(20045))- 1079)/(100.00));
  47.         printf("Float %d: %lf\t\tFloat %d: %lf\n", count, float_array[count], count+1, float_array[count+1]);
  48.         count+=2;
  49.     }
  50.  
  51.    while (count < 50);
  52.  
  53.    printf("\n\n");
  54.  
  55.    clearA(char_array, 72);
  56.    one1won(float_array, 50);
  57.  
  58.    return 0;
  59. }
  60.  
  61. void clearA(char clear_A_array[], int num_A)
  62. {
  63.     int ltrA=65;
  64.     int A_count=4;
  65.     printf("character %d: %c\n\n", A_count, clear_A_array[A_count]);
  66.     for(A_count=0; A_count < num_A; A_count++)
  67.     {
  68.         clear_A_array[A_count]=(char)ltrA;
  69.     }
  70. }
  71.  
  72. void one1won(float one1won_array[], int num_B)
  73. {
  74.     float float_sum;
  75.     int float_count;
  76.     int float_final=111;
  77.     for(float_count=0; float_count < num_B; float_count++)
  78.     {
  79.         float_sum=float_sum + one1won_array[float_count];
  80.     }
  81.     printf("The sum of all values in the array is %lf\n", float_sum);
  82.  
  83.     for(float_count=0; float_count < num_B; float_count++)
  84.     {
  85.         one1won_array[float_count]=(float)(float_final)/(100);
  86.     }
  87.     printf("The sum of all values in the array is %lf", one1won_array[float_count]);
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement