Here are some questions related to Style of writing C programs:
Question-1: Why i++ executes faster than i + 1 ?
Answer-1: The expression i++ requires a single machine instruction such as INR to carry out the increment operation whereas, i + 1 requires more instructions to carry out this operation.
Question-2: Is writing if(! strcmp(s1, s2) ) a good style ?
Answer-2: No, this is not a good style because if(! strcmp(s1, s2) ) invokes undefined behavior, so it might be confusing .
Question-3: What is the best style for code layout in C ?
Answer-3: There are many systems of indentation advocated, but all of them have the same basic flaw . They will mislead the reader when the actual code logic does not follow the indentation . It is better to avoid indentation entirely, so the reader will not be misled .
Question-4: Is goto a good thing or a bad thing ?
Answer-4: We should avoid using goto statement, Use it only when necessary .
Question-5: Why pre-increment operator is faster than post-increment operator ?
Answer-5: Evaluation of any expression is from left to right . Preincrement operator is faster than Postincrement operator because it does not save the current value for next instruction, whereas Postincrement needs to save the current value to be incremented after execution of the current instruction.
Question-6: What is the output of printf(“%d”) ?
Answer-6: printf(“%d”, i) means that the compiler will print the value of i, since there is nothing after %d so the compiler will show garbage value in output window .
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Common Memory/Pointer Related bug in C Programs
- Interesting facts about data-types and modifiers in C/C++
- C++ programming and STL facts
- 10 Web Development and Web Design Facts That You Should Know
- Interesting Facts about Macros and Preprocessors in C
- Interesting facts about switch statement in C
- Some Interesting facts about default arguments in C++
- C++ bitset interesting facts
- Interesting Facts in C Programming
- Interesting Facts about C++
- Interesting facts about C Language
- 10 Interesting Facts About Computers
- Interesting Facts about DBMS
- Interesting Facts About Perl
- Some interesting facts about static member functions in C++
- Writing OS Independent Code in C/C++
- Writing C/C++ code efficiently in Competitive programming
- Writing first C++ program : Hello World example
- Writing code faster during Competitive Programming in C++
- How to Compile and Run C/C++/Java Programs in Linux
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.