Home » C programs » C 'goto' programs

C program to print table of 2 using goto statement



In this C program, we are going to learn how to print table of a number? Here, we are printing the table of 2 using goto statement?
Submitted by Manju Tomar, on November 07, 2017

Give a number (2) and we have to print its table using C program.

goto is a jumping statement, which transfers the program’s control to specified label, in this program we will print the table of 2.

Example:

Input: 2 (given in the program)

Output:
2*1=2
2*2=4
2*3=6
2*4=8
2*5=10
2*6=12
2*7=14
2*8=16
2*9=18
2*10=20

Program to print table of 2 using goto statement in C

#include<stdio.h>

int main()
{
	//declare variable
	int count,t,r;

	//assign 2 to the variable 't'
	t =2;

	count=1;

	start:
	if(count<=10)
	{
		//Formula of table
		r=t*count;
		printf("%d*%d=%d\n",t,count,r);
		count++;
		goto start;
	} 

	return 0;
}

Output

2*1=2
2*2=4
2*3=6
2*4=8
2*5=10
2*6=12
2*7=14
2*8=16
2*9=18
2*10=20

This is how we can print table of 2 using goto statement? If you liked or have any issue with the program, please share your comment.






Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.




Comments and Discussions





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.