From a34d61d268f8b97ef2aa813b437016694e66e152 Mon Sep 17 00:00:00 2001 From: Mukutmani Das Date: Fri, 7 Oct 2022 18:15:05 +0530 Subject: [PATCH] Add files via upload Please fill out the template below Did you read the instructions in the README? Y Have you read the instructions in CONTRIBUTING? Y Have you written this article by yourself? Have you taken inspiration from anywhere and then written it in your words? Yes, I've written it myself. Some of reference examples have been taken from https://cs50.readthedocs.io/style/c/ --- style guide.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 style guide.md diff --git a/style guide.md b/style guide.md new file mode 100644 index 0000000..ca9a81d --- /dev/null +++ b/style guide.md @@ -0,0 +1,43 @@ +Style of a code + +Styling your code is important as it solves a number of problems :- + +1 it makes the code readable +2 it makes the code easy to debug +3 it makes the code neat and clean +What you have to do? +=> styling a code means :- +1 intending it properly (the alignment should be proper) +2 give proper spacing b/w lines of code +3 add comments if you need it. +Here are some examples : - +if (x > 0) +{ + printf("x is positive\n"); +} +else if (x < 0) +{ + printf("x is negative\n"); +} +else +{ + printf("x is zero\n"); +} + + +Declare a switch as follows: + +switch (n) +{ + case -1: + printf("n is -1\n"); + break; + + case 1: + printf("n is 1\n"); + break; + + default: + printf("n is neither -1 nor 1\n"); + break; +} \ No newline at end of file