History of C Programming Language
57 Questions
3 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What was the original goal of the American National Standards Institute (ANSI) committee established in 1983 related to the C programming language?

  • To produce an ambiguous definition of the language C
  • To produce an unambiguous and machine independent definition of the language C (correct)
  • To produce a machine-dependent definition of the language C
  • To establish a committee to oversee the development of C++ language
  • Which programming language was UNIX primarily written in?

  • C++
  • C (correct)
  • Java
  • Assembly Language
  • What makes UNIX one of the first portable operating systems?

  • It was specifically designed for DEC PDP-11 computers
  • The majority of the code does not know or care about the computer it is running on (correct)
  • It relies heavily on specific hardware architecture
  • Machine-specific features are scattered throughout the UNIX code
  • Who originally designed the C programming language for use with UNIX on DEC PDP-11 computers?

    <p>Dennis Ritchie</p> Signup and view all the answers

    Which book was the first publication about the C programming language, authored by Brian Kernighan and Dennis Ritchie?

    <p>The C Programming Language</p> Signup and view all the answers

    What was one of the earlier forms of the C language before it evolved from B?

    <p>BCPL</p> Signup and view all the answers

    What is the purpose of local declarations in a C program?

    <p>To declare variables inside a given function or block</p> Signup and view all the answers

    Which of the following statements is considered part of a C program?

    <p>switch, case</p> Signup and view all the answers

    In C programming, what is the purpose of user-defined functions?

    <p>To specify operations as needed by the user</p> Signup and view all the answers

    What is the role of the return function in C programs?

    <p>To end the execution of a function</p> Signup and view all the answers

    Why must every file containing a C program be saved with a '.c' extension?

    <p>To allow linking with library functions</p> Signup and view all the answers

    What is the purpose of the linker in C programming?

    <p>To link object files with library functions</p> Signup and view all the answers

    Which component loads the executable file into RAM during program execution?

    <p>Loader</p> Signup and view all the answers

    What does the Instruction Register do during program execution?

    <p>Holds the current instructions for CPU execution</p> Signup and view all the answers

    'Program Counter' in C programming is responsible for:

    <p>Holding the address of the next instruction to be executed</p> Signup and view all the answers

    What does the Accumulator store during program execution in C programming?

    <p>Information related to calculations</p> Signup and view all the answers

    What is the name of the recognized standard for C language established by ANSI?

    <p>ANSI C</p> Signup and view all the answers

    Which organization established a standard for C similar to ANSI C?

    <p>ISO</p> Signup and view all the answers

    What is the primary advantage of using C for writing programs?

    <p>Efficiency and portability</p> Signup and view all the answers

    Which section of a C program includes program's name, date, and description?

    <p>Documentation section</p> Signup and view all the answers

    What purpose does the preprocessor section serve in a C program?

    <p>Link header files to system libraries</p> Signup and view all the answers

    Which keyword is used to declare constants in the define section of a C program?

    <p>#define</p> Signup and view all the answers

    What is the purpose of the main function in a C program?

    <p>To start program execution</p> Signup and view all the answers

    'void main()' versus 'int main()' in C programming primarily differs in:

    <p>Returned value type</p> Signup and view all the answers

    Why is C considered well-suited for writing both system and application software?

    <p>Availability of several data types and operators.</p> Signup and view all the answers

    What is the output of the following code snippet?

    #include int main() {
        int a, b, sum;
        printf("Enter two no: ");
        scanf("%d %d", &amp;a, &amp;b);
        sum = a + b;
        printf("Sum : %d", sum);
        return(0);
    }
    

    Given Input: 3 7

    <p>Enter two no: Sum : 10</p> Signup and view all the answers

    What does the C function 'ceil(number)' do?

    <p>Rounds up the given number to the nearest integer</p> Signup and view all the answers

    Which of the following is NOT a C keyword?

    <p>print</p> Signup and view all the answers

    What does the 'pow(base, exponent)' function do in C?

    <p>Returns the power of the given number</p> Signup and view all the answers

    In C programming, what do identifiers refer to?

    <p>Names of variables and program elements like functions</p> Signup and view all the answers

    What is an essential requirement for declaring identifiers in C programming?

    <p>Not being a reserved keyword</p> Signup and view all the answers

    What is the purpose of assigning values to variables in a C program?

    <p>To store and manipulate data during program execution</p> Signup and view all the answers

    'sizeof' is an example of which of the following in C programming?

    <p>'C' operator to determine memory consumption</p> Signup and view all the answers

    'int_amt=(prt)/100;' in C programming is an example of what?

    <p>Assignment operation with arithmetic expression</p> Signup and view all the answers

    Which function in C programming rounds down a given number?

    <p>floor(number)</p> Signup and view all the answers

    Which type of variable retains its value between multiple function calls?

    <p>Static variable</p> Signup and view all the answers

    What is the default visibility scope of automatic variables in C?

    <p>Local</p> Signup and view all the answers

    In C, where must global variables be declared?

    <p>Outside any function or block</p> Signup and view all the answers

    What is the purpose of the static keyword when declaring a variable in C?

    <p>To retain the variable's value between function calls</p> Signup and view all the answers

    Which storage class is associated with automatic variables in C?

    <p>Auto</p> Signup and view all the answers

    What is the default lifetime of static variables in C?

    <p>Till the end of the main program</p> Signup and view all the answers

    Which symbol is not allowed to start a variable name in C?

    <h1>(hash)</h1> Signup and view all the answers

    'int long' is an invalid variable name in C because:

    <p>'int long' is a reserved keyword in C.</p> Signup and view all the answers

    'extern int x=10;' declares an external variable with an initial value. Why might this declaration cause issues?

    <p>'extern' variables should not be explicitly initialized.</p> Signup and view all the answers

    Which data type is used to store the address of a variable in C?

    <p>Pointer data type</p> Signup and view all the answers

    What is the range of an unsigned char data type in C?

    <p>0 to 255</p> Signup and view all the answers

    Which of the following is an example of a derived data type in C?

    <p>Array</p> Signup and view all the answers

    What is the purpose of using typedef in C?

    <p>To create new variable names</p> Signup and view all the answers

    What do escape sequences represent in C?

    <p>Control characters like newline, tab</p> Signup and view all the answers

    Which type of constant allows for increasing the storage range in C?

    <p>Unsigned constant</p> Signup and view all the answers

    'I am a little boy' would be classified as:

    <p>'I' string constant</p> Signup and view all the answers

    'typedef int Integer;' statement creates a synonym for which data type?

    <p>'int'</p> Signup and view all the answers

    Which storage class in C allows variables to hold their value between multiple function calls?

    <p>Static</p> Signup and view all the answers

    In C, which storage class allows variables to be stored in the CPU registers?

    <p>Register</p> Signup and view all the answers

    What happens if you try to dereference a register variable in C?

    <p>It is not allowed and will result in a compilation error</p> Signup and view all the answers

    What does the extern storage class declaration indicate in C?

    <p>Variable is declared elsewhere with external linkage</p> Signup and view all the answers

    What does the compiler do if an extern variable in C is not initialized within the program?

    <p>Searches for it to be initialized somewhere in the program</p> Signup and view all the answers

    Study Notes

    History of C

    • The C language was first proposed in 1972 by Dennis M. Ritchie at Bell Laboratories, USA.
    • In 1983, the American National Standards Institute (ANSI) established a committee to standardize the definition of C, resulting in ANSI C.
    • ANSI C is the recognized standard for the language, grammar, and core set of libraries.

    Characteristics of C

    • C is a robust language with a rich set of built-in functions, data types, and operators.
    • Programs written in C are efficient due to the availability of several data types and operators.
    • C is a highly portable language, allowing code written on one machine to be easily moved to another.
    • C supports low-level features like bit-level programming and direct access to memory using pointers.

    Basic Structure of a C Program

    • A C program consists of several sections, including:
      • Documentation section (includes comments and program description)
      • Preprocessor section (includes header files and library links)
      • Definition section (includes constants and macros)
      • Global declaration section (includes global variables and functions)
      • Main function (the entry point of the program)
      • User-defined functions (custom functions written by the programmer)

    Program Execution

    • When a C program is compiled and executed, the compiler generates several files, including:
      • Source file (with a .c extension)
      • Object file (with a .obj extension)
      • Executable file (with a .exe extension)
    • The program is executed in the following steps:
      1. The loader loads the executable file into RAM and informs the CPU of the starting point.
      2. The CPU executes the program, using the Instruction Register and Program Counter.

    C Math Functions

    • C provides several math functions, including:
      • ceil() (rounds up a number)
      • floor() (rounds down a number)
      • sqrt() (returns the square root of a number)
      • pow() (returns the power of a number)
      • abs() (returns the absolute value of a number)

    C Tokens

    • Tokens are the individual units of a C program, including:
      • Keywords (reserved words with specific meanings)
      • Identifiers (names of variables, functions, and arrays)
      • Constants (numeric, character, or string values)
      • Operators (symbols used for arithmetic, comparison, and logical operations)
      • Punctuators (symbols used for grouping and separating tokens)

    Keywords

    • Keywords are reserved words in C, including:
      • auto
      • double
      • int
      • struct
      • break
      • else
      • long
      • switch
      • ...

    Identifiers

    • Identifiers are names of variables, functions, and arrays, and must follow certain rules:
      • Can be named from a combination of A-Z, a-z, 0-9, and _
      • First character must be an alphabet or underscore
      • Must not be a keyword
      • Can be up to 31 characters long

    Data Types

    • C provides several data types, including:
      • int
      • float
      • char
      • double
      • long
      • short
      • unsigned
      • ...

    Variables

    • Variables are named storage locations that can hold different values, and can be:
      • Local (declared inside a function or block)
      • Global (declared outside a function or block)
      • Static (retains its value between multiple function calls)
      • Automatic (allocated memory automatically at runtime)
      • External (shared across multiple C source files)

    Storage Classes

    • Storage classes in C determine the lifetime, visibility, memory location, and initial value of a variable, including:
      • Automatic
      • External
      • Static
      • Register### C Data Types
    • C supports four classes of data types: basic, derived, user-defined, and pointer data types.

    Basic Data Types

    • Basic data types support arithmetic operations such as addition and subtraction.
    • Examples: int a, b;, char c;
    • Storage size and range of basic data types:
      • Unsigned char: 8 bits, 0 to 255
      • Char: 8 bits, -128 to 127
      • Short int: 16 bits, -32768 to 32767
      • Unsigned int: 32 bits, 0 to 4294967295
      • Int: 32 bits, -2147483648 to 2147483648
      • Unsigned long: 32 bits, 0 to 4294967295
      • Enum: 16 bits, -2147483648 to 2147483648
      • Long: 32 bits, -2147483648 to 2147483648
      • Float: 32 bits, 3.4e-38 to 3.4e38
      • Double: 64 bits, 1.7e-308 to 1.7e308
      • Long double: 80 bits, 3.4e-4932 to 1.1e4932

    Derived Data Types

    • Derived data types store a set of data values.
    • Examples: arrays and structures.

    User-Defined Data Types

    • C provides a facility called typedef for creating new data type names defined by the user.
    • Example: typedef int Integer; makes Integer a synonym of int.

    Pointer Data Types

    • Pointer data types store the address of a variable.

    Constants

    • A constant is a quantity that does not vary during the execution of a program.
    • Two types of constants: numeric and character constants.

    Numeric Constants

    • Examples: 786, -127, 1234567899L (long constant)
    • Unsigned constants: 123456789u (unsigned constant), 1234567891ul (unsigned long constant)
    • Advantage of declaring an unsigned constant: increases the range of storage.
    • Floating-point constants: 123.4, 1e-2, 1.4E-4

    Character Constants

    • A character constant is written as one character within single quotes, e.g. 'a'.
    • Escape sequences: \a (alert), \b (backspace), \f (form feed), \n (new line), \r (carriage return), \t (horizontal tab), \v (vertical tab)

    String Constants

    • A string constant is a sequence of zero or more characters surrounded by a double quote, e.g. " I am a little boy".
    • Quotes are not part of the string.

    Enumeration Constants

    • An enumeration constant is a list of constant integer values, e.g. enum color { RED, Green, BLUE }.
    • The first name in the enum has the value 0, and the next 1, and so on unless explicit values are specified.

    Variables

    • auto variables: default initial value is garbage.
    • static variables:
      • Hold their value between multiple function calls.
      • Visible only to the function or block in which they are defined.
      • Can be declared many times but can be assigned at only one time.
      • Default initial value of static integral variables is 0 otherwise null.
    • register variables:
      • Allocated memory into the CPU registers.
      • Can not be dereferenced (i.e., can not use & operator).
      • Access time is faster than automatic variables.
      • Initial default value of register local variables is 0.
      • Can store pointers into the register.
    • extern variables:
      • Used to tell the compiler that the variable is declared with an external linkage elsewhere in the program.
      • Not allocated any memory.
      • Default initial value of external integral type is 0 otherwise null.
      • Can only initialize the extern variable globally.
      • Can be declared many times but can be initialized at only once.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Explore the evolution and milestones of the C programming language, which originated at Bell Laboratories in 1972. Learn about the standardization efforts by ANSI and its association with UNIX.

    More Like This

    Java Programming Language Quiz
    20 questions
    C Programming Language Quiz
    10 questions
    History of C Programming Language
    10 questions
    History of C Programming Language
    40 questions
    Use Quizgecko on...
    Browser
    Browser