C program to display forward branching using goto statement.

Forward branching using goto.
Syntax-

Statement(s);
goto Label;
Statement(s);
.
.
Label:

Example-


C program to calculate squareroot of given number.

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main(){
int n;
float s;
clrscr();
printf("Enter a positive integer\n");
scanf("%d",&n);
if (n<=0) goto XYZ;
s=sqrt(n);
printf("sqrt of %d = %f\n",n,s);
XYZ:
getch();
}

Comments

Popular posts from this blog

C Language Topics in Hindi and English

C language IMP Questions for BSc/BA/BCom/BCA/BE/BTech/MSc/MCA (CS/IT) I year students