Q:

C program to read a name and print its 10 times using goto statement

0

C program to read a name and print its 10 times using goto statement

Given a name (string) and we have to print its 10 times using goto in C language.

goto is a jumping statement, which transfers the program's control to specified label, in this program, we are reading a name (string) by the user and printing its 10 times.

Example:

Input: 
Enter the name: Manju

Output:
Manju, Manju, Manju, Manju, Manju, Manju, Manju, Manju, Manju, Manju,

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program to print name (string) 10 times using goto in C

#include<stdio.h>

int main()
{
	//declare the variable
	int count;
	char name[50];

	//input value of name
	printf("Enter the name: ");
	scanf("%s",name);

	//counter initialization with 1
	count=1;

	//defining lable 
	start:
	printf("%s, ",name);
	count++;
	if(count<=10)
		goto start;

	return 0;
}

Output

Enter the name: Manju
Manju, Manju, Manju, Manju, Manju, Manju, Manju, Manju, Manju, Manju,

This is how we can print name (string) 10 times, using goto statement? If you liked or have any issue with the program, please share your comment.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C program to print square and cube of all numbers ... >>
<< C program to print table of a given number using g...