C-programming "To repeat particular steps after getting instead of terminating the program"

//program to calculate horizontal Distance and Reduced Level by tacheometry
#include <stdio.h>
#include <math.h>

void main()
{
  float m,s,cosine,t,c,d,pi,v,h,hi,bm,rl,r;
  printf("enter value of stadia intercept,theta,bench mark,central reading on bm,central reading on staff station");
  printf("\n");
  scanf("%f %f %f %f %f", &s, &t, &bm, &r, &h);
  m=100; c=0;
  pi=22.0/7.0;
  cosine=cos(t*pi/180.0);
  d=((m*s*pow(cosine,2))+(c*cosine));
  v=d*tan(t*pi/180.0); hi=bm+r-v; rl=hi+v-h;
  printf("distance=%f meters, vertival distance=%f meters,height of instrument=%f meters,reduced level=%f meters",d,v,hi,rl);
}

Above I have provided the program to calculate Horizontal distance and Reduced Level.

I have a question that after printing the answer that is 12th line in the image. Can I repeat the steps 8 to 12 again instead of restarting the program?

I am a beginner in C programming. So I am sorry if I didn't specified something important.


ANSWERS:


You need to learn loops (see comments) but to help, your code could look like this:

#include <stdio.h>
#include <math.h>

int main(void)
{
    do {
        float m,s,cosine,t,c,d,v,h,hi,bm,rl,r;
        printf("enter value of stadia intercept,theta,bench mark,central reading on bm,central reading on staff station");
        printf("\n");
        if (scanf("%f %f %f %f %f", &s, &t, &bm, &r, &h)!=5)
            break;
        m=100; c=0;
        cosine=cos(t*M_PI/180.0);
        d=((m*s*pow(cosine,2))+(c*cosine));
        v=d*tan(t*M_PI/180.0); hi=bm+r-v; rl=hi+v-h;
        printf("distance=%f meters, vertival distance=%f meters,height of instrument=%f meters,reduced level=%f meters",d,v,hi,rl);
    } while (1);
    return(0);
}

the do {...} while(1); is an infinite loop but the loop breaks when the user does not enter the 5 parameters. After the loop, the main function returns zero, which will be forwarded to the operating system, which interprets zero as success.



 MORE:


 ? Clang C Block : block function definition after call
 ? How to send data from Arduino Uno to PC using the USB port
 ? read lines from file with fgets and compare each line with strncmp in c
 ? sinch calling app-to-phone why receiver getting calls from random numbers?
 ? LabelView is not appearing programmatically IOS Swift
 ? Display a message after uninstalling iOS application
 ? Required iPv6 compatibility - rejected by Apple iOS app
 ? How to get the Instagram Media_ID of video In Ios.?
 ? Missing label colors in barplot when not using add_trace
 ? perform many regressions row by row