Deitel & Deitel, C How to Program 6th Edition, Exercise 9.18 (Reading Strings in Quotes)
// 9.18 (Reading Strings in Quotes)
#include <stdio.h>
int main() {
char string[20];
printf("Enter a word: ");
scanf("%s", string);
printf("The word is: ");
printf("%s\n", string);
printf("Enter a word: ");
scanf("%s", string);
printf("The word is: ");
printf("%s\n", string);
printf("Enter a word: ");
scanf("%s", string);
printf("The word is: ");
printf("%s", string);
printf("\n\n\n");
return 0;
}
OUTPUT
Enter a word: suzy
The word is: suzy
Enter a word: 'suzy'
The word is: 'suzy'
Enter a word: "suzy"
The word is: "suzy"
Press any key to continue . . .
#include <stdio.h>
int main() {
char string[20];
printf("Enter a word: ");
scanf("%s", string);
printf("The word is: ");
printf("%s\n", string);
printf("Enter a word: ");
scanf("%s", string);
printf("The word is: ");
printf("%s\n", string);
printf("Enter a word: ");
scanf("%s", string);
printf("The word is: ");
printf("%s", string);
printf("\n\n\n");
return 0;
}
OUTPUT
Enter a word: suzy
The word is: suzy
Enter a word: 'suzy'
The word is: 'suzy'
Enter a word: "suzy"
The word is: "suzy"
Press any key to continue . . .
Comments
Post a Comment