|
CS256 - Principles of Structured Design
Fall 2021
|
Displaying ./code/h5sol/scream.c
/*
p05.c - prompt the user for two numbers, representing the number of A's and the
number of H's, then print the specified number of A's followed by the
specified number of H's
*/
#include <stdio.h>
int main(){
int a, h; //declaring variables for a and h
//print a statement asking the user for number of A's
//then use scanf to get the number and store i
printf("How many A's should I print?> ");
scanf("%d", &a);
//do the same thing as above, but this time, you're asking for the number of H's
printf("How many H's should I print?> ");
scanf("%d", &h);
//then use a loop to print the specified number of A's
//Just print the uppercase A character, do NOT print a newline character
for(int i = 0; i < a; i++){
printf("A");
}
//then do the same as above, except we're now printing H's
for(int i = 0; i < h; i++){
printf("H");
}
//then after both loops finish, print a newline character("\n")
printf("\n");
return 0;
}
|