Write a program to calculate square root using the goto statement.
C Program
#include <stdio.h>#include <math.h>int main(){int num;float sqrtvalue;printf("Enter a number : ");scanf("%d", &num);goto sqrtNum;sqrtNum:sqrtvalue = (float)sqrt(num);printf("Sqrt of %d is %f", num, sqrtvalue);return 0;}
Input:
Enter a number : 8
Output:
Sqrt of 8 is 2.828427
No comments:
Post a Comment