Untitled
unknown
plain_text
18 days ago
1.4 kB
9
Indexable
Never
Question 2 #include<stdio.h> int findMe(int prompt[], int size, char *alphabet) { char str[size]; for (int i = 0; i <= size; i++) { if (prompt[i] > 0) { if (*alphabet == 'Z') { str[i] = *alphabet - (26 - prompt[i]); } else { str[i] = *alphabet + prompt[i]; } } if (prompt[i] < 0) { if (*alphabet == 'A') { str[i] = *alphabet + (26 + prompt[i]); } else { str[i] = *alphabet + (prompt[i]); } // printf("%s", str); } if (prompt[i] == 0) { break; } } for (int i = 0; i < size - 1; i++) { printf("%c", str[i]); } } int main() { char alphabet; printf("Enter the character: "); scanf("%c", &alphabet); int size; printf("Enter the size:"); scanf("%d", &size); int prompt[size]; printf("Please Enter the Promt: "); for (int i = 0; i < size; i++) { scanf("%d", &prompt[i]); } for (int i = 0; i < size; i++) { printf("%d ", prompt[i]); } printf("\n"); int result = findMe(prompt, size, &alphabet); } /// A // 2, 3, -1, 0 //C, D, Z
Leave a Comment