(X) C Programming Theory

C Programming - 1 mark Questions
  1. What is C programming language?
    Answer:   A structure programming language, which was developed by Dennis Ritchie at Bell laboratories in 1972 AD is called C programming language.
  2. List any two characteristics / features of C language.
    Answer:  (i) It is structured programming language.
                    (ii) It has both the features of high level languages as well as low level languages.
  3. List any two similarities between QBASIC and C language.
    Answer:  (i) Both QBASIC and C language are high level programming language.
             (ii) Both QBASIC and C language are structured programming language.
             (iii) Both QBASIC and C language supports local and global variables.
  4. Differentiate between QBASIC and C language.
    Answer: 
  5. QBASIC C Programming
    (i) It is used to design application software. (i) It is used to design system software.
    (ii) It supports both function and sub procedures. (ii) It supports only function procedures.
  6. What is structured programming language?
    Answer:  An approach in which emphasis is given on data rather than procedure and follows top bottom approach is called structured programming language.
  7. Why C is called structured programming language?
    Answer:  C is called structured programming language because a program in C language can be divided into small logical functional modules or structures with the help of function procedure.
  8. Write any two advantages of structured programming.
    Answer:
    (i) Easy to learn and understand the program
    (ii) More than one programmers can work in the one system
  9. Write any two keywords of C language.
    Answer:  (i) int     (ii) float       (iii) char        [Note: C has 32 keywords. You can write any two]
  10. " C is also called middle level programming language". Justify this statement.
    Answer:  C is called middle level language because it  combines elements of a high level language with some features of assembler.
  11. List any two (basic or primary) data type supported by C language.
    Answer:  (i) int    (ii) float     (iii) char      (iv) double     [Note: write any two ]
  12. Data Type Keyword Type Specifier
    Decimal Integer(Whole numbers ONLY) int %d
    Single Precision of 6 digits decimal points
    (Fractional Number)
    float %f
    Single Character char %c
    String [Collection of Characters] char v_name[size]; %s
  13. Name some data modifiers used in C language.
    Answer:  (i) short   (ii) long     (iii) signed      (iv) unsigned 
  14. Write down the functions of printf and scanf.
    Answer: printf is used to display contents(text/number) where as scanf is used to get inputs from the user. To use printf and scanf we have to include <stdio.h> in our program. stdio stands for Standard Input Output header file.
  15. Define operator in C.
    Answer: The symbols, which are used to computer values based on mathematical calculations , and test multiple conditions is called operators.
    The data on which the operations are performed are called operands.
    For example: sum=a+b, here sum,a,b are operands. = and + are operators.
  16. List the arithmetic operator with their meaning and example.
    Answer:
    Operator Description
    + (Plus) - Addition Adds two operands
    - (Minus) - Subtraction Subtracts second operand from first operand
    * (Asterisk) - Multiplication Multiply two operands
     / (Slash) - Division Divides first operand by second operand
     % (Percentage symbol) - Modulus Division Provides remainder when first operand is divided by second operand
    Suppose A = 10 and B = 20 then
    A+B=10+20=30
    A-B=10-20=-10
    A*B=10*20=200
    B/A= 20/10=2
    B%A= 20%10=0
  17. List unary operator with their meaning and example.
    Answer: Unary operator is used in looping statement.
    Operator Description
    ++ (Plus Plus) - Increment Operator Increases the value of operand by 1
    -- (Minus Minus) - Decrement Operator Decreases the value of operand by 1
    Suppose A = 10 and B = 20 then
    A++ = 11
    B--    = 19
  18. List relational operator with their meaning and example.
    Answer: Relational operator checks the relationship between two operands and returns either 1(True) or 0 (False). There are six types of relational or comparison operator.
    Operator Description
    > Greater than
    >= Greater than or equal to
    < Smaller than
    <= Smaller than or equal to
    == Equal to
    != Not equal to
  19. Suppose A = 5 and B = 10 then
    A>B
      Result : 0 (False)
    A>=B
      Result : 0 (False)
    A<B
      Result : 1 (True)
    A<=B
      Result : 1 (True_
    A==B
      Result : 0 (False)
    A!=B
      Result : 1 (True)
  20. List three types of Logical operator.
    Answer:
    OperatorDescription
    &&AND
    ||OR
    !NOT
  21. Define decision making statements. List the decision making statements supported by C.
    Answer: The statements which display one statement when the condition is true, otherwise display another statement is called decision making statement. Since these statements "control" the flow of execution , they are also called Control Structure.
    C has two major decision making statement.
    (a) if statement
    (b) switch statement
  22. Define C expression. Convert following algebraic expression into C expression.
    Answer: A combination of variables, constants and operators written according to the syntax of C language is called C expression. In C every expression evaluates to value.
    Algebraic Expression C Expression
    a x b - c  a * b  - c
    ( m + n) ( x + y ) (m + n) * (x + y)
    ( ab / c ) a * b / c
     3x2 + 2x + 1 3*x*x + 2*x + 1
     ( x / y ) + c x / y + c
  23. Define looping. List the three types of loop used in C Programming.
    Answer: 
    A control structure that executes the same program statement or block of program statements repeatedly for specified number of times or till the given condition is satisfied is called Looping.
    Three types of loop used in C programming are:
    (a) for Loop       (b) While Loop      (c) do while Loop
  24. Write down the syntax of for, while and do while loop.
    Answer: Each loop has three components:
    (i) Initialization means Starting Point
    (ii) Condition means Stopping Point
    (iii) increment / decrement means counter.
    Syntax of for loop:
    for(initialization ; condition ; increment / decrement)
    {
           statements;
    }


    Syntax of while loop:
    initialization;
    while (condition)
    {
            statements;
            increment/decrement;
    }

    Syntax of do while loop:
    initialization;
    do
    {
            statements;
            increment/decrement;
    }while (condition);