Review of Cprogramming

Total Page:16

File Type:pdf, Size:1020Kb

Review of Cprogramming 5/24/2016 Resources • Kochen, Programming in C, Third Edition Review of Programming • Brian Kernighan and Dennis Ritchie, The C Programming C Language , 2 nd Edition, Prentice Hall – Is considered “THE” book on C : coauthor belongs to the creators of the C programming language – The book is not an introductory programming manual; it assumes some familiarity with basic programming concepts • C Programming Notes by Steve Summit http://www.eskimo.com/~scs/cclass/notes/top.html Based on the Original Slides from Politehnica International- Computer Engineering Lecture Slides Compilers The C Programming Language • Developed by Dennis Ritchie at AT&T Bell Laboratories in the early 1970s Source Machine Compiler Code Code • Growth of C tightly coupled with growth of Unix: Unix was written mostly in C • Success of PCs: need of porting C on MS-DOS • Many providers of C compilers for many different platforms => Input Executable Output need for standardization of the C language data Program data • 1990: ANSI C (American National Standards Institute) • International Standard Organization: ISO/IEC 9899:1990 Compiler: analyzes program and • 1999: standard updated: C99, or ISO/IEC 9899:1999 translates it into machine language Executable program: can be run independently from compiler as many times => fast execution 1 5/24/2016 The first C program Compiling and running C programs uses standard library input and output functions Editor (printf) Source code #include <stdio.h> file.c the program int main (void) begin of program { Compiler printf ("Programming is fun.\n"); Object code statements return 0; file.obj end of program } Libraries main: a special name that indicates where the program must begin execution. It is Linker a special function . Executable code file.exe first statement: calls a routine named printf, with argument the string of characters IDE (Integrated “Programming is fun \n” Development last statement: finishes execution of main and return to the system a status value Environment) of 0 (conventional value for OK) C Compilers and IDE’s Debugging program errors • One can: – use a text editor to edit source code, and then use independent Editor command-line compilers and linkers Syntactic Source code Errors – use an IDE: everything together + facilities to debug, develop and file.c organize large projects • There are several C compilers and IDE’s that support various C compilers Compiler We will use Eclipse and the “GCC” compiler. Object code • file.obj gcc prog.c porg.out Libraries Linker Executable code file.exe Semantic Errors 2 5/24/2016 Displaying multiple values Using comments in a program /* This program adds two integer values and displays the results */ #include <stdio.h> int main (void) #include <stdio.h> { int main (void) int value1, value2, sum; { value1 = 50; // Declare variables value2 = 25; int value1, value2, sum; sum = value1 + value2; // Assign values and calculate their sum printf ("The sum of %i and %i is %i\n",value1, value2, sum); value1 = 50; return 0; value2 = 25; } sum = value1 + value2; // Display the result printf ("The sum of %i and %i is %i\n", The format string must contain as many placeholders as expressions to be printed value1, value2, sum); return 0; } Example: Using data types Basic Data Types - Summary Type Meaning Constants Ex. printf #include <stdio.h> int Integer value; guaranteed to contain at least 16 bits 12, -7, %i,%d, %x, int main (void) 0xFFE0, 0177 %o { short int Integer value of reduced precision; guaranteed to - %hi, %hx, int integerVar = 100; contain at least 16 bits %ho float floatingVar = 331.79; long int Integer value of extended precision; guaranteed to 12L, 23l, %li, %lx, 0xffffL %lo double doubleVar = 8.44e+11; contain at least 32 bits char charVar = 'W'; long long Integer value of extraextended precision; guaranteed 12LL, 23ll, %lli, 0xffffLL %llx, %llo printf ("integerVar = %d\n", integerVar); int to contain at least 64 bits printf ("floatingVar = %f\n", floatingVar); unsigned Positive integer value; can store positive values up 12u, 0XFFu %u, %x, %o printf ("doubleVar = %e\n", doubleVar); int to twice as large as an int; guaranteed to contain at printf ("doubleVar = %g\n", doubleVar); least 16 bits (all bits represent the value, no sign bit) printf ("charVar = %c\n", charVar); unsigned - %hu, %hx, return 0; short int %ho } unsigned 12UL, 100ul, %lu, %lx, long int 0xffeeUL %lo unsigned 12ull, %llu, long long 0xffeeULL %llx, %llo int 3 5/24/2016 Basic Data Types - Summary (contd.) Integer and Floating-Point Conversions Type Meaning Constants printf // Basic conversions in C #include <stdio.h> float Floating-point value; a value that can contain decimal 12.34f, 3.1e- %f, %e, places; guaranteed to contain at least six digits of 5f %g int main (void) precision . { double Extended accuracy floating-point value; guaranteed to 12.34, 3.1e-5, %f, %e, float f1 = 123.125, f2; contain at least 10 digits of precision . %g int i1, i2 = -150; char c = 'a'; long Extraextended accuracy floating-point value; 12.341, 3.1e- %Lf, i1 = f1; // floating to integer conversion double guaranteed to contain at least 10 digits of 5l %Le, %Lg printf ("%f assigned to an int produces %d\n", f1, i1); precision. f1 = i2; // integer to floating conversion char Single character value; on some systems, sign 'a', '\n' %c printf ("%d assigned to a float produces %f\n", i2, f1); extension might occur when used in an expression. f1 = i2 / 100; // integer divided by integer printf ("%d divided by 100 produces %f\n", i2, f1); unsigned Same as char, except ensures that sign extension - char does not occur as a result of integral promotion. f2 = i2 / 100.0; // integer divided by a float printf ("%d divided by 100.0 produces %f\n", i2, f2); signed Same as char, except ensures that sign extension - f2 = (float) i2 / 100; // type cast operator char does occur as a result of integral promotion. printf ("(float) %d divided by 100 produces %f\n", i2, f2); return 0; } The Type Cast Operator The assignment operators • f2 = (float) i2 / 100; // type cast operator • The C language permits you to join the arithmetic operators with the • The type cast operator has the effect of converting the value of the variable i2 to assignment operator using the following general format: op=, where op type float for purposes of evaluation of the expression. is an arithmetic operator, including +, –, ×, /, and %. • This operator does NOT permanently affect the value of the variable i2; • op can also be a logical or bit operator => later in this course • The type cast operator has a higher precedence than all the arithmetic operators • Example: except the unary minus and unary plus. count += 10; – Equivalent with: • Examples of the use of the type cast operator: count=count+10; • (int) 29.55 + (int) 21.99 results in 29 + 21 • Example: precedence of op=: (float) 6 / (float) 4 results in 1.5 • a /= b + c • (float) 6 / 4 results in 1.5 – Equivalent with: a = a / (b + c) – addition is performed first because the addition operator has higher precedence than the assignment operator 4 5/24/2016 Program input The while statement #include <stdio.h> It’s polite to while ( expression ) int main (void) display a { message before program statement int n, number, triangularNumber; printf ("What triangular number do you want? "); scanf ("%i", &number); triangularNumber = 0; Reads integer while ( number <= 0 ) { for ( n = 1; n <= number; ++n ) from keyboard printf (“The number must be >0“); triangularNumber += n; printf (“Give a new number: “); printf ("Triangular number %i is %i\n", number, scanf(“%i“, &number); triangularNumber); } return 0; } Scanf: similar to printf: first argument contains format characters, next arguments tell where to store the values entered at the keyboard More details -> in a later chapter ! Example – do while Statements break and continue • Programming style: don’t abuse break !!! // Program to reverse the digits of a number #include <stdio.h> ... int main () { while ( number != 0 ) { int number, right_digit; // Statements to do something in loop printf ("Enter your number.\n"); scanf ("%i", &number); printf("Stop, answer 1: "); do { right_digit = number % 10; scanf ("%i", &answer); printf ("%i", right_digit); if(answer == 1) number = number / 10; } break; // very bad idea to do this while ( number != 0 ); printf ("\n"); } return 0; } 5 5/24/2016 Statements break and continue Example: compound relational test Continue also not so good style!!! // Program to determine if a year is a leap year ... #include <stdio.h> int main (void) while ( number != 0 ) { { // Statements to do something in loop int year, rem_4, rem_100, rem_400; printf(“Skip next statements answer 1: "); printf ("Enter the year to be tested: "); scanf ("%i", &answer); scanf ("%i", &year); if(answer == 1) rem_4 = year % 4; continue; // not so good idea… rem_100 = year % 100; // Statements to do something in loop rem_400 = year % 400; if ( (rem_4 == 0 && rem_100 != 0) || rem_400 == 0 ) // If answer was 1 these statements are printf ("It's a leap year.\n"); // not executed. They are skipped. else // Go straight to the beginning of while printf (“It's not a leap year.\n"); } return 0; } Logical operators Boolean variables Operator Symbol Meaning // Program to generate a table of prime numbers AND && X && y is true if BOTH x and y are true #include <stdio.h> OR || X || y is true if at least one of x and y is true int main (void) { int p, d; A flag : assumes only NOT ! !x is true if x is false _Bool isPrime; one of two different for ( p = 2; p <= 50; ++p ) { values.
Recommended publications
  • By Kumari Priyadarshani 22-04-2020 BBM 3Rd Year Variables in C a Variable Is a Name of the Memory Location. It Is Used to Store Data
    By Kumari priyadarshani 22-04-2020 BBM 3rd year Variables in C A variable is a name of the memory location. It is used to store data. Its value can be changed, and it can be reused many times. It is a way to represent memory location through symbol so that it can be easily identified. Let's see the syntax to declare a variable: type variable_list; The example of declaring the variable is given below: int a; float b; char c; Here, a, b, c are variables. The int, float, char are the data types. We can also provide values while declaring the variables as given below: int a=10,b=20;//declaring 2 variable of integer type float f=20.8; char c='A'; Rules for defining variables A variable can have alphabets, digits, and underscore. A variable name can start with the alphabet, and underscore only. It can't start with a digit. No whitespace is allowed within the variable name. A variable name must not be any reserved word or keyword, e.g. int, float, etc. Valid variable names: int a; int _ab; int a30; Invalid variable names: int 2; int a b; int long; Types of Variables in C There are many types of variables in c: local variable global variable static variable automatic variable external variable 1)Local Variable A variable that is declared inside the function or block is called a local variable. It must be declared at the start of the block. void function1(){ int x=10;//local variable } You must have to initialize the local variable before it is used.
    [Show full text]
  • An Empirical Study Into COBOL Type Inferencing*
    Science of Computer Programming ELSEVIERI Science of Computer Programming 40 (2001) 189-211 www.elsevier.nl/locate/scico An empirical study into COBOL type inferencing* Arie van Deursen 1, Leon Moonen 1 * CWL P. 0. Box 94079, 1090 GB Amsterdam, Netherlands Accepted 2 February 2001 Abstract In a typical COBOL program, the data division consists of 50% of the lines of code. Automatic type inference can help to understand the large collections of variable declarations contained therein, showing how variables are related based on their actual usage. The most problematic aspect of type inference is pollution, the phenomenon that types become too large, and contain variables that intuitively should not belong to the same type. The aim of the paper is to provide empirical evidence for the hypothesis that the use of subtyping is an effective way for dealing with pollution. The main results include a tool set to carry out type inference experiments, a suite of metrics characterizing type inference outcomes, and the experimental observation that only one instance of pollution occurs in the case study conducted. @ 2001 Elsevier Science B.V. All rights reserved. Keywords: Software maintenance; Static program analysis; Variable usage; Case study 1. Introduction In this paper, we will be concerned with the variables occurring in a COBOL pro­ gram. The two main parts of a COBOL program are the data division, containing declarations for all variables used, and the procedure division, which contains the state­ ments performing the program's functionality. Since it is in the procedure division that the actual computations are made, one would expect this division to be larger than the data division.
    [Show full text]
  • Software Comprehension Using Open Source Tools: a Study
    International Journal of Computer Sciences and Engineering Open Access Survey Paper Vol.-7, Issue-3, March 2019 E-ISSN: 2347-2693 Software Comprehension Using Open Source Tools: A Study Jyoti Yadav Department of Computer Science, Savitribai Phule Pune University, Maharashtra, India *Corresponding Author: [email protected], Tel.: 9881252910 DOI: https://doi.org/10.26438/ijcse/v7i3.657668 | Available online at: www.ijcseonline.org Accepted: 12/Mar/2019, Published: 31/Mar/2019 Abstract: Software applications developed in recent times are written in lakhs of lines of code and have become increasingly complex in terms of structure, behaviour and functionality. At the same time, development life cycles of such applications reveal a tendency of becoming increasingly shorter, due to factors such as rapid evolution of supporting and enabling technologies. As a consequence, an increasing portion of software development cost shifts from the creation of new artefacts to the adaptation of existing ones. A key component of this activity is the understanding of the design, operation, and behaviour of existing artefacts of the code. For instance, in the software industry, it is estimated that maintenance costs exceed 80% of the total costs of a software product’s lifecycle, and software understanding accounts for as much as half of these maintenance costs. Software Comprehension is a key subtask of software maintenance and evolution phase, which is driven by the need to change software. This paper will help in enhancing the ability of the developers to read and comprehend large pieces of software in an organized manner, even in the absence of adequate documentation by using existing open source tools.
    [Show full text]
  • CMSC 246 Systems Programming Spring 2018 Bryn Mawr College Instructor: Deepak Kumar
    1/23/2018 CMSC 246 Systems Programming Spring 2018 Bryn Mawr College Instructor: Deepak Kumar Input • scanf() is the C library’s counterpart to printf. • Syntax for using scanf() scanf(<format-string>, <variable-reference(s)>) • Example: read an integer value into an int variable data. scanf("%d", &data); //read an integer; store into data • The & is a reference operator. More on that later! 2 1 1/23/2018 Reading Input • Reading a float: scanf("%f", &x); • "%f" tells scanf to look for an input value in float format (the number may contain a decimal point, but doesn’t have to). 3 Standard Input & Output Devices • In Linux the standard I/O devices are, by default, the keyboard for input, and the terminal console for output. • Thus, input and output in C, if not specified, is always from the standard input and output devices. That is, printf() always outputs to the terminal console scanf() always inputs from the keyboard • Later, you will see how these can be reassigned/redirected to other devices. 4 2 1/23/2018 Program: Convert Fahrenheit to Celsius • The celsius.c program prompts the user to enter a Fahrenheit temperature; it then prints the equivalent Celsius temperature. • Sample program output: Enter Fahrenheit temperature: 212 Celsius equivalent: 100.0 • The program will allow temperatures that aren’t integers. 5 Program: Convert Fahrenheit to Celsius ctof.c #include <stdio.h> int main(void) { float f, c; printf("Enter Fahrenheit temperature: "); scanf("%f", &f); c = (f – 32) * 5.0/9.0; printf("Celsius equivalent: %.1f\n", c); return
    [Show full text]
  • XL C/C++: Language Reference About This Document
    IBM XL C/C++ for Linux, V16.1.1 IBM Language Reference Version 16.1.1 SC27-8045-01 IBM XL C/C++ for Linux, V16.1.1 IBM Language Reference Version 16.1.1 SC27-8045-01 Note Before using this information and the product it supports, read the information in “Notices” on page 63. First edition This edition applies to IBM XL C/C++ for Linux, V16.1.1 (Program 5765-J13, 5725-C73) and to all subsequent releases and modifications until otherwise indicated in new editions. Make sure you are using the correct edition for the level of the product. © Copyright IBM Corporation 1998, 2018. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents About this document ......... v Chapter 4. IBM extension features ... 11 Who should read this document........ v IBM extension features for both C and C++.... 11 How to use this document.......... v General IBM extensions ......... 11 How this document is organized ....... v Extensions for GNU C compatibility ..... 15 Conventions .............. v Extensions for vector processing support ... 47 Related information ........... viii IBM extension features for C only ....... 56 Available help information ........ ix Extensions for GNU C compatibility ..... 56 Standards and specifications ........ x Extensions for vector processing support ... 58 Technical support ............ xi IBM extension features for C++ only ...... 59 How to send your comments ........ xi Extensions for C99 compatibility ...... 59 Extensions for C11 compatibility ...... 59 Chapter 1. Standards and specifications 1 Extensions for GNU C++ compatibility .... 60 Chapter 2. Language levels and Notices .............. 63 language extensions ......... 3 Trademarks .............
    [Show full text]
  • Language Reference
    Enterprise PL/I for z/OS Version 5 Release 3 Language Reference IBM SC27-8940-02 Note Before using this information and the product it supports, be sure to read the general information under “Notices” on page 613. Third Edition (September 2019) This edition applies to Enterprise PL/I for z/OS Version 5 Release 3 (5655-PL5), and IBM Developer for z/OS PL/I for Windows (former Rational Developer for System z PL/I for Windows), Version 9.1, and to any subsequent releases of any of these products until otherwise indicated in new editions or technical newsletters. Make sure you are using the correct edition for the level of the product. Order publications through your IBM® representative or the IBM branch office serving your locality. Publications are not stocked at the address below. A form for readers' comments is provided at the back of this publication. If the form has been removed, address your comments to: IBM Corporation, Department H150/090 555 Bailey Ave. San Jose, CA, 95141-1099 United States of America When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. Because IBM Enterprise PL/I for z/OS supports the continuous delivery (CD) model and publications are updated to document the features delivered under the CD model, it is a good idea to check for updates once every three months. © Copyright International Business Machines Corporation 1999, 2019. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
    [Show full text]
  • The C Programming Language
    The C programming Language The C programming Language By Brian W. Kernighan and Dennis M. Ritchie. Published by Prentice-Hall in 1988 ISBN 0-13-110362-8 (paperback) ISBN 0-13-110370-9 Contents ● Preface ● Preface to the first edition ● Introduction 1. Chapter 1: A Tutorial Introduction 1. Getting Started 2. Variables and Arithmetic Expressions 3. The for statement 4. Symbolic Constants 5. Character Input and Output 1. File Copying 2. Character Counting 3. Line Counting 4. Word Counting 6. Arrays 7. Functions 8. Arguments - Call by Value 9. Character Arrays 10. External Variables and Scope 2. Chapter 2: Types, Operators and Expressions 1. Variable Names 2. Data Types and Sizes 3. Constants 4. Declarations http://freebooks.by.ru/view/CProgrammingLanguage/kandr.html (1 of 5) [5/15/2002 10:12:59 PM] The C programming Language 5. Arithmetic Operators 6. Relational and Logical Operators 7. Type Conversions 8. Increment and Decrement Operators 9. Bitwise Operators 10. Assignment Operators and Expressions 11. Conditional Expressions 12. Precedence and Order of Evaluation 3. Chapter 3: Control Flow 1. Statements and Blocks 2. If-Else 3. Else-If 4. Switch 5. Loops - While and For 6. Loops - Do-While 7. Break and Continue 8. Goto and labels 4. Chapter 4: Functions and Program Structure 1. Basics of Functions 2. Functions Returning Non-integers 3. External Variables 4. Scope Rules 5. Header Files 6. Static Variables 7. Register Variables 8. Block Structure 9. Initialization 10. Recursion 11. The C Preprocessor 1. File Inclusion 2. Macro Substitution 3. Conditional Inclusion 5. Chapter 5: Pointers and Arrays 1.
    [Show full text]
  • Fundamentals of Programming Session 12
    Fundamentals of Programming Session 12 Instructor: Maryam Asadi Email: [email protected] 1 Fall 2018 These slides have been created using Deitel’s slides Sharif University of Technology Outlines Random Number Generation … Storage Classes Scope Rules 2 Random Number Generation … The values produced directly by rand are always in the range: 0 rand() RAND_MAX As you know, the following statement simulates rolling a six- sided die: face = 1 + rand() % 6; This statement always assigns an integer value (at random) to the variable face in the range 1 face 6. The width of this range (i.e., the number of consecutive integers in the range) is 6 and the starting number in the range is 1. 3 Random Number Generation … Referring to the preceding statement, we see that the width of the range is determined by the number used to scale rand with the remainder operator (i.e., 6), and the starting number of the range is equal to the number (i.e., 1) that is added to rand % 6. We can generalize this result as follows n = a + rand() % b; where a is the shifting value (which is equal to the first number in the desired range of consecutive integers) and b is the scaling factor (which is equal to the width of the desired range of consecutive integers). 4 Random Number Generation … 5 Random Number Generation … 6 Random Number Generation … Notice that a different sequence of random numbers is obtained each time the program is run, provided that a different seed is supplied. To randomize without entering a seed each time, use a statement like srand( time( NULL ) ); This causes the computer to read its clock to obtain the value for the seed automatically.
    [Show full text]
  • PRU Optimizing C/C++ Compiler User's Guide
    PRU Optimizing C/C++ Compiler v2.3 User's Guide Literature Number: SPRUHV7C July 2014–Revised July 2018 Contents Preface ........................................................................................................................................ 8 1 Introduction to the Software Development Tools.................................................................... 11 1.1 Software Development Tools Overview ................................................................................. 12 1.2 Compiler Interface.......................................................................................................... 13 1.3 ANSI/ISO Standard ........................................................................................................ 14 1.4 Output Files ................................................................................................................. 14 1.5 Utilities ....................................................................................................................... 14 2 Using the C/C++ Compiler ................................................................................................... 15 2.1 About the Compiler......................................................................................................... 16 2.2 Invoking the C/C++ Compiler ............................................................................................. 16 2.3 Changing the Compiler's Behavior with Options ....................................................................... 17 2.3.1 Linker
    [Show full text]
  • Lecture 14 07/02/03
    EE314 Spring 2003 Summer 2003 Lecture 14 07/02/03 LAB 6 Lab 6 involves interfacing to the IBM PC parallel port. Use the material on www.beyondlogic.org for reference. This lab requires the use of a Digilab board. Everyone should have one, but at least each group working together needs to have a board. Parallel Port Registers Address: Base + 0 => Data Port Base + 1 => Status Port Base + 2 => Control Port Status port bits: Signal Name Pin # Inverted Bit 7 Busy 11 Yes Bit 6 Ack 10 Bit 5 Paper Out 12 Bit 4 Select In 13 Bit 3 Error 15 Bit 2 IRQ N/A Bit 1 Reserved Bit 0 Reserved EE314 Spring 2003 Control Port Bits Signal Name Pin # Inverted Bit 7 Unused Bit 6 Unused Bit 5 Enable bi-directional port N/A Bit 4 Enable IRQ via ACK line N/A Bit 3 Select Printer 17 Yes Bit 2 Initialize Printer (Reset) 16 No Bit 1 Auto Linefeed 14 Yes Bit 0 Strobe 1 Yes Digilab Board Initialization: A program will be provided on the lab machines that is used to initialize the Digilab boards. It is called cfglab6.exe, and will be placed in a directory on the path, so that it can be executed simply by typing its name anywhere from a DOS prompt. C Programming Language Semantics Parameter passing to procedures: C is ‘call by value’ for scalar variables, ‘call by reference’ for vector variables. ‘Call by value’ means that the value of the parameter is pushed onto the stack and passed to the procedure as the parameter.
    [Show full text]
  • Fundamentals of C Structure of a C Program
    Fundamentals of C Structure of a C Program 1 Our First Simple Program Comments - Different Modes 2 Comments - Rules Preprocessor Directives Preprocessor directives start with # e.g. #include copies a file into the source code before compilation 2 forms…..we will usually see the first #include <systemFilename> #include “undefinedFilename” Within “ ” : personal file in your own directory 3 We will almost always use #include <stdio.h> • stdio.h is the standard input/output header • Contains code required for I/O (Input/Output) •.hfiles are header files Includes header ; The .obj part on Linking NO code is generally included except on linking • Header files contain definitions The function : main() ALL Programs must have a main() function. Later we will have add other functions. Different Formats: main( ) int main (void ) ***The book likes this void main(void) int main( ) 4 main( ) , void main(void) End with return; ************************** int main (void ) , int main( ) End with return 0; Back To Our First Program 5 Variables A Variable is a block of memory that stores data. A variable has a particular “Type”, i.e. it stores a particular kind of data A variable is named with an appropriate Identifier (or Name) Suppose we have a variable declared as follows: int number_of_days This reserves a block of memory which holds an integer 6 Schematic view: number_of_days 365 In the course of the program we might want to change the value in the variable. So that later we might want: number_of_days 7361 • The “actual” view of memory: 4 bytes number_of_days 01100000 11001010 10010100 00100111 So a variable takes a fixed number of bytes in memory 7 Rules for Naming Variables 1.
    [Show full text]
  • Lesson 01 Programming with C
    Lesson 01 Programming with C Pijushkanti Panigrahi What is C ? • The C is a programming Language, developed by Dennis Ritchie for creating system applications that directly interact with the hardware devices such as drivers, kernels, etc. • C programming is considered as the base for other programming languages, that is why it is known as mother language. • C is famous for its Compactness. • C language is case sensitive. 2 Features It can be defined by the following ways: Mother language System programming language Procedure-oriented programming language Structured programming language Mid-level programming language 3 1) C as a mother language ? • C language is considered as the mother language of all the modern programming languages because most of the compilers, JVMs, Kernels, etc. are written in C language , and most of the programming languages follow C syntax, for example, C++, Java, C#, etc. • It provides the core concepts like the array , strings , functions , file handling , etc . that are being used in many languages like C++ , Java , C# , etc. 4 2) C as a system programming language • A system programming language is used to create system software. • C language is a system programming language because it can be used to do low-level programming (for example driver and kernel) . • It is generally used to create hardware devices, OS, drivers, kernels, etc. For example, Linux kernel is written in C. 5 3) C as a procedural language • A procedure is known as a function, method, routine, subroutine, etc. A procedural language specifies a series of steps for the program to solve the problem.
    [Show full text]