Home »
C programs »
C 'goto' programs
C program to print 1, 11, 31, 61, ... 10 times using goto statement
In this C program, we are going to learn how to print a number series like 1, 11, 31, 61, .. 10 times using C language goto statement?
Submitted by Manju Tomar, on November 09, 2017
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.
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.
C Goto Programs »