Print a message telling a user to press the letterToQuit key numPresses times to quit. End with newline. Ex: If letterToQuit = ‘q’ and numPresses = 2, print:
Press the q key 2 times to quit.
solution
Outputting all combinations.
#include <stdio.h> int main(void) { char a; char b; char c; a = 'x'; b = 'y'; c = 'z'; printf("%c%c%c %c%c%c %c%c%c %c%c%c %c%c%c %c%c%c", a, b, c, a, c, b, b, a, c, b, c, a, c, a, b, c, b, a ); printf("\n"); return 0; }
Successive letters.
Declare a character variable letterStart. Write a statement to read a letter from the user into letterStart, followed by statements that output that letter and the next letter in the alphabet. End with a newline. Hint: A letter is stored as its ASCII number, so adding 1 yields the next letter. Sample output assuming the user enters ‘d’: de
#include <stdio.h> int main(void) { char letterStart; char letter2; scanf("%c", &letterStart); letter2 = (letterStart + 1); printf("%c%c\n", letterStart, letter2); return 0; }