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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:19:23+00:00 2026-05-25T23:19:23+00:00

I have to write a program in which main calls other functions that test

  • 0

I have to write a program in which main calls other functions that test a series of number if any are less than a number, if all the series’ numbers are between two limits, and if any are negative.

My code returns the values of 1 for true and 0 for false, but the assignment asks that they be printed as ‘true’ or ‘false’. I’m not sure how to get the bool answers to print as a string from printf. I used if (atl == false) printf("false"); in my at_least.c file and in file main.c, but it returns only a long string of true or false (example: truetruetrue….).

I’m not sure if that is the correct coding and I’m putting it in the wrong spot or there was some other code that I need to use.

This is my main.c file:

#include "my.h"

int main (void)
{
    int     x;
    int     count    = 0;
    int     sum      = 0;
    double  average  = 0.0;
    int     largest  = INT_MIN;
    int     smallest = INT_MAX;
    bool    atlst    = false;
    bool    bet      = true;
    bool    neg      = false;
    int     end;

    while ((end = scanf("%d",&x)) != EOF)
    {
        sumall(x, &sum);                        // Calling function sumall
        count++;
        larger_smaller(x, &largest, &smallest); // Calling function larger_smaller
        if (atlst == false)
           at_least(x, &atlst);                 // Calling function at_least if x < 50
        if (bet == true)
           between(x, &bet);                    // Calling function between if x is between 30 and 40 (inclusive)
        if (neg == false)
           negative(x, &neg);                   // Calling function negative if x < 0
    }

    average = (double) sum / count;
    print(count, sum, average, largest, smallest, atlst, bet, neg);
    return;
 }

My results for a set of numbers:

The number of integers is:           15
The sum is               :         3844
The average is           :       256.27
The largest is           :          987
The smallest is          :          -28
At least one is <  50    :            1     // This needs to be true
All between  30 and  40  :            0     // This needs to be false
At least one is negative :            1     // This needs to be true

This is in C, which I can’t seem to find much on.

Addendum:

This is repeated from an answer below.

This worked for the at_least and negative functions, but not for the between function. I have

void between(int x, bool* bet)
{
    if (x >= LOWER && x <= UPPER)
        *bet = false;
    return;
}

as my code. What’s wrong?

  • 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-05-25T23:19:23+00:00Added an answer on May 25, 2026 at 11:19 pm

    You could use C’s conditional (or ternary) operator:

      (a > b) ? "True" : "False";
    

    Or perhaps in your case:

      x ? "True" : "False";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to write a program that test if two files are duplicates (have
How to write a java program which will tell me whether I have internet
I have to write a program that read from a file that contains the
I have to write a program that sniffs network packets (part1-the simple part). And
I have been assigned wit the task to write a program that takes a
I have to write a program that performs highly computationally intensive calculations. The program
i was told to write program which generate unique 5 digit number ( for
i have question how write program which calculates following procedures http://en.wikipedia.org/wiki/Tetration i have exponential
I am planning to write a program that makes calls to cdrecord. (I am
I have a dummy Java Program, which I want to write in Clojure. It

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.