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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:49:44+00:00 2026-06-03T07:49:44+00:00

Here is the program that I am trying to compile #include<stdio.h> int main() {

  • 0

Here is the program that I am trying to compile

#include<stdio.h>   
int main()
    {
        int i = 0;
        rec(i);
    }
int rec(int i)
    {
        i = i + 1;
        if (i == 10){return true;}
        rec(i);
        printf("i: %d\n", i);
    }

I am getting this output

$ gcc -o one one.c
one.c: In function ‘rec’:
one.c:10:24: error: ‘true’ undeclared (first use in this function)
one.c:10:24: note: each undeclared identifier is reported only once for each function it appears in

As far I believe is Boolean true evaluates to 1 in c. If so why am I getting an error?

  • 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-03T07:49:45+00:00Added an answer on June 3, 2026 at 7:49 am

    There are no true or false keywords in C. There are some library definitions for those values in stdbool.h (starting in C99, I think) but oft times most C programmers will just use 1 and 0.

    If you don’t want to use stdbool.h, or you’re working on a compiler that doesn’t support it, you can usually define the constants yourself with something like:

    #define FALSE (1==0)
    #define TRUE  (1==1)
    

    or you can use 1 and 0 directly – the method above is for those who don’t want to have to remember which integer values apply to which truth values (a).

    0 is false, any other value is true. So your code would look something like (fixing up the return value problem as well though I’m not sure why that’s even there since it always returns true.):

    #include <stdio.h>   
    
    int rec (int i) {
        i = i + 1;
        if (i == 10)
            return 1;
        printf ("i: %d\n", i);
        return rec (i);
    }
    
    int main (void) {
        int rv, i = 0;
        rv = rec (i);
        printf ("rv: %d\n", rv);
        return 0;
    }
    

    which gives you:

    i: 1
    i: 2
    i: 3
    i: 4
    i: 5
    i: 6
    i: 7
    i: 8
    i: 9
    rv: 1
    

    I should also mention that recursion is a solution best used when the search space is reduced quickly, such as in a binary tree search where the search spaces halves on each recursive call. It’s not usually a good fit for something where you just increment a value on each call although, in this case, it’s probably okay since you limit it to about ten levels.


    (a): Keep in mind the caveat that, although the given definition of TRUE will most be 1, any non-zero value will be treated so. That means that the two statements:

    if (isValid)
    if (isValid == TRUE)
    

    do not mean the same thing. There are a large number of possible isValid values which will be pass the first test but fail the second. That’s usually not a problem since it’s almost always a bad idea to compare boolean variables with boolean constants anyway.

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

Sidebar

Related Questions

I am confused here. What my program do: displays a view( main layout) that
Here's my program so far: int main() { char choice = 'D'; string inputString;
I'm trying to compile a Windows C++ program in g++. This is what I
I have a very simple example program that I am trying to compile, but
I am trying to compile a program that compiles perfectly fine on my desktop
I am trying to compile a program that is created from Visual Studio 8,
I'm having some trouble trying to compile a program that uses exp function on
I'm having a problem when trying to compile the program in this tutorial from
OK, here is a program that prompts a user for basketball player input. Well
Here is a C# program that tries Marshal.SizeOf on a few different types: using

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.