Monday, 17 November 2014

Previous Year BCPC Paper

Final Semester exam question paper with solution 
Section A
(i)What is the syntax of nested If Statement?


(i) C language supports if-else-if statements to test additional conditions apart from the initial test expression. The if-else-if construct works in the same way as a normal if statement. 

     The construct is called NESTED IF STATEMENTS

     It is not necessary that every if  statement shoulld have an else  block as C supports simple if  statement. After the first test expression or the first if  branch, we can have as many else-if branches as we want depending on the expressions that have to be tested.

  Syntax of if-else-if statement

if (test expression 1)
 {

    Statement block 1;

      if(Statement Block 3)

       { Statement Block 3;

        }
      else
       {Statement Block 4;
        }
  }
else if(test expression 2)
{ Statement block 2
 }
(ii) What is Conditional Operator in C.
(ii) The conditional operator in C is also known as ternary operator. It is called ternary operator because it takes three arguments. 
      Syntax
      expression 1 ? expression 2 : expression 3
  
 Where

  •   Expression 1 is called Condition.
  •   Expression 2 is Statement Followed when Condition is True.
  •   Expression 3 is Statement followed when Condition is False.


     Working

  1. Expression 1 is a Boolean Condition i.e it results into TRUE or FALSE.
  1. If the result of Expression 1 is TRUE(NON ZERO value), then Expression 2 is executed.
  1. If the result of Expression 2 is FALSE(ZERO value), then Expression 3 will be executed.


      Example

      #include<stdio.h>

      #include<conio.h>

       void main()

       { int num;     //declaring int variable.

          clrscr();      //Clearing Screen.

          printf("Enter the Number to check Even or Odd"); //Printing.  

          scanf("%d",&num);   //Input

         (num%2==0)? printf("Even") : printf("Odd");   //Condtional operator

          getch();
        }
(iii) What is a compiler ?
(iii) A compiler is a computer program (or set of programs) that transforms source code wriiten in a  programming language (the source language) into another computer language (the target language,often having a binary from known as object code). The most common reason for converting a source code is to create an executable program. 
  Compiler bridge source program in high level languages with the underlying hardware. A compiler consist of :

  1. Front End :- Verifies syntax and semantics.
  1. Middle End:- Performs optimizations, including removal of useless or unreachable code,discovery and propogation of constant values.
  1. Back End:- Generates the assembly code, performing register allocation in process.   


 (iv) What is the need of Operating System?

 (iv) Usage of Operating System:

  1. Easy interaction between the human & computer.
  2. Starting computer operation automatically when power in turned on.
  3. Loading & scheduling users program.
  4. Controlling input & output.
  5. Controlling program execution.
  6. Managing use of main memory.
  7. Providing security to users program.


(v) Differentiate between Compiler and interpreter.

(v) The main differences between compiler and interpreter are listed below:


  • The interpreter takes one statement then translates it and executes it and then takes another statement. While the compiler translates the entire program in one go and then executes it.
  • Compiler generates the error report after the translation of the entire page while an interpreter will stop the translation after it gets the first error.
  • Compiler takes a larger amount of time in analyzing and processing the high level language code comparatively interpreter takes lesser time in the same process.
  • Besides the processing and analyzing time the overall execution time of a code is faster for compiler relative to the interpreter.
 (vi) What are the various types of software used in computers ?
 (vi) Although the range of software available today is vast and varied, most of the software can be divided into two major categories:-

   System Software
   System software is a set of one or more programs designed to control the operations and extend the processing capability of the computer system. In general System Software perform following functions:-
  1. Supports development of other application software.
  2. Supports execution of other application software.
  3. Monitors effective use of various hardware resources such as CPU, memory, peripherals, etc.
  4. Communicates with and controls operation of peripheral devices such as printer, disk, tape, etc. 
  Application Software
Application software is a set of one or more programs designed to solve a specific problem, or do a specific ask. For example, payroll processing software, examination results processing software. etc. The programs included in an application software package are called application programs. The programmers who prepare application software are referred to as application programmers.

(vii) How many bytes are required for Int a[20] statement?
 (vii)  QUESTION DOUBT 

(viii) What is an algorithm?
(viii) Planning a program involves defining its logic .The term algorithm refers to the logic of a program. it is a step-by-step description of how to arrive at a solution to a given problem. It is defined as a sequence of instruction that when executed in the specified sequence, the desired results are obtained. In order to qualify as an algorithm, a sequence of instruction must process the following characteristics:
  1. Each instruction should be precise and unambiguous.
  2. Each instruction should be executed in /a finite time.
  3. One or more instruction should not be repeated infinitely. This ensures that the algorithm will ultimately terminate.
  4. After executing the instruction (when the algorithm terminates), the desired results are obtained.
(ix) How structure is represented?
(ix)  A structure contains a number of data types grouped together. These data types may or may not be of the dame type.
  syntax:
  struct <strructure name>
    {structure element 1;
      structure element 2;
      structure element 3;
      .......
      .......
     };
Memory representation of structure

(x) What is conditional statement?
(x) Conditional statements are used to execute a statement or a group of statement based on certain conditions.
1) if conditional statement in C :

Syntax for if statement in C :



if(condition)
{
Valid C Statements;


}

2) if else in C :

Syntax for if :

if(condition)
{
Valid C Statements;
}
else
{
Valid C Statements;
}

3) else if in C :

Syntax :

if(condition)
{
Valid C Statements;
}
else if(condition 1)
{
Valid C Statements;
}
-
-
else if(condition n)
{
Valid C Statements;
}
else
{
Valid C Statements;
}

4) Switch statement in C :

Syntax :

switch(variable)
{
case 1:
Valid C Statements;
break;
-
-
case n:
Valid C Statements;
break;
default:
Valid C Statements;
break;
}

5) goto statement in C :

goto is a unconditional jump statement.

Syntax :

goto label;

6) The conditional Operators
    The conditional operators ? and : are sometimes called ternary operators they take three arguments.
   
    Syntax:
    expression 1? expression 2 : expression 3
Section B
Ques 2) What are the various Output devices of computers? Explain the working principle of each of them.
Ans 2) Output device is an electromechanical device that accepts data from a computer and translates them into a form of suitable for use by outside world (users). Several output devices are available today. Classified as:-
  1. Monitors.
  2. printers
  3. Plotters
  4. Screen image projector.
  5. Voice response system.

Monitors
 Monitors are the most popular output devices used today for producing soft-copy output. They display the generated output on a television like screen. A monitor is associated usually with a keyboard and together they form a video display terminal(VDT).

  

Sunday, 9 November 2014

My Blogs List

     My Blogs List

       Hello Guys,
                          Here is my blog on C language and will be posting more languages blog stay in touch.
        
         1) My C Blog