element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Code Exchange
  • Technologies
  • More
Code Exchange
Forum Redundant parathensis in C
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Code Exchange to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 26 replies
  • Answers 4 answers
  • Subscribers 52 subscribers
  • Views 2465 views
  • Users 0 members are here
  • Code Exchange
  • redundant
  • conditional tricky writing style
  • if else construct
  • paranthesis
Related

Redundant parathensis in C

dr.akshay_1980@yahoo.com
dr.akshay_1980@yahoo.com over 9 years ago

Hi,

Out of curiosity and experimenting with ANSI C constructs ,I would like to know any means by which we can ignore the empty braces for the conditional statements in C programming??? Does C allow us to do this.

 

Refer below the sample C code for discussion

 

 

int main()

{

     if()             /// there should no error while writing this, empty parathensis..

{

     printf("your if  is without parameters...");

}

else

{

    printf("if block ignored....");

}

return 0;

}

 

 

How to implement the above code in C successfully without any errors(compile time/Run time)????? By any means I want to implement above style.

 

 

Thanks in advance....

  • Sign in to reply
  • Cancel

Top Replies

  • shabaz
    shabaz over 9 years ago in reply to clem57 +2
    It looks like another interview/college homework type question (they do ask odd questions sometimes). Much like this one: If-Else construct in C language-hello world As you say, nothing for any real practical…
  • amgalbu
    amgalbu over 9 years ago +1 suggested
    According to c grammar, you need to type a boolean expression. So there is no way to create an if without condition
  • amgalbu
    amgalbu over 9 years ago in reply to D_Hersey +1
    @akshay dharma is asking if it is possibile to uae empty braces after a if keyword. That's noto possibile imho. Btw true and false are c++ keywords, and are not allowed in ANSI c (aka c90)
Parents
  • D_Hersey
    0 D_Hersey over 9 years ago

    My only motivation in bringing up three-valued logic is a vain attempt to bring something interesting to this thread.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • D_Hersey
    0 D_Hersey over 9 years ago

    My only motivation in bringing up three-valued logic is a vain attempt to bring something interesting to this thread.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
  • Former Member
    0 Former Member over 9 years ago in reply to D_Hersey

    Ok, Don. I was simply puzzled by shift.  Clearly, I missed the point.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • D_Hersey
    0 D_Hersey over 9 years ago in reply to Former Member

    It's clang association.  When I was a kid they thought I might have been creative, but it's mostly random.

     

    https://en.wikipedia.org/wiki/Clanging

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube