Tuesday, April 14, 2020

Goto statement in C


  • Flowchart :
  • Syntax :
goto label;
... .. ...
... .. ...
label: 
statement;
  • Program :
#include<stdio.h>
#include<conio.h>
void main()
{
   int sum,i;
   clrscr();
   printf("\n----------------GOTO STATEMENT----------------");
   printf("\nEnter the sum value :");
   scanf("%d",&sum);
   for(i=0;i<=10;i++)
  {
sum=sum+i;
if(i==5)
        {
   goto addition;
}
   }

   addition:
   printf("\nThe sum is : %d",sum);
   getch();
}

  • Output :


No comments:

Post a Comment

Function Overloading in C++

https://monitechvenkat1620.blogspot.com Program : #include <iostream> using namespace std; int c(int x, int y) {   return...