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 8972817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:18:31+00:00 2026-06-15T18:18:31+00:00

I am learning C programming and wrote a simple program to learn function in

  • 0

I am learning C programming and wrote a simple program to learn function in C. I have used two functios here, although the first one works but not the second one !

Here is the simple code:

#include<stdio.h>

void main() {
  int a,b,c,sum;
  printf("Input your numbers one by one:\n");
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  printf("You have put %d, %d, %d\n\n", a, b, c);
  max (a,b,c);
  min (a,b,c);
}

void max (int a, int b, int c) {
  int sum;
  a=sum;
  if(sum>b)
    sum=b;
  if(sum>c)
    sum=c;
}

void min (int f, int g, int h) {
  int sum;
  sum=f;
  if(sum<g)
    sum=g;
  if(sum<h)
    sum=h;
  printf("The lowest value is:%d\n\n\n",sum);
}

Can anyone tell me why this happens and the solution?

  • 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-15T18:18:32+00:00Added an answer on June 15, 2026 at 6:18 pm

    None of your function should work. The first one set in the variable a the current value of sumwhich is unitialized.

    Then when searching for the MAX value, you check if current sum (supposed to be a) is greater than b and if it is you store b value in sum.

    Then if you want to call a function before it is defined you need to put the prototype of the function at the beginning of your file. As you are calling min() and max() before their definition you are having compilation errors.

    It should be like this:

    #include<stdio.h>
    
    void max (int a, int b, int c);
    void min (int f, int g, int h);
    
    void main()
    {
      int a,b,c,sum;
      printf("Put your numbers throughly one by one:\n");
      scanf("%d", &a);
      scanf("%d", &b);
      scanf("%d", &c);
      printf("You have putted %d, %d, %d\n\n", a, b, c);
      max (a,b,c);
      min (a,b,c);
    }
    
    void max (int a, int b, int c)
    {
        int sum;
        sum = a;
        if(sum<b)
            sum=b;
        if(sum<c)
            sum=c;
    
        printf("The max value is:%d\n\n\n",sum);
    }
    
    void min (int f, int g, int h)
    {
        int sum;
        sum=f;
        if(sum>g)
            sum=g;
        if(sum>h)
            sum=h;
    
        printf("The min value is:%d\n\n\n",sum);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning socket programming in c, I wrote this simple program to accept
I am learning C++ for the first time. I have no previous programming background.
So I'm learning about socket programming and have wrote a nifty little chat server.
I am learning java servlet programming and I wrote a program to upload files,
I've been learning sqlite3 programming in C++ for the first time and this error
I am still learning socket programming (using Perl) but I have both options (
I have been learning functional programming and I come to idea, to assemble mathematical
I am learning socket programming for use in an upcoming project, and I have
I wrote a program to compile a simple text program to a compiled executable...
I just started learning C++ and I wrote this sample program from the text

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.