Posts

C - character set, identifiers, keywords

Image
 character set, identifiers, keywords  Character set:  A character denotes any alphabet, digit or special symbol used to represent information. Valid alphabets, numbers and special symbols allowed in C are The alphabets, numbers and special symbols when properly combined form constants, variables and keywords. Identifiers:   Identifiers are user defined word used to name of entities like variables, arrays, functions, structures etc. Rules for naming identifiers are:  1) name should only consists of alphabets (both upper and lower case), digits and underscore (_) sign. 2) first characters should be alphabet or underscore  3) name should not be a keyword  4) since C is a case sensitive, the upper case and lower case considered differently, for example code, Code, CODE etc. are different identifiers.    5) identifiers are generally given in some meaningful name such as value, net_salary, age, data etc. An identifier name may be long, s...

C - Compiling and executing the Programs

 Steps for Compiling and executing the Programs A compiler is a software program that analyzes a program developed in a particular computer language and then translates it into a form that is suitable for executionon a particular computer system. Figure below shows the steps that are involved in entering, compiling, and executing a computer program developed in the C programming language and the typical Unix commands that would be entered from the command line. Step 1:  The program that is to be compiled is first typed into a file on the computer system. There are various conventions that are used for naming files, typically be any name provided the last two characters are “.c” or file with extension .c. So, the file name prog1.c might be a valid filename for a C program. A text editor is usually used to enter the C program into a file. For example, vi is a popular text editor used on Unix systems. The program that is entered into the file is known as the source program becaus...

Structure of C program

Structure of c program:   1 ) Comment line  2) Preprocessor directive  3 ) Global variable declaration  4) main function( ) { Local variables; Statements; } User defined function } } Comment line It indicates the purpose of the program. It is represented as /*……………………………..*/ Comment line is used for increasing the readability of the program. It is useful in explaining the program and generally used for documentation. It is enclosed within the decimeters. Comment line can be single or multiple line but should not be nested. It can be anywhere in the program except inside string constant & character constant. Preprocessor Directive: #include tells the compiler to include information about the standard input/output library. It is also used in symbolic constant such as #define PI 3.14(value). The stdio.h (standard input output header file) contains definition &declaration of system defined function such as printf( ), scanf( ), pow( ) etc. General...

C Introduction

Image
 Introduction to C   C is a programming language developed at AT & T’s Bell Laboratories of USA in 1972. It was designed and written by a man named Dennis Ritchie. In the late seventies C began to replace the more familiar languages of that time like PL/I, ALGOL, etc ANSI C standard emerged in the early 1980s, this book was split into two titles: The original was still called Programming in C, and the title that covered ANSI C was called Programming in ANSI C. This was done because it took several years for the compiler vendors to release their ANSI C compilers and for them to become ubiquitous.  It was initially designed for programming UNIX operating system. Now the software tool as well as the C compiler is written in C. Major parts of popular operating systems like Windows, UNIX, Linux is still written in C. This is because even today when it comes to performance (speed of execution) nothing beats C. Moreover, if one is to extend the operating system to work...