A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C program to read a name and print its 10 times using goto statement
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)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now