Execution of the C Program:- Developing a program in a compiled language such as C requires at least four steps: 1. Editing (or writing) the program. 2. Compiling. 3. Linking. 4. Executing. Step 1: Editing : (in turbo C Compiler use the command TC filename.c at dos (prompt) 1. Write C program using Text Editor. Such as Notepad or Turbo C editor. 2. Save program with an extension .C (F2 in Turbo C) 3. File saved with .C extension is called as Source Program. Step 2: Compiling : (In turbo C compiler use Alt + F9 Key) 1. Source Program with an extension .C is given as input to Compiler. 2. Compiler checks for errors, if source code contains errors then goto step1 to modify the source program. 3. If source code is error free then Compiler Converts it into Object file with an extension obj and proceed to step3. Step 3: Linking : (This Process is inbuilt with step2 in Turbo Compiler). 1. Object Program with an extension .OBJ is given as input to Linker.
Posts
- Get link
- Other Apps
Programming Style of C Language :- The style of a C Language describes how to use various elements of C language to increase clarity, readability and understandability of c programs. Various elements that are included to describe c-style are:- 1.Names. 2.Spaces. 3.Line Breaks. 4.Comments. 5.Indentation. 6.Blank lines. 7.Braces. 1.Names : Use Meaningful names for File names. Variable names. Function names. If two (or) three words are used in names, combine them with Underscores. File name should have an extension .c. Function name should be terminated with() Examples: Sum_of_two_numbers.c. file1.c, calendar.c /* File names */ Area_of_circle, x. y. z /* variable names */ Print_address().read_data(), calc_interest() /*Function names*/ 2.Spaces :- use at least one space between two or three elements of a program, one or more spaces will be treated as a single space. For example:- For 1=1 to 10 S= a + b + c (or) s = a + b +
Structure of C-Language
- Get link
- Other Apps
Now let us combine all the above three sections/parts to make a complete C program. =>/* Program to print hello world*/ #include<stdio.h> /*link section*/ Int main() /*main function*/ { Printf(“Hello world”); Return 0; } Output: - Hello world Note: - only link and main function sections are compulsory. Documentation section is optional. The various sections/parts of a C program are:- 1) Document section :- Gives the brief explanation of the program, author,date written etc….. 2) Link section :- Include header files with #include statements. 3) Definition section :- variables and initializes them using # define. 4) Global declaration section :- The variables used throughout the program are declared. 5) Function Prototype Declaration section : - User defined functions are declared here. 6) Main Function : Main function is written here to start the program execution. 7) User Defined Function Section : The bodies of all the user d
Introduction Structure of C-Language
- Get link
- Other Apps
Structure of c language program:- To write programs in c, we should follow the basic structure of the c program. Structure of a C program includes various sections/parts. All these sections may or may not be used in all the programs, But to write complete C program that can be easily understood by programmers one should use some or all the sections based on the program complexity and functionality. Simple programs may use a few sections and complex programs may use all the sections of the program structure. To understand the concept let us begin with a sample program with only three sections. 1) DOCUMENTATION SECTION :- Gives the aim of the program or double line comment(This should be between '/*this comments is used for understand any programs easily or find debug's easily*/'). Ex:-/* program of operating system*/ * '//' this is used for single line comments. Ex:- //Area of triangle. 2) LINK SEC