
C is a general purpose, high-level programming language. Brian Kernighan and Dennis Ritchie created it at AT&T Bell laboratories in 1972 for writing the UNIX operating system.
Although developed between 1969 and 1973, its first publication occurred in 1978 in the form of a book titled “The C Programming Language”. Several programmers preferred C to other programming languages of that time like PL/1, ALGOL, COBOL, FORTRAN, PASCAL and APL. Soon C became the most popular programming language.
The popularity of C is due to its following features:
- It is reliable, simple and easy to use.
- It has the virtues of a high-level programming language with the efficiency of an assembly language.
- It supports user-defined data types of grater flexibility in programming.
- It supports modular and structured programming concepts. That is, while writing a C Program to solve a problem, the problem may be broken into smaller tasks, a function may be written to solve each task, and the C program may become a group of functions that are linked to produce the problem solution.
- It supports a rich library of functions that can be used directly by programmers to code efficiently their applications.
- It supports pointers with printer operations. This feature allows programmers to access memory addresses directly where variables are stored, and to perform bit-level manipulation of data stored in memory or processor registers.
- It provides low-level memory and device access features, making it suitable for writing system programs.
- It is a small and concise language providing only the bare essential features, so that a C program can be translated by a compiler into an efficient machine language code.
- It is standardized by several international standards body, making C Programs easily portable from one computer to another.
Also Read:
- [#1] – Introduction to Computer Fundamentals
- [#2] – Basic computer organization
- [#3] – Number systems
- [#4] – Computer Codes
- [#5] – Computer Arithmetic
- [#6] – Processor and Memory
- [#7] – Secondary Storage Devices
- [#8] – Input-Output Devices
- [#9] – Computer software
- [#10] – Planning the Computer Program
- [#11] – Computer Languages
- [#12] – System Implementation and Operation
- [#13] – Operating Systems
- [#14] – Application Software packages
- [#15] – Business Data Processing
- [#16] – Data Communications and Computer Networks
- [#17] – The Internet
- [#18] – Multimedia
- [#19] – Classification of Computers
- [#20] – Introduction to C Programming Language
Points To Remember:
- C is a general purpose, high-level programming language developed by Kernighan and Ritchie at AT&T Bell Labs between 1969 and 1973.
- C has several attractive features that make it one of the most popular programming languages.
- C character set includes uppercase and lowercase alphabets, digits, and several special characters. Altogether there are 93 valid characters allowed in C.
- The three primitive types of constants supported in C are integer, real, and character.
- A C variable is an entity whose value may vary during program execution. C makes it compulsory to declare the type of any variable name that a programmer wishes to use in a program before using it. The basic data types that can be used for such declaration are int, short, long, float, double, and char. Variable names must be unique in their visibility scope.
- Variable can be accessed only within its visibility scope. A variable is visible in the function or statement block it is declared in. Global variables are accessible from anywhere in program. A local variable has access precedence over global variable of same name.
- There are 32 keyboards (reserved words) in C. They cannot be used as variable names.
- C has a wide range of basic operators categorized into arithmetic, logical, bitwise, data access and miscellaneous. Operators have a precedence level and associativity that govern in what order compilers execute them.
- C program logic is combination of statements. Statements are always found between {} braces called body of a function. Each statement performs a set of operations. Simple statements are terminated by semicolon “;”.
- C provides standard library functions for performing all input/output operations. Some basic I/O library functions are getch, getche, getchar, putchar, putch, scanf, printf, gets, and puts.
- Preprocessor directives are source-code preprocessing stage where programmers can provide instruction and declarations that are useful for compiler when processing the source code. Three commonly used preprocessor directives in C are #define, #include, and #ifdef.
- The pointer data type is special modifier of any other data type that associates value and address of the storage to a variable name. A pointer is declared by adding an ‘*’ symbol after the data type declarator.
- For a pointer variable, using ‘*’ refers to the value at memory location pointed by it. The name of the pointer variable refers to the address itself. It is possible to get the address of any variable by simple qualifying the variable with & operator.
- An arrary is a collection of elements in which all elements are of the same data type. It is homogeneous, linear, and contiguous memory structure. An array has a fixed number of elements, called it length or size, given at the time of its declaration. The size parameter must be a numeric literal or a constant. All elements of an array are stored in contiguous memory locations.
- The elements of an array can be referred to be using their subscript or index position that in monotonic in nature. The first element of an array is always denoted by subscript value of 0(zero), increasing monotonically up to one less than declared size of array.
- A string is a one-dimensional array of characters terminated by a null character (‘0’). Individual elements of a string can be accessed by using their subscript or index position, with zero being the subscript of the first element.
- A structure is a program defined data type that is made by using primary data types and other user defined data types. All elements of a structure, also called member variables, are publicly accessible. Each member can be accessed by using “.” (dot) operator. Structure has contiguous memory allocation.
- A union is a program defined data type that refers to a memory location using several data types. Each data member begins at the same memory location. The minimum size of union variable is the sizes of its largest constituent data types.
- The if group of conditional branch statements are used to implement simple one-way test. The flow of execution depends on a logical Boolean expression.
- The switch..case facilitates multi-way condition test similar to if construct when primary test object remains same across all condition tests. Each case constant expression is compared against switch integral expression. A special case named default can be written at the end that is automatically selected if no other case statement is selected.
- The break statement causes unconditional exit form for, while, do, or switch constructs.
- The continue statement causes unconditional transfer to next iteration in a for, while, or do constructs.
- The goto statement causes unconditional transfer to statement marked with the label within the function.
- The return statement causes immediate termination of function in which it appears and transfers control to the statement that called the function.
- The for pretest loop statement has three parts; initializer, loop condition, and incrementor. Initializer is executed at start of loop. Loop condition is tested before each iteration. If condition evaluates to nonzero (true) the next iteration occurs otherwise the loop is terminated.
Incrementor is executed at end of each iteration. - The while pretest loop statement has a loop condition. Loop condition is tested before each iteration. If condition evaluates to nonzero (true) the next iteration occurs otherwise the loop is terminated.
- The do..while posttest loop statement has a loop condition. Loop condition is tested after each iteration. At least one iteration occurs before the condition is tested. If condition evaluates to nonzero (true) the next iteration occurs otherwise the loop is terminated.
- Functions are building blocks of a program, and are also called subprograms. All function need to be declared and defined before use. Function declaration requires function name, argument list, and return type. Function definition requires coding the body or logic of function. It is possible to declare and define a function at same time.
- Every C program is required to have a special function called main. This function is the entry point of the program.
List of Questions:
- Trace history of development of C language and various standardizations it went through.
- Why C is one of the most popular programming languages?
- Write the rules for constructing integer constants.
- Write the rules for constructing real constants in exponential form.
- Write the rules for constructing real constants in fractional form.
- Write the rules for constructing variable names.
- What are keywords (reserved words)? Write ten keywords used in C language.
- What is a comment statement? How a comment statement is written in C? How a comment statement is treated by a compiler?
- Write five standard library functions provided in C for performing I/O operations.
- What is preprocessor directive?
- Explain purpose of following preprocessor directives: #define, #ifdef, #include.
- What is primitive data type? What is user defined data type? Give an example of each type.
- What are the differences between signed and unsigned data type?
- What is a variable? List the restrictions that apply in selecting name for a variable.
- What are declaring and defining stages of a variable? How are they different?
- What is meant by lifetime and visibility scope of variable?
- What is a pointer? How it is declared and used in a C program?
- What is the function of ‘*’ and ‘&’ operators in context of pointer variable?
- What are important properties of an array in C? How is an array declared in C?
- Explain use and characteristics of index or subscript in array?
- What is a struct in C? How is a struct declared in C?
- Explain how elements of struct are accessed in C?
- What is ‘shallow copy’ in struct?
- What is a union in C? How is a union declared in C?
- What is the difference between structures and unions in C?
- What types of basic operators are provided in C? Give an example of each type.
- What is operator precedence and associativity?
- Explain, with example, if..else control construct in C?
- How is switch different from if group of control constructs in C? Give one example where same logic can be written in both if and switch constructs.
- What is significance of break keyword in switch construct? What will be behavior of a switch block having no break statement? Explain with an example of your own.
- What is effect of writing a continue statement in a loop? Explain with an example.
- What is a pretest loop? What is a posttest loop?
- What are different parts of a for construct? What is behavior of a for loop where these parts are not provided?
- How is while loop different from do..while loop? Write a loop logic of your own using both these loop constructs.
- What are functions? Write the general syntax for declaring a function?
- What is return used of in a C function?
- What is the significance of main function in C?
- What is the prototype of main function in C?
- Write a C program to accept five numbers from console and then to display them back on console in ascending order.
- Write a C program to calculate the sum of all numbers from 0 to 100 (both inclusive) that are divisible by 4.
- Write a C program to accept the length of three sides of a triangle from console and to test and print the type of triangle – equilateral, isoceles, right angled, none of these.
- Write a C program to accept a string from console and to display the following on console:
Total number of characters in the string
Total number of vowels in the string
Total number of occurrence of character ‘a’ in the string.
Total number of occurrence of string ‘the’ in the string.