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

  • Home
  • SEARCH
  • 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 7923051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:10:37+00:00 2026-06-03T17:10:37+00:00

Learning C here, and I’m pretty confused on how to use function prototypes. I’m

  • 0

Learning C here, and I’m pretty confused on how to use function prototypes.

I’m mainly having a problem calling the function into main. I’m sure I have something messed up in here because all this does is print whatever’s in memory.

Thank you for the help.

#include <stdio.h>


double source_volt(double vs);


int main()
{
    double source_volt(double vs);
    double vs;
    printf("%lf", vs);
    return 0;
}


double source_volt(double vs)
{

    int valid = 0;
    do
    {
        printf("Enter source voltage Vs in volts: ");
        scanf("%lf", &vs);

        if (vs < 0 || vs > 100)
        {
            valid = 0;
            printf("Please enter a number between 0 and 100.\n");
        }
        else
            valid = 1;
    }while(!valid);
    return vs;
}
  • 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-03T17:10:39+00:00Added an answer on June 3, 2026 at 5:10 pm

    This is what is not working for you:

    int main()
    {
        double source_volt(double vs); //You already declared the function, 
                                       //you dont need the doubles
        double vs;
        printf("%lf", vs);
        return 0;
    }
    

    Instead:

    int main()
    {
        double vs;
        vs = double source_volt(vs); //The double keyword is gone
        printf("%lf", vs);
        return 0;
    }
    

    But really, you don’t need an argument at all in source volt.

    You could rewrite that function to:

    double source_volt(void)
    {
        double vs;
        int valid = 0;
        do
        {
            printf("Enter source voltage Vs in volts: ");
            scanf("%lf", &vs);
    
            if (vs < 0 || vs > 100)
            {
                valid = 0;
                printf("Please enter a number between 0 and 100.\n");
            }
            else
                valid = 1;
        }while(!valid);
        return vs;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

new to programmation, im learning and here is probably a very simple problem for
I'm learning javascript and was going through an example here: https://developer.mozilla.org/en/A_re-introduction_to_JavaScript function personFullName() {
I've been learning python here recently....mainly for scripting purposes....since apparently it's supposed to be
New to scheme here and I'm having some trouble learning do loops. I am
I am learning Google App Engine in Python. Here is my problem: I want
I just started learning C and am not sure what the issue is here.
Ok still learning here. If I have one form calling another form like below
Just started learning Jquery - here's my problem: I have six divs on a
I'm learning ruby and can't figure out what's the problem here. formatter = %s
Brand new poster here on StackOverflow. I've been reading and learning here for some

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.