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

In this C program, we are going to learn how to print a given name (string) 10 times using the goto statement? Here, we are reading a name and printing it's 10 times.
Submitted by Manju Tomar, on November 07, 2017

Problem 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,

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.

C Goto Programs »


Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.