✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.
The following piece of code encrypts the line of text taken as input by shifting each character of the line by a key value. It uses the index notation. (Assume MAX is a #define constant.)
char line[MAX]; int i = 0, key = 4; printf("Enter a line of text:"); scanf("%[^\n]", line); while (line[i]) { putchar(line[i]+key); i++; }
In an attempt to rewrite the entire code using pointer notation, a beginner program made the following attempt:
char line[MAX]; int key = 4; printf("Enter a line of text: "); scanf("%[^\n]", line); while (*line) { putchar(*line + key); line++; }
Unfortunately, the code would not compile. Can you find the mistake and fix it? You do not have to rewrite the entire code segment, but only the parts you are modifying.
Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!