Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
my program is not returning any value...when i try to solve this problem without using user defined function and use printf() to output the message "that triangle is valid or not" ,its working

What I have tried:

#include<stdio.h>
#include <stdbool.h>
bool triangle( int a,int b,int c);
int main(void){
    printf("enter three side of triangel to check if triangle exist\n");
     
    
    int x=get_int();
    int y=get_int();
    int z=get_int();
    
    triangle(x,y,z);
}
bool triangle( int a,int b,int c)
{
    if((a>0&&b>0&&c>0)&&(a+b>c&&b+c>a&&a+c>a)){return true;}
        
    
    else{ return false;}}
Posted
Updated 26-Mar-17 5:05am
Comments
[no name] 26-Mar-17 10:13am    
"my program is not returning any value", oh yes it is. You just aren't doing anything with it.
Member 12914219 26-Mar-17 10:48am    
plz elaborate ..the program should return either true or false?..thank you for your intrest
[no name] 26-Mar-17 11:11am    
Elaborate what? You are ignoring the return value.

1 solution

The function DOES return a value. You're just not capturing it and doing anything with it.

Your call to triangle(x,y,z); doesn't capture the return value. It should be
C
bool c;
c = triangle(x,y,z);
...
 
Share this answer
 
Comments
Member 12914219 26-Mar-17 11:23am    
thank you ....i got it.....should i then print its value...?
Dave Kreskowiak 26-Mar-17 11:32am    
How the f*** should I know?!?! It's YOUR application. I have no idea what you want/need to do with that value!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900