Printing a message with ints and chars.

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.
#include <stdio.h>

int main(void) {
 char letterToQuit;
 int numPresses;

letterToQuit = '?';
 numPresses = 2;

printf("Press the %c key %d times to quit.\n", letterToQuit, numPresses);
scanf("%c", &letterToQuit);

return 0;

Outputting all combinations.

 Output all combinations of character variables a, b, and c, using this ordering:
abc acb bac bca cab cbaSo if a = ‘x’, b = ‘y’, and c = ‘z’, then the output is: xyz xzy yxz yzx zxy zyx


#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 );


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;