Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are to write a short C program. The program will input a user’s first name f

ID: 3798758 • Letter: Y

Question

You are to write a short C program. The program will input a user’s first name followed by a number that represents the number of times to display the name. The output will be a line number followed by the NAME. This will be displayed X times. You are to include your C Source and your Design Tool. This is how you will input a word. A word is a group of characters. In programming, a group of characters is called a STRING. In the C programming language there is no actual data type for a STRING. In order to represent a string do the following: 1. Declare the string a. char firstName[50]; // the string is firstName. It will hold a group of characters. The actual number of characters is actually 49. The 50th position holds the end of string marker. C will populate the end of string for you. 2. To input a string a. scanf(“%s”, firstName); // do not use the & when scanning a STRING. 3. To output a string a. printf(“Hello the string was %s. ”, firstName);

Explanation / Answer

#include <stdio.h>

int main(int argc, char *argv[]){
char firstName[50];
int numOfTimes, i;
scanf("%s", firstName);
scanf("%d", &numOfTimes);
for(i = 1; i <= numOfTimes; i++){
printf("%d %s ", i, firstName);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote