Posts

1.18 Identifiers in c

  Identifiers: - Identifiers are names used for program elements like variables, functions, arrays, structures, unions, constants, and labels. Every identifier must have a unique name to help to recognize and use values or functions during program execution. The value of an identifier can change during the program as per the programmer's need. Identifiers can have uppercase letters, lowercase letters, digits, and underscores. It uses 63 characters (26 uppercase, 26 lowercase + 10 digits) can be used to form identifiers. Here underscore character is treated as letter, commonly used in the middle of identifiers.   Rules for Writing Identifiers: - An identifier must start with a letter (A–Z or a–z) or an underscore _. It can contain letters, digits (0–9), or underscores after the first character. An identifier cannot begin with a digit. Uppercase and lowercase lette...

1.16 The C Character Set or Characters of lexical set

  The C Character Set or Characters of lexical set: - Character set is a set of alphabets, digits and some special characters that are valid in C language. A program requires all these when designing it. Alphabets                               Uppercase: A B C  ......................... X Y Z                               Lowercase: a b c  ......................  x y z                          C accepts both lowercase and uppercase alphabets as variables and functions.   Digits                                              ...

1.15 Executing a ' C ' Program.

Image
  Executing a ' C ' Program. Executing a program written in C involves a series of steps. These are: Creating the C program. Compiling the C program. Linking the C program. Executing the C program. 1) Creating the C program: - An editor like notepad, WordPad, or Editplus etc. are used to create or write a c program. The code which we have written inside the editor is known as source code and should saved with “.c” extension. 2) Compiling the C program: - After writing the source code in editor, which is ready for compilation process. The source code is compiled by the compilers. The compiler converts C source high level code to low level code as assembly source code. Then assembler is ready to convert assembly source code to binary code, which code was well understandable by computer machine. i.e. object code.   3) Linking the C program: - In this step, the object code of a C program is linked with libraries that are needed for execution of a ...

1.14 Programming Style

Programming Style: -   A good programming style in C helps make your code readable, understandable, and easy to maintain. It is important to use consistent indentation throughout your code. (spaces or tabs, but not both). Always use meaningful names for your variables and functions. For instance, use student_Count instead of a value name like a. Adding comments in your code helps others understand the logic. Choose a brace style and stick to it consistently. Try to keep each line of code reasonably short, ideally under 80 to 100 characters, so that it fits on the screen without scrolling.   Break your program into smaller functions, where each function performs a single specific task. This makes your code modular and easier to debug or reuse. Avoid using magic numbers in your code. Instead, use constants or macros declared with #define or const variables to make your code more understandable. Use proper spacing around operators and after commas to improve readability. For ex...

1.13 Basic Structure of C Program

Image
  v    Basic Structure of C Programs: - Basic structure of c program consists of several sections. 1.        Documentation Section. 2.        Link Section. 3.        Definition Section. 4.        Global Declaration Section. 5.        Function Prototype Declaration Section. 6.        Main Function 7.        Sub Function section. 1)      Documentation Section: - Ø    Documentation section includes comments about the C program. Ø    Comments improve readability and understandability of the programmer. Ø    We can give comments about program, creation, modified date, author name, etc. in this section. Ø    Comment lines are ignored by compiler while C program was compiled. Ø    Comments can be of two ...