Bloque 3 (Reducido A Temario de Examen)
Bloque 3 (Reducido A Temario de Examen)
Bloque 3 (Reducido A Temario de Examen)
#include <stdio.h>
#include <ctype.h>
#define ALPHABET_SIZE 26
int main() {
int letterCount[ALPHABET_SIZE] = {0};
int totalLetters = 0;
char ch;
printf("Letter Frequencies:\n");
for (int i = 0; i < ALPHABET_SIZE; i++) {
if (letterCount[i] > 0) {
printf("%c: %.2f%%\n", i + 'a', (double)letterCount[i] / totalLetters * 100);
}
}
return 0;
}
2.
#include <stdio.h>
#define MAX_ROWS 10
#define MAX_COLS 10
int main() {
int firstMatrix[MAX_ROWS][MAX_COLS], secondMatrix[MAX_ROWS][MAX_COLS],
resultMatrix[MAX_ROWS][MAX_COLS];
int firstRows, firstCols, secondRows, secondCols;
printf("Matrix 1\n");
readMatrix(firstMatrix, &firstRows, &firstCols);
printf("Matrix 2\n");
readMatrix(secondMatrix, &secondRows, &secondCols);
if (firstCols != secondRows) {
printf("Multiplication not possible.\n");
return 1;
}
return 0;
}
3.
#include <stdio.h>
int main() {
float num1, num2;
char operation, choice;
do {
printf("Enter operation (+, -, *, /) or 'q' to quit: ");
scanf(" %c", &operation); // Space before %c to skip whitespace
return 0;
}
5.
#include <stdio.h>
#include <string.h>
while (1) {
const char *p = strstr(tmp, pattern);
// Copy replacement
memcpy(insert_point, replacement, repl_len);
insert_point += repl_len;
int main() {
char text[MAX_TEXT_SIZE], pattern[MAX_PATTERN_SIZE],
replacement[MAX_PATTERN_SIZE];
return 0;
}
6.
#include <stdio.h>
int main() {
int num;
printf("Enter an integer: ");
scanf("%d", &num);
return 0;
}
7.
#include <stdio.h>
int main() {
int n;
printf("Enter number of elements: ");
scanf("%d", &n);
int arr[n];
printf("Enter %d integers: ", n);
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
bubbleSort(arr, n);
return 0;
}
8.
#include <stdio.h>
#include <string.h>
int main() {
char words[MAX_WORDS][MAX_WORD_LENGTH];
int n;
sortWords(words, n);
return 0;
}
9.
#include <stdio.h>
#include <string.h>
int main() {
char pattern[MAX_LINE_LENGTH], line[MAX_LINE_LENGTH];
return 0;
}