Click here to Skip to main content
15,887,135 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: if else Style Pin
trønderen26-Jan-24 2:26
trønderen26-Jan-24 2:26 
GeneralRe: if else Style Pin
Daniel Pfeffer26-Jan-24 4:09
professionalDaniel Pfeffer26-Jan-24 4:09 
GeneralRe: if else Style Pin
Matt Bond29-Jan-24 3:06
Matt Bond29-Jan-24 3:06 
GeneralRe: if else Style Pin
Greg Utas26-Jan-24 4:42
professionalGreg Utas26-Jan-24 4:42 
GeneralRe: if else Style Pin
0x01AA26-Jan-24 4:55
mve0x01AA26-Jan-24 4:55 
GeneralRe: if else Style Pin
Greg Utas26-Jan-24 5:25
professionalGreg Utas26-Jan-24 5:25 
GeneralRe: if else Style Pin
honey the codewitch26-Jan-24 8:11
mvahoney the codewitch26-Jan-24 8:11 
GeneralRe: if else Style Pin
Mircea Neacsu26-Jan-24 6:02
Mircea Neacsu26-Jan-24 6:02 
As @GregUtas was pointing out, a lot of answers for a (bad) style question! So, I'll just add my own, just to increase the noise Smile | :)

First, although the OP doesn't specify, we have to assume that the code is C++, because it looks like it and in plain C true and false are not defined. Now, if it's C++, both styles are wrong as @sanderrossel pointed out. The extra fluff of "== true" or "== false" only adds space for confusion and potential errors like the program below illustrates.
C++
#include <stdio.h>

int main()
{
  int one = 1, two = 2;

  if (one + two == true) {
    printf("Miracle of miracles!\n");
  } else if (one + two == false) {
    printf("Another miracle!!\n");
  } else {
    printf("1+2 = 3, you moron!\n");
  }

  return 0;
}
It compiles fine with just a warning about "unsafe mix of type 'int' and type 'bool' in operation". Unsafe indeed!

PS Assume a joker comes along and added to a header file:
C++
#define true 3

Mircea

GeneralRe: if else Style Pin
honey the codewitch26-Jan-24 7:21
mvahoney the codewitch26-Jan-24 7:21 
GeneralRe: if else Style Pin
0x01AA26-Jan-24 8:09
mve0x01AA26-Jan-24 8:09 
GeneralRe: if else Style Pin
trønderen26-Jan-24 8:29
trønderen26-Jan-24 8:29 
GeneralRe: if else Style Pin
0x01AA26-Jan-24 9:32
mve0x01AA26-Jan-24 9:32 
GeneralRe: if else Style Pin
Gary R. Wheeler26-Jan-24 13:12
Gary R. Wheeler26-Jan-24 13:12 
GeneralRe: if else Style Pin
BernardIE531726-Jan-24 13:34
BernardIE531726-Jan-24 13:34 
AnswerRe: if else Style Pin
Ravi Bhavnani26-Jan-24 20:53
professionalRavi Bhavnani26-Jan-24 20:53 
GeneralRe: if else Style Pin
trønderen27-Jan-24 9:05
trønderen27-Jan-24 9:05 
GeneralRe: if else Style Pin
BernardIE531727-Jan-24 10:24
BernardIE531727-Jan-24 10:24 
GeneralRe: if else Style Pin
trønderen27-Jan-24 11:44
trønderen27-Jan-24 11:44 
GeneralRe: if else Style Pin
BernardIE531727-Jan-24 12:16
BernardIE531727-Jan-24 12:16 
GeneralRe: if else Style Pin
trønderen27-Jan-24 14:32
trønderen27-Jan-24 14:32 
GeneralRe: if else Style Pin
BernardIE531727-Jan-24 14:42
BernardIE531727-Jan-24 14:42 
GeneralRe: if else Style Pin
BernardIE531727-Jan-24 19:16
BernardIE531727-Jan-24 19:16 
GeneralRe: if else Style Pin
BernardIE531727-Jan-24 11:59
BernardIE531727-Jan-24 11:59 
GeneralRe: if else Style Pin
Ravi Bhavnani28-Jan-24 16:52
professionalRavi Bhavnani28-Jan-24 16:52 
GeneralRe: if else Style Pin
Iacopo Vettori28-Jan-24 23:47
Iacopo Vettori28-Jan-24 23:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.