For the following values, list the smallest possible C data type it can fit into:
Analyze the following code, and answer the questions:
#include <stdio.h> #define SIZE 31 int main() { char data[SIZE]; int i; printf("Enter a string of up to %d letters (upper and lowercase), NO spaces: ", (SIZE-1)); scanf("%s", data); for(i = 0; i < SIZE; i++) { if (data[i] != 0) { if ((data[i] == 97) || (data[i] == 101) || (data[i] == 105) || (data[i] == 111) || (data[i] == 117)) { data[i] = data[i] - 32; } } else { break; } } printf("After processing, the string is: %s\n", data); return(0); }
Analyze the following code, and answer the questions:
#include <stdio.h> #define SIZE 31 int main() { char data[SIZE]; int i, j = 0; printf("Enter a string of up to %d letters (upper and lowercase), NO spaces: ", (SIZE-1)); scanf("%s", data); for(i = 0; i < SIZE; i++) { if (data[i] != 0) { if ((data[i] == 101) || (data[i] == 69)) { j = j + 1; } } else { break; } } printf("After processing, j is: %d\n", j); return(0); }
Analyze the following code, and answer the questions:
#include <stdio.h> #define SIZE 31 int main() { char data[SIZE]; int i, j = 0, k = 0; printf("Enter a string of up to %d letters (upper and lowercase), NO spaces: ", (SIZE-1)); scanf("%s", data); for(i = 0; i < SIZE; i++) { if (data[i] != 0) { if ((data[i] >= 65) && (data[i] <= 90)) { j = j + data[i]; k++; } } else { break; } } i = j / k; j = i; printf("After processing, j is: %c\n", j); return(0); }
Analyze the following code, and answer the questions:
#include <stdio.h> #include <stdlib.h> #include <time.h> #define SIZE 31 int main() { char data[SIZE]; int i, j = -1, k = 0; srand(time(NULL)); for(i = 0; i < SIZE; i++) { data[i] = rand() % 2599 + 1; } for(i = 0; i < SIZE; i++) { if (data[i] > j) j = data[i]; } printf("After processing, j is: %d\n", j); return(0); }