Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9318611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:10:22+00:00 2026-06-19T03:10:22+00:00

I am trying to make is so that my program will start over once

  • 0

I am trying to make is so that my program will start over once the answer is given. It just won’t function again once I run it once. I want to make it functional to where the user doesn’t have to start the program up again. Thanks!

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


int main()
{
    float firstnum, secondnum, answer;
    char function;

    printf("\nHello and welcome to my calculator!\n");                                             //Intro

    start:                                                                                         //Area to loop to when program completes

    printf("\nPlease input the function you would like to use.  These include +, -, *, /.\n");     //Asking for function input

    scanf("%c", &function);                                                                        //Receiving Function Input

    printf("\nNow please input the two variables.\n");                                             //Asking for variables

    scanf("%f", &firstnum);

    scanf("%f", &secondnum);                                                                       //Receiving Input for Variables

    if (function == '+')                                                                           //Doing calculation
    {
            answer = firstnum+secondnum;
    }
    else if (function == '-')
    {
    answer = firstnum-secondnum;
    }
    else if (function == '*')
    {
    answer = firstnum*secondnum;
    }
    else if (function == '/')
    {
    answer = firstnum/secondnum;
    }
    else
    {
            printf("Sorry that was an incorrect function.  The correct inputs are +, -, *, /.");       //If they don't follow the directions
    }

    printf("Your answer is %f \n", answer);                                                        //Answer

    goto start;                                                                                    //Loop

return 0;

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:10:24+00:00Added an answer on June 19, 2026 at 3:10 am

    This is why you use loops. (And try not to use goto for this).

    #include <stdio.h>
    #include <math.h>
    
    
    int main() {
    
        float firstnum, secondnum, answer;
        char function, buffer[2];
    
        while(1) {      
    
            printf("\nHello and welcome to my calculator!\n");                                             
    
            printf("\nPlease input the function you would like to use.  These include +, -, *, /.\n");     
            scanf("%s", &buffer);   
            function = buffer[0];
            printf("\nNow please input the two variables.\n");  
            scanf("%f", &firstnum);
            scanf("%f", &secondnum);
            if (function == '+') answer = firstnum+secondnum;
            else if (function == '-') answer = firstnum-secondnum;
            else if (function == '*') answer = firstnum*secondnum;
            else if (function == '/') answer = firstnum/secondnum;
            else printf("Sorry that was an incorrect function.  The correct inputs are +, -, *, /.");    
    
            printf("Your answer is %f \n", answer);                                                               
            } 
    
         return 0;
         }
    

    This should go in an infinite loop, so use an input from the user to break; the loop to exit the program


    Note : I have replaced the scanf %c with %s indicating an input of a string & used a buffer.

     scanf("%s",&buffer); function = buffer[0];
    

    (Updated as per discussion in comments)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so I'm trying to make a little gag program that will run away
I am trying to make a program that will find similar images from a
I'm trying to make a chat program, that will pull the server every 2
I'm trying to make a bash script that will talk to a java program
Again, I'm trying to make a simple program. It will read some kind of
Im trying to make a program that retrieves an endless amount of numbers that
I'm trying to make a program that, using pointers, detects lines in an image
I'm trying to make a program that lets you input any one-step equation, and
I'm trying to make a program that can be hosted by many peoples, like
I am trying to make a program that can take an .mp3 file from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.