Page | 1
Chapter 02: Programming In C                                              Class X
                                Short Questions
Q2. Give short answers to the following questions.
  i.      Define computer program.
   A program is a set of instruction(statements) written in a programming language
   to solve a particular problem.
                                              Or
   A program is a set of instruction that tells the computer what to do and how to
   do.
  ii.     Differentiate between syntax and semantic.
                Syntax                                   Semantic
  i.      Rules of a programming             i.    Gives meaning to statement.
          language.                         ii.    Describes the sequence of
  ii.     Describes the way to write               operation to be performed by a
          correct statement in a                   computer.
          program.
  iii.    Write three differences between assembly language and HLLs.
         Assembly Language                         High Level language
   i.     Consists of symbolic code or      i.     Use English language words
          abbreviations known as                   such as print, go to, if, end.
          mnemonics.                       ii.     Use compiler interpreter to
   ii.    Use assembler to convert                 convert high level language to
          assembly language to                     machine code.
          machine language.                iii.    Requires less attention to detail.
  iii.    Requires more attention to
          detail.
  iv.     Write four characteristics of HLLs.
   1. These languages were developed to make computer programming simple,
      easier and less prone to errors.
   2. The process of finding and removing errors in programs (debugging) is easier
      in high-level languages compared to low level language.
   3. Program written in high-level language must be translated into machine
      language by a compiler or an interpreter before execution by the computer.
   4. High-level languages are not machine dependent. They enable programmers
      to write programs that are independent of a particular type of computer.
  v.      Define Integrated Development Environment (IDE).
   IDE is a software that bring all the processes and tools required for program
   development into one place. It provides an ease to the programmer.
                                                                                    Page | 2
Chapter 02: Programming In C                                              Class X
  vi.     Differentiate between constant and variable.
              Constant                                    Variable
  1. Quantities whose values do not          1. Symbolic name that represents a
     change during execution.                   value that can change during
  2. In constant value was given in             execution.
     program while writing it.               2. In variable, value was given in
                                                program during execution.
  vii.    Which of the following are valid C variables? Give the reason if not a
          valid variable.
          area, 5x, Sum, net pay, float, _age, else, case, size22,
          my_weight
 Area                   reserved word
 Net pay                space cannot be included in a variable name.
 Float                  reserved word
 Case                    reserved word
 Else                   reserved word
  viii.   What are reserved words? Why they should not be used as
          variable names?
 Reserved words are part of programming language and have special
 purpose in computer program.
 Reserved words have predefined use so they cannot be used as
 variable or any other purpose.
  ix.     Why comments are used in programs?
  Comments are used in a program when a fact is necessary to be
  brought to the attention of program’s reader.
  Comments are used where something is to be clarified about the
  structure of the program.
  x.     What is the use of typecasting in C programs?
  Typecasting is used to convert variable from one data type to another
  data type. It make variable of one type act like another type.
                                                                                     Page | 3
Chapter 02: Programming In C                                           Class X
                            Extensive Questions
Q3. Describe the following HLLs.
    C/C++:
               C language was developed in 1970s by Dennis Ritchie.
               Highly structured language easy to use and understand.
               Mainly used for writing programs such as operating systems,
                compilers, assemblers
              C++ language was developed by Bjarne Stroustrup during the year
                1983-85.
              Superset of C.
              Provides programming facilities to easily and quickly write more
                powerful programs.
              Any valid C program is also a valid C++ program.
    Visual Basic:
              BASIC stands for Beginner’s All Purpose Symbolic Instruction
                Code.
              VB is an evolved version of BASIC.
              Popular for writing windows and web applications.
              Provides a graphical development environment.
              Commonly used for developing business programs.
    C#:
              Developed in 2000 by Microsoft Corporation.
              Pronounced as C sharp.
              Simple, modern and general-purpose programming language.
                Supports some features of Java.
              Provides facilities to write web applications that can be used
                across the world.
              Programs including games, utilities, OS, compilers, business
                development applications can be developed in C#.
     Java:
              High level language developed by sun microsystems.
              Similar to the syntax of C and C++.
              Small programs can be embedded in a web page.
              Ideal language for network computing.
              Used for writing programs for devices.
              Used in web applications.
              Java was enabled in most of the browsers.
Q4. Differentiate between compiler and interpreter.
               Compiler                                  Interpreter
   1. A compiler is software that           1. An interpreter is software that
      translates source program into           translates high level language into
      object program.                          machine language.
   2. Compiler translates the entire        2. Interpreter reads each statement
      program into object program              of source program, determine
      before execution by the computer.        what it means as it executes it.
                                               Means that each time a statement
                                               is read, it must be translated into
                                               machine language before
                                               execution.
   3. Compiler is fast.                     3. Interpreter is slow.
                                                                                          Page | 4
Chapter 02: Programming In C                                                 Class X
Q5. Describe the function of linker and loader programs.
    Linker:
            Linker intake the object codes generated by the assembler and combine
them to generate the executable module. Linker is a utility program. It generates the
executable module of a source program. It is the responsibility of linker to combines
all the object modules of a source code to generate an executable module.
   Loader:
         It is the responsibility of the loader to take the executable module to the
main memory. It allocates the addresses to an executable module in main memory.
Q6. What are the rules for specifying a variable name in C language?
    1. A variable begins with a letter or underscore ( _ ) and may consists of letters,
       underscores and/or digits.
    2. The underscore may be used to improve readability of the variable name. For
       example, over_time.
    3. There is no restriction on the length of a variable name. However, only the
       first 31 characters of a variable are significant. This means that if two
       variables have the same first 31 characters they are considered to be the
       same variables.
    4. Both upper and lower case letters are allowed in naming variable. An upper
       case letter is considered different from a lower case letter. For example, the
       variable AVG is different from Avg or avg.
    5. Special characters cannot be used as variable names. e.g. #, ?, @.
    6. Reserved words of C language such as int, case, if, etc., cannot be used as
       variable names.
    7. There must be no embedded blank in the name of variable. For example
       ma ss is not correct.
Q7. What is the difference between implicit typecasting and explicit
typecasting? Give examples.
                  Implicit                                   Explicit
Performed automatically by the compiler     Performed by programmer.
without programmer’s intervention.          The programmer explicitly defines the
The compiler converts all operands into     data types in parenthesis before the
the data type of the largest operand.       variable or expression.
Float value1=2.5;                           Int value1=30;
Float value2=5.3;                           Int value2=7;
Int result;                                 Float result;
Result=value1+value2;                       Result=(float)value1/value2;
Printf(“result=%d”, result);                Printf(“result : %f”, result);
                                                                                          Page | 5
Chapter 02: Programming In C                                                   Class X
Q8. What is a preprocessor? Give examples.
     Preprocessor directives are the instructions for the C compiler. Every C
language program contains certain preprocessor directives at the beginning of the
program. Before translating a C language program into machine language, the
compiler of C language carries out the processor directives. These directives start
with number sign(#).
Most commonly use preprocessor directives are:
  1. Include preprocessor directive
  2. Define preprocessor directive
   1. Include preprocessor directive: The preprocessor is carried out by the C
      compiler, it will search for the header file that is written in the less than and
      greater than symbol and copy it into the source file.
      Syntax:     #include <conio.h>
   2. Define preprocessor directive: The define preprocessor is used for defining
      constants (symbolic constant) in C program. It directs the compiler to replace
      all the occurrences of one or more variables in a program with the specified
      constant.
      The purpose is to give a meaningful name to a constant value that is to be in
      the program.
      Syntax:      #define symbol value/expression
                   #define HEIGHT 12