Q:

C program to print 1, 11, 31, 61, ... 10 times using goto statement

0

C program to print 1, 11, 31, 61, ... 10 times using goto statement

The series is

1, 11, 31, 61, … 10 times

Consider the series, there is no constant difference between the terms, the difference of 10, 20, 30 etc. So , we need to increase difference value also by 10.

All Answers

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

Program to print 1, 11, 31, 61, ... 10 times using goto statement in C

#include<stdio.h>

int main()
{
	int count,a,diff;

	count=1;	//loop counter
	a=1;		//series starting number
	diff=10;	//difference variable initialization
	
	start:	//label
	printf(" %d ",a);
	a=a+diff;
	diff=diff+10;
	count++;
	if(count<=10)
		goto start;

	return 0;
}

Output

1  11  31  61  101  151  211  281  361  451 

This is how we can print a numeric series like 1, 11, 31, 61,..., 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 ASCII values of all uppercase a... >>
<< C program to print square and cube of all numbers ...