HSEB computer solved

Computer Solved question 2069-2072
HSEB-GRADE XII
2072(2015)
Sub: Computer Science
Group 'A'
1,a) What is looping? Describe 'for' and 'while' loop with appropriate example.
Answer:
'A loop' is a part of code of a program which is executed repeatedly. A loop is used using condition. The repetition is done until condition becomes condition true. A loop declaration and execution can be done in following ways:
·         Check condition to start a loop
·         Initialize loop with declaring a variable.
·         Executing statements inside loop.
·         Increment or decrement of value of a variable.

'For' loop is a programming language control statement for specifying iteration, which allows code to be executed repeatedly until condition is tru.
In C programming, Syntax:
for(initial value;condition;counter)
{
                Statement...
}
Step 1,
The initial step is executed first, and only once. This step allows to declare and initialize any loop control variables.
Step 2,
The condition is evaluated. If it is true, the body of the loop is executed. If it is false, Loop is stop.
Step 3,
After the body of the 'for' loop executes, the flow of control jumps back up to the counter. This statement allows to update any loop control variables. After that it will check the condition.
The condition is true, the loop executes and the process repeats itself, After the condition becomes false, the 'for' loop terminates.
Example:
#include<stdio.h>
void main()
{
Int I;
For(i=1;i<=5;i++)
{
printf(“Condition is true\n”);
}
printf(“program End\n”);
}

‘While loop’ Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body. In C programming, Syntax:
while(Condition)
{
                Statement...
Counter (increment / decrement)
}
Example:
#include <stdio.h>
int main()
{
  int x = 0;   
  while ( x < 10 )
{
      printf( "%d\n", x );
      x++; 
  }
}

1,b) Write a program to check if a given number is odd or even using if statement.
Answer:
#include<stdio.h>
void main()
{
    int num;
    printf("Input Number:");
    scanf("%d",&num);
    if(num%2==0)
    printf("%d is Even\n",num);
    else
    printf("%d is Odd\n",num);
}


2) Describe any five string handling function with example.
Answer:

Function Name
Description
strlen
Returns the length of a string.
strlwr
Returns upper case letter to lower case.
strupr
Returns lower case letter to upper case.
strcmp
Compares two strings.
strrev
Returns length of a string.

Example:
#include <stdio.h>
#include <string.h>
void main()
{      
       char str[50];
       char *m="abc";
       printf("\n\t Enter your name : ");
       gets(str);
       printf("\nLower case of string: %s",strlwr(str));
       printf("\nUpper case of string: %s",strupr(str));
       printf("\nReverse of string: %s",strrev(str));
       printf("\nLength of String: %d",strlen(str));    
       printf("\nString compare %d ",strcmp(str,m));
}

3) What is array? Write a program to find addition of two matrices.
Answer:
Array is a collection of homogenous data stored under unique name. The values in an array is called as 'elements of an array.' These elements are accessed by numbers called as 'subscripts or index numbers.' Arrays may be of any variable type. Array is also called as 'subscripted variable.'
Types of an Array :
1. One / Single Dimensional Array
2. Two Dimensional Array
Single / One Dimensional Array :
The array which is used to represent and store data in a linear form is called as 'single or one dimensional array.'
Two Dimensional Array : The array which is used to represent and store data in a tabular form is called as 'two dimensional array.' Such type of array specially used to represent data in a matrix form.
Example: addition of two matrices
#include<stdio.h>
void main()
{
  int a[3][3],b[3][3],c[3][3],i,j;
  puts("First matrix:");
  for(i=0;i<3;i++)
      for(j=0;j<3;j++)
           scanf("%d",&a[i][j]);
  puts("\nSecond matrix:");
  for(i=0;i<3;i++)
      for(j=0;j<3;j++)
           scanf("%d",&b[i][j]);

   for(i=0;i<3;i++)
       for(j=0;j<3;j++)
            c[i][j]=a[i][j]+b[i][j];
   printf("\nThe Addition of two matrix is\n");
   for(i=0;i<3;i++){
       printf("\n");
       for(j=0;j<3;j++)
            printf("%d\t",c[i][j]);
   }
  
}

4,a)Differentiate between structure and union.
Answer:
Structure is user defined data type which is used to store heterogeneous data under unique name. Keyword 'struct' is used to declare structure. The variables which are declared inside the structure are called as 'members of structure'.

Union is user defined data type used to stored data under unique variable name at single memory location. Union is similar to that of structure. Syntax of union is similar to structure.
The major difference between structure and union is 'storage.'
In structures, each member has its own storage location, whereas all the members of union use the same location. Union contains many members of different types, it can handle only one member at a time.

4,b) Write a program to find greatest number among four numbers.
Answer:
#include<stdio.h>
void main()
{
  int i,j,gt=0;
  int n[4];
  for(i=0;i<4;i++)
  {
      printf("%d, Input Number:",i);
      scanf("%d",&n[i]);
  }
  for(j=0;j<4;j++)
  {
      if(gt<=n[j])
      {
          gt=n[j];
      }

  }
   printf("%d\n",gt);
}

5,a) Describe any two file handling functions.
Answer:
fopen()
Creates a new file. Opens an existing file.
fclose
Closes a file which has been opened for use

To use files in C programs, must declare a file variable to use. This variable must be of type FILE, and be declared as a pointer type. FILE is a predefined type.
Syntax: FILE  *file_pointer;
Syntax for 'fopen()' function:
file_pointer=fopen("file name", file handling mode);
'fclose()' function use for closing the opened file.
Example:
#include
void main(void)
{
FILE *fp;
char c;
myfile = fopen("firstfile.txt", "r");
if (fp == NULL)
printf("File doesn't exist\n");
else
{
do {
c = getc(fp);
putchar(c);
} while (c != EOF);
}
fclose(fp);
}
5,b) Write a program to display name, age and address reading from file 'record.dat'.
Answer:
#include "stdio.h"
void main()
{
  FILE *f;
  char ch;
  f=fopen("'record.dat'","r");
  while((ch=fgetc(f))!= EOF)
  printf("%c",ch);
  fclose(f);
}




HSEB-GRADE XII
2070(2014)
Computer Science
Candidates are required to give their answer in their own words as far as practicable.

Group ‘A’
Long answer questions
Attempt any four questions
1.         Write a program which reads name of 100 students and sort them in alphabetical order.
Answer:
#include<stdio.h>
void main()
{
    char nm[100][20];
    char tmp[20];
    int r=100,i,m,n,j;
    for(i=0;i<r;i++)
    {
        printf("Input Name:");
        scanf("%s",&nm[i]);
    }
    printf("\n\n\nsorting:\n");
    for(m=0;m<r;m++)
    {
        for(n=0;n<r;n++)
        {
            if(strcmp(nm[n-1],nm[n])>0)
            {
                strcpy(tmp,nm[n-1]);
                strcpy(nm[n-1],nm[n]);
                strcpy(nm[n],tmp);
            }
        }
    }
    for(j=0;j<r;j++)
    {
        printf("%s\n",nm[j]);
    }
}

1.         Describe ‘Sequence’, ‘Selection’ and ‘Loop’ with flowchart. Write a program to check if a number is odd or even.
Answer:
Sequence: A sequence point defines any point in a computer program's execution at which it is guaranteed that all effects of previous evaluations will have been performed. They are often mentioned in reference to C, because the result of some expressions can depend on the order of evaluation of their sub-expressions. Adding one or more sequence points is one method of ensuring a consistent result, because this restricts the possible orders of evaluation.













Selection: selection also called a decision, one of the three basic logic structures in c programming. The other two logic structures are sequence and loop. In a selection structure, a question is asked, and depending on the answer, the program takes one of two courses of action, after which the program moves on to the next event. 



















Loop: 'A loop' is a part of code of a program which is executed repeatedly. A loop is used using condition. The repetition is done until condition becomes condition true. A loop declaration and execution can be done in following ways:
           Check condition to start a loop
           Initialize loop with declaring a variable.
           Executing statements inside loop.
           Increment or decrement of value of a variable.







Odd, Even program:
#include<stdio.h>
void main()
{
    int num;
    printf("Input Number:");
    scanf("%d",&num);
    if(num%2==0)
    printf("%d is Even\n",num);
    else
    printf("%d is Odd\n",num);
}

2.         What is pointer? Describe the benefits of pointer with example.
Answer:
Pointer is a variable which holds the memory address of another address variable. Pointers are represented by '*'. It is a derive data type in C. Pointer returns the value of stored address.
Benefits of pointers:
           Pointers provide direct access to memory
           Pointers provide a way to return more than one value to the functions
           Reduces the storage space and complexity of the program
           Reduces the execution time of the program
           Provides an alternate way to access array elements
           Pointers can be used to pass information back and forth between the calling function and called function.
           Pointers allows us to perform dynamic memory allocation and deallocation.
           Pointers helps us to build complex data structures like linked list, stack, queues, trees, graphs etc.
           Pointers allows us to resize the dynamically allocated memory block.
           Addresses of objects can be extracted using pointers
 Example:
#include <stdio.h>
#include <conio.h>
void main()
{
int a=10;
int *ptr;
clrscr();
ptr = &a;
printf("\n\t Value of a : %d", a);
printf("\n\n\t Address of pointer ptr : %d", ptr);
getch();
}

3.         What is an array? Write a program which finds multiplication table of two matrices (3*3).
Answer:
Array is a collection of homogenous data stored under unique name. The values in an array is called as 'elements of an array.' These elements are accessed by numbers called as 'subscripts or index numbers.' Arrays may be of any variable type. Array is also called as 'subscripted variable.'
Types of an Array :
1. One / Single Dimensional Array
2. Two Dimensional Array
Single / One Dimensional Array :
The array which is used to represent and store data in a linear form is called as 'single or one dimensional array.'
Two Dimensional Array : The array which is used to represent and store data in a tabular form is called as 'two dimensional array.' Such type of array specially used to represent data in a matrix form.

Program:
 #include <stdio.h>
void main()
{
    int m[3][3];
    int n[3][3];
    int mn[3][3];
    int i,j,k,l;
    int x,y,z,v;
    int a,s,q;
    int sum=0;
    printf("Input 3*3 Matrix A=[]:\n");
    for(j=0;j<3;j++)
    {
        for(k=0;k<3;k++)
        {
            scanf("%d",&m[j][k]);
        }
    }
    printf("Input 3*3 Matrix B=[]:\n");
    for(x=0;x<3;x++)
    {
        for(y=0;y<3;y++)
        {
            scanf("%d",&n[x][y]);
        }
    }

    printf("Matrix table:\n");
    printf("A=");
    for(l=0;l<3;l++)
    {
        for(i=0;i<3;i++)
        {
            printf("\t%d",m[l][i]);
        }
        putchar('\n');
    }

    printf("\n\nB=");
    for(l=0;l<3;l++)
    {
        for(i=0;i<3;i++)
        {
            printf("\t%d",n[l][i]);
        }
        putchar('\n');
    }
       //matrix calculation
    for(a=0;a<3;a++)
    {
        for(s=0;s<3;s++)
        {
            sum=0;
            for(q=0;q<3;q++)
            {

                sum=sum+(m[a][q]*n[q][s]);
            }
            mn[a][s]=sum;

        }
    }

    //matrix calculation end here
    //display result
    printf("Answer:\n");
    for(l=0;l<3;l++)
    {
        for(i=0;i<3;i++)
        {
            printf("\t%d",mn[l][i]);
        }
        putchar('\n');
    }

}


4.         Write a program which reads name, roll number and age from a file named “student.dat” and display them.
Answer:

#include <stdio.h>
void main()
{
 FILE *fp;
 char c;
 fp=fopen("students.dat","r");
puts("Name roll age");
        while((c=fgetc(fp))!=EOF)
        {

           printf("%c",c);

        }
}





Group ‘B’
Short answer questions
Attempt any seven questions:
5.         Describe different levels of feasibility study.
Answer:
Different levels of feasibilities are:
• Technical feasibility
• Economic feasibility
• Operational feasibility
• Legal feasibility
Technical Feasibility:
Technical feasibility is concerned with the availability of hardware and software required for the development of the system, to see compatibility and maturity of the technology proposed to be used and to see the availability of the required technical manpower to develop the system.

Economic Feasibility:
It is the measure of cost effectiveness of the project. The economic feasibility is nothing but judging whether the possible benefit of solving the problems is worthwhile or not. When the specific requirements and solutions have been identified, the analyst weighs the cost and benefits of all solutions, this is called “cost benefit analysis”. A project which is expensive when compared to the savings that can be made from its usage, then this project may be treated as economically infeasible.

Operational Feasibility:
Operational feasibility is all about problems that may arise during operations.
Information The system needs to provide adequate, timely, accurate and useful information. It should be able to supply all the useful and required information to all levels and categories of users.
Response time It needs to study the response time of the system in term of throughput. It should be fast enough to give the required output to the users.
Accuracy A software system must operate accurately. It means that it should provide value to its users. Accuracy is the degree to which the software performs its required functions and gives desired output correctly.
Security There should be adequate security to information and data. It should be able to protect itself from fraud.
Services The system needs to be able to provide desirable and reliable services to its users.
Efficiency The system needs to be able to use maximum of the available resources in an efficient manner so that there are no delays in execution of jobs.

Legal Feasibility:
Legal feasibility studies issues arising out of the need to the development of the system. The possible consideration might include copyright law, labor law, antitrust legislation, foreign trade, regulation, etc. Legal feasibility plays a major role in formulating contracts between vendors and users.

6.         Who is system analyst? List out the rolls of system analyst.
Answer:
The work of a systems analyst who designs an information system is the same as an architect of a house. Three groups of people are involved in developing information systems for organizations. They are managers, users of the systems and computer programmers who implement systems. The systems analyst coordinates the efforts of all these groups to effectively develop and operate computer based information systems. Systems analysts develop information systems. For this task, they must know about concepts of systems. They must be involved in all the phases of system development life cycle.
It mainly consists of four phases: System Analysis, System Design, System Construction & Implementation and System Support. Every phase consist of inputs, tasks and outputs.

ROLE OF A SYSTEMS ANALYST
The success of an information system development is based on the role of Systems analyst. Some important roles are:
Change Agent: The analyst may be viewed as an agent of change. A candidate system is designed to introduce change and reorientation in how the user organization handles information or makes decisions. Then, it is important that the user accepts change. For user acceptance, analysts prefer user participations during design and implementation. Analyst carefully plans, monitors and implements change into the user domain because people inherently resist changes.
Investigator and Monitor: A systems analyst may investigate the existing system to find the reasons for its failure.
Architect: The analyst’s role as an architect is liaison between the user’s logical design requirements and the detailed physical system design.
Psychologist: In system development, systems are built around people. The analyst plays the role of psychologist in the way s/he reaches people, interprets their thoughts, assesses their behavior and draws conclusions from these interactions. Psychologist plays a major role during the phase of fact finding.
Motivator: System acceptance is achieved through user participation in its development, effective user training and proper motivation to use the system.
Intermediary: In implementing a candidate system, the analyst tries to appease all parties involved. Diplomacy in dealing with people can improve acceptance of the system.

7.         What is RDBMS? List out the functions of RDBMS.
Answer:
RDBMS stands for Relational Database Management System. RDBMS data is structured in database tables, fields and records. Each RDBMS table consists of database table rows. Each database table row consists of one or more database table fields. RDBMS store the data into collection of tables, which might be related by common fields (database table columns). RDBMS also provide relational operators to manipulate the data stored into the database tables. Most RDBMS use SQL as database query language.
Functions of RDBMS:
getConnectionStatus()
setCurrentConnection()
unsetConnection()
 beginTransaction()
commit()
rollback()
 insert()
update()
delete()
 queryUsingConceptProps()
queryUsingPreparedStmt()
queryUsingPrimaryKeys()
queryUsingSQL()
assertDBInstance()
 executePreparedStmt()
executeSQL()
 createQuery()
closeQuery()
getNextPage()
getNextPageFromOffset()
getPreviousPage()
getPreviousPageFromOffset()

8.         Describe “Operators” which are used in C-programming.
Answer:
In C programming, an operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C language is rich in built-in operators and provides the following types of operators:
Arithmetic Operators
Operator
Description
+
Adds two operands
-
Subtracts second operand from the first
*
Multiplies both operands
/
Divides numerator by de-numerator
%
Modulus Operator and remainder of after an integer division
++
Increments operator increases integer value by one
--
Decrements operator decreases integer value by one
Relational Operators
Operator
Description
==
Checks if the values of two operands are equal or not, if yes then condition becomes true.
!=
Checks if the values of two operands are equal or not, if values are not equal then condition becomes true.
Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.
Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.
>=
Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.
<=
Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.
Logical Operators
Operator
Description
&&
Called Logical AND operator. If both the operands are non-zero, then condition becomes true.
||
Called Logical OR Operator. If any of the two operands is non-zero, then condition becomes true.
!
Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false.
Bitwise Operators
Operator
Description
&
Binary AND Operator copies a bit to the result if it exists in both operands.
|
Binary OR Operator copies a bit if it exists in either operand.
^
Binary XOR Operator copies the bit if it is set in one operand but not both.
~
Binary Ones Complement Operator is unary and has the effect of 'flipping' bits.
<< 
Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand.
>> 
Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand.
Assignment Operators
Operator
Description
=
Simple assignment operator, Assigns values from right side operands to left side operand
+=
Add AND assignment operator, It adds right operand to the left operand and assign the result to left operand
-=
Subtract AND assignment operator, It subtracts right operand from the left operand and assign the result to left operand
*=
Multiply AND assignment operator, It multiplies right operand with the left operand and assign the result to left operand
/=
Divide AND assignment operator, It divides left operand with the right operand and assign the result to left operand
%=
Modulus AND assignment operator, It takes modulus using two operands and assign the result to left operand
<<=
Left shift AND assignment operator
>>=
Right shift AND assignment operator
&=
Bitwise AND assignment operator
^=
bitwise exclusive OR and assignment operator
|=
bitwise inclusive OR and assignment operator
Misc. Operators
Operator
Description
sizeof()
Returns the size of a variable.
&
Returns the address of a variable.
*
Pointer to a variable.
? :
Conditional Expression



9.         What is Network? List out the benefits of Network.
Answer:
A computer network is a set of computers or devices that are connected with each other to carry on data and share information. In computing, it is called a network as a way to interconnect two or more devices to each other using cables, signals, waves or other methods with the ultimate goal of transmitting data, share information, resources and services.
Benefits of Network:
           Helps to enhance connectivity:
           Networking helps in sharing of hardware:
           Eases out management of data.
           Internet
           Data Sharing
           Networking has promoted gaming.

10.       Describe the importance of OOP.
Answer:
The importance of OOP:
           Simplicity: software objects model real world objects, so the complexity is reduced and the program structure is very clear;
           Modularity: each object forms a separate entity whose internal workings are decoupled from other parts of the system;
           Modifiability: it is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods;
           Extensibility: adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones;
           Maintainability: objects can be maintained separately, making locating and fixing problems easier;
           Re-usability: objects can be reused in different programs.

11.       Describe computer crime and its various forms.
Answer:
Computer crime, or Cybercrime, refers to any crime that involves a computer and a network. The computer may have been used in the commission of a crime, or it may be the target. Net crime refers, more precisely, to criminal exploitation of the Internet. Physical presence is not essential for the cybercrime to take a place. The requirements to commit Cyber Crimes are few, compared to the possible repercussions caused and easy to get as programs and software are available on the Internet. Such crimes generate threats to the nation’s security and the personal financial health Issues surrounding this type of crime have become highprofile, particularly those surrounding cracking, copyright infringement, child pornography, and child grooming. There are also problems of privacy when confidential information is lost or intercepted, lawfully or otherwise.
Various forms are:
• Computer viruses
• Denialofservice attacks
• Malware (malicious code)
• Cyber stalking
• Fraud and identity theft
• Information warfare
• Phishing scams

12.       What is multimedia? List out the advantages of multimedia.
Answer:
Multimedia:
Multimedia is media and content that uses a combination of different content forms. The term can be used as a noun (a medium with multiple content forms) or as an adjective describing a medium as having multiple content forms. Multimedia includes a combination of text, audio, still images, animation, video, and interactivity content forms.

Advantages of multimedia:
           It is integrated and interactive. All the different mediums are integrated through the digitization process. Interactivity is heightened by the possibility of easy feedback.
           It is flexible. Being digital, this media can easily be changed to fit different situations and audiences.
           It can be used for a wide variety of audiences, ranging from one person to a whole group.
           Increases learning effectiveness.
           More appealing over traditional, lecture-based learning methods.
           Offers significant potential in improving personal communications, education and training efforts.
           Reduces training costs.
           Easy to use.
           Tailors information to the individual.
           Provides high-quality video images & audio.
           Offers system portability.
           Gathers information about the study results of the student.

13.       Describe the objectives of e-governance?
Answer:
‘EGovernment' (or Digital Government) is defined as ‘The utilization of the Internet and the worldwide web for delivering government information and services to the citizens.’ EGovernances is digital interaction between a government and citizens (G2C), government and businesses/commerce/ecommerce (G2B), and between government agencies (G2G), GovernmenttoReligious Movements/Church (G2R), GovernmenttoHouseholds (G2H). This digital interaction consists of governance, information and communication technology (ICT), business process reengineering (BPR), and ecitizen at all levels of government (city, state/province, national, and international). 'Electronic Government' essentially refers to the approach ‘How government utilized IT, ICT, and other webbased telecommunication technologies to improve and/or enhance on the efficiency and effectiveness of service delivery in the public sector.’
14.       Write Short notes on:
a.         Cyber law.
Answer:
Legal aspects of computing are related to various areas of law. Cyber law is a term that encapsulates the legal issues related to use of communicative, transactional, and distributive aspects of networked information devices and technologies. It is less a distinct field of law than property or contract law, as it is a domain covering many areas of law and regulation. Some leading topics include intellectual property, privacy, freedom of expression, and jurisdiction. Information Technology Law (or IT Law) is a set of recent legal enactments, currently in existence in several countries, which governs the process and dissemination of information digitally. These legal enactments cover a broad gamut of different aspects relating to computer software, protection of computer software, access and control of digital information, privacy, security, internet access and usage, and electronic commerce.

b.         Expert System.
Answer:
An expert system is an artificial intelligence application that uses a knowledge base of human expertise to aid in solving problems. The degree of problem solving is based on the quality of the data and rules obtained from the human expert. Expert systems are designed to perform at a human expert level. In practice, they will perform both well below and well above that of an individual expert. The expert system derives its answers by running the knowledge base through an inference engine, a software program that interacts with the user and processes the results from the rules and data in the knowledge base. Expert systems are used in applications such as medical diagnosis, equipment repair, investment analysis, financial, estate and insurance planning, route scheduling for delivery vehicles, contract bidding, counseling for self-service customers, production control and training.




 



********************************

HSEB – Grade XII (2013)
(Computer Science)
Solved Questions

Group ‘A’
Long Answer
Q1) What is control statement? Describe ‘Sequence’, ‘Selection’ and ‘Loop’ with flow chart and example.

Answer:
Control Statement: Control statements enable us to specify the flow of program control; i.e., the order in which the instructions in a program must be executed. They make it possible to make decisions, to perform tasks repeatedly or to jump from one section of code to another.  The if else Statement, switch Statement, Loops, while Loop, do while Loop, for Loop, break Statement, continue Statement and goto Statement are the examples of control statements.
There are four types of control statements in C:
·         Decision making statements

·         Selection statements

·         Iteration statements

·         Jump statements
Sequence: A sequence point defines any point in a computer program's execution at which it is guaranteed that all effects of previous evaluations will have been performed. They are often mentioned in reference to C, because the result of some expressions can depend on the order of evaluation of their sub-expressions. Adding one or more sequence points is one method of ensuring a consistent result, because this restricts the possible orders of evaluation.

Selection: selection also called a decision, one of the three basic logic structures in c programming. The other two logic structures are sequence and loop. In a selection structure, a question is asked, and depending on the answer, the program takes one of two courses of action, after which the program moves on to the next event.  

Loop: 'A loop' is a part of code of a program which is executed repeatedly. A loop is used using condition. The repetition is done until condition becomes condition true. A loop declaration and execution can be done in following ways:
  • ·         Check condition to start a loop
  • ·         Initialize loop with declaring a variable.
  • ·         Executing statements inside loop.
  • ·         Increment or decrement of value of a variable.



Q2) Write a program which reads name of 20 employees and sort them in alphabetic order.

Answer:
#include "stdio.h"
#include "string.h"
#include "conio.h"
void main()
{
      int i,j;
      char name[20][20],temp[20];
      for(i=0;i<20;i++)
      {
       printf("Enter the name of %dth person:\n",i+1);
       scanf("%s",&name[i]);
      }
      printf("\n The names in original order are:\n");
      for(i=0;i<20;i++)
      {
       printf("%d.%s\n",i+1,name[i]);
      }
      for(i=0;i<20-1;i++)
      {
            for(j=i+1;j<20;j++)
            {
                  if(strcmp(name[i],name[j])>0 )
                  {
                     strcpy(temp,name[i]);
                     strcpy(name[i],name[j]);
                     strcpy(name[j],temp);
                   }
              }
        }

      printf("\n\nThe names in alphabetical order are:\n");
      for(i=0;i<20;i++)
      {
        printf("%d.%s\n",i+1,name[i]);
      }
 getch();
 }


Q3) Differentiate between structure and union with suitable examples.

Answer:
Structure: Structure is a method of packing the data of different types. When we require using a collection of different data items of different data types in that situation we can use a structure. A structure is used as a method of handling a group of related data items of different data types.
Example:
#include "stdio.h"

#include "conio.h"

struct comp_info

{

char nm[100];

char addr[100];

}info;

void main()

{

clrscr();

printf("\n Enter Company Name : ");

gets(info.nm);

printf("\n Enter Address : ");

gets(info.addr);

printf("\n\n Company Name : %s",info.nm);

printf("\n\n Address : %s",info.addr);

getch();

}
Union: Union is user defined data type used to stored data under unique variable name at single memory location. Union is similar to that of structure. Syntax of union is similar to structure. But the major difference between structure and union is 'storage.' In structures, each member has its own storage location, whereas all the members of union use the same location. Union contains many members of different types, it can handle only one member at a time. To declare union data type, 'union' keyword is used. Union holds value for one data type which requires larger storage among their members.
Example:
#include "stdio.h"

#include "conio.h"

union techno

{

int id;

char nm[50];

}tch;

void main()

{

clrscr();

printf("\n\t Enter developer id : ");

scanf("%d", &amp;tch.id);

printf("\n\n\t Enter developer name : ");

scanf("%s", tch.nm);

printf("\n\n Developer ID : %d", tch.id);//Garbage

printf("\n\n Developed By : %s", tch.nm);

getch();

}

Q4) What is recursion? Write a program to calculate factorial value of given number using recursive function.

Answer:
Recursion is a programming technique that allows the programmer to express operations in terms of themselves. In C, this takes the form of a function that calls itself. A useful way to think of recursive functions is to imagine them as a process being performed where one of the instructions is to "repeat the process". This makes it sound very similar to a loop because it repeats the same code, and in some ways it is similar to looping. On the other hand, recursion makes it easier to express ideas in which the result of the recursive call is necessary to complete the task.
Example:
#include "stdio.h"

#include "conio.h"

int fact(int);

void main()

{

  int num,f;

  printf("\nEnter a number: ");

  scanf("%d",&num);

  f=fact(num);

  printf("\nFactorial of %d is: %d",num,f);

  }

int fact(int n)

{

   if(n==1)

       return 1;

   else

       return(n*fact(n-1));

 }

Q5) Write a program which reads name, department and age from a file named "Employee.dat" and display them.

Answer:
#include "stdio.h"

#include "conio.h"
void main()
{
  FILE *f;
  char ch;
  f=fopen("employee.txt","r");
  while( ( ch = fgetc(f) ) != EOF )
  printf("%c",ch);
  fclose(f);
  getch();
}



Group ‘B’
Short Answer Questions

Q6) What is system? Explain the basic elements of system.
Answer:
A System may be defined as orderly grouping of interdependent components linked together according to a plan to achieve a specific goal. Each component is a part of total system and it has to do its own share of work for the system to achieve the desired goal.
Purpose, Boundary, Environment, Inputs, and Outputs are some important terms related to Systems.
• A System’s purpose is the reason for its existence and the reference point for measuring its success.
• A System’s boundary defines what is inside the system and what is outside.
• A System Environment is everything pertinent to the System that is outside of its boundaries.
• A System’s Inputs are the physical objects and information that cross the boundary to enter it from its environment.
• A system’s Outputs are the physical objects and information that go from the system into its environment.

Q7) Who is system analyst? List out the roles of system analyst.
Answer:
Systems analyst who designs an information system is the same as an architect of a house. Three groups of people are involved in developing information systems for organizations. They are managers, users of the systems and computer programmers who implement systems. The systems analyst coordinates the efforts of all these groups to effectively develop and operate computer based information systems. Systems analysts develop information systems. For this task, they must know about concepts of systems. They must be involved in all the phases of system development life cycle. It mainly consists of four phases: System Analysis, System Design, System Construction &amp; Implementation and System Support. Every phase consist of inputs, tasks and outputs.
Roles of system analyst:
Change Agent: The analyst may be viewed as an agent of change.
Investigator and Monitor: A systems analyst may investigate the existing system to find the reasons for its failure.
Architect: The analyst’s role as an architect is liaison between the user’s logical design requirements and the detailed physical system design.
Psychologist: In system development, systems are built around people.
Motivator: System acceptance is achieved through user participation in its development, effective user training and proper motivation to use the system.
Intermediary: In implementing a candidate system, the analyst tries to appease all parties involved.

Q8) Differentiate between DBMS and RDBMS with examples.
Answer:
DBMS
A Database Management System (DBMS) is a set of computer programs that controls the creation, maintenance, and the use of the database in a computer platform or of an organization and its end users. A DBMS is a system software package that helps the use of integrated collection of data records and files known as databases. It allows different user application programs to easily access the same database. Example: Perl, Python, IMS etc..
RDBMS
A Relational Database Management System (RDBMS) is a Database Management System (DBMS) that is based on the relational model. RDBMS is a DBMS in which data is stored in the form of tables and the relationship among the data is also stored in the form of tables. Example: Microsoft SQL Server, Oracle, Access, DB2 etc..

Q9) Describe the data types which are used in C programming.
Answer:
Followings are the most commonly used data types in C.







Q10) Describe the types of network topologies with clear diagram.
Answer:
Network topologies are:
Bus Topology:
In local area networks where bus topology is used, each node is connected to a single cable. Each computer or server is connected to the single bus cable. A signal from the source travels in both directions to all machines connected on the bus cable until it finds the intended recipient. If the machine address does not match the intended address for the data, the machine ignores the data. Alternatively, if the data does match the machine address, the data is accepted.





Star Topology:
Star networks are one of the most common computer network topologies. In its simplest form, a star network consists of one central switch, hub or computer, which acts as a conduit to transmit messages.
This consists of a central node, to which all other nodes are connected; this central node provides a common connection point for all nodes through a hub.





Ring Topology:
A ring network is a network topology in which each node connects to exactly two other nodes, forming a single continuous pathway for signals through each node - a ring. Data travels from node to node, with each node along the way handling every packet. Because a ring topology provides only one pathway between any two nodes, ring networks may be disrupted by the failure of a single link. A node failure or cable break might isolate every node attached to the ring.





Tree Topology:
The type of network topology in which a central 'root' node (the top level of the hierarchy) is connected to one or more other nodes that are one level lower in the hierarchy (i.e., the second level) with a point-to-point link between each of the second level nodes and the top level central 'root' node, while each of the second level nodes that are connected to the top level central 'root' node will also have one or more other nodes that are one level lower in the hierarchy (i.e., the third level) connected to it, also with a point-to-point link, the top level central 'root' node being the only node that has no other node above it in the hierarchy (The hierarchy of the tree is symmetrical.) Each node in the network having a specific fixed number, of nodes connected to it at the next lower level in the hierarchy, the number, being referred to as the 'branching factor' of the hierarchical tree. This tree has individual peripheral nodes.






Mesh topology:
Mesh networking (topology) is a type of networking where each node must not only capture and disseminate its own data, but also serve as a relay for other nodes, that is, it must collaborate to propagate the data in the network. A mesh network can be designed using a flooding technique or a routing technique. When using a routing technique, the message is propagated along a path, by hopping from node to node until the destination is reached. To ensure all its paths' availability, a routing network must allow for continuous connections and reconfiguration around broken or blocked paths, using self-healing algorithms. A mesh network whose nodes are all connected to each other is a fully connected network. Mesh networks can be seen as one type of ad hoc network.




Q11) Explain polymorphism and inheritance with example.
Answer:
Polymorphism:
Polymorphism – means the ability of a single variable of a given type to be used to reference objects of different types, and automatically call the method that is specific to the type of object the variable references. In a nutshell, polymorphism is a bottom-up method call. The benefit of polymorphism is that it is very easy to add new classes of derived objects without breaking the calling code that uses the polymorphic classes or interfaces.

Inheritance:
Inheritance – is the inclusion of behavior (i.e. methods) and state (i.e. variables) of a base class in a derived class so that they are accessible in that derived class. The key benefit of Inheritance is that it provides the formal mechanism for code reuse. Any shared piece of business logic can be moved from the derived class into the base class as part of refactoring process to improve maintainability of your code by avoiding code duplication. The existing class is called the super class and the derived class is called the subclass. Inheritance can also be defined as the process whereby one object acquires characteristics from one or more other objects the same way children acquire characteristics from their parents.
Example:
#include "iostream.h" 
class   vehicle
{
int    wheels;
float  weight;
public:
void  message(void) 
{
cout<<"Vehicle message, from vehicle, the base class\n";
}
};
class  car : public  vehicle
{
int   passenger_load;
public:
void   message(void)    // second message()
{
cout<<"Car message, from car, the vehicle derived class\n";
}
};
class  truck : public  vehicle
{
int  passenger_load;
float   payload;
public:
int  passengers(void)
{
return  passenger_load;
}
};
class  boat : public  vehicle
{
int  passenger_load;
public:
int  passengers(void) {return  passenger_load;}
void  message(void)     // third message()
{
cout<<"Boat message, from boat, the vehicle derived class\n";
}
};
int  main()
{
vehicle  unicycle;
car      sedan_car;
truck    trailer;
 boat     sailboat;
unicycle.message();
sedan_car.message();
trailer.message();
sailboat.message();
// base and derived object assignment
unicycle = sedan_car;     
unicycle.message();
return 0;
}

Q12) Describe computer crime and its various forms.
Answer:
Computer crimes:
Computer crime, or Cyber crime, refers to any crime that involves a computer and a network. The computer may have been used in the commission of a crime, or it may be the target. Net crime refers, more precisely, to criminal exploitation of the Internet. Physical presence is not essential for the cyber-crime to take a place. The requirements to commit Cyber Crimes are few, compared to the possible repercussions caused and easy to get as programs and software are available on the Internet. Such crimes generate threats to the nation’s security and the personal financial health Issues surrounding this type of crime have become high‐profile, particularly those surrounding cracking, copyright infringement, child pornography, and child grooming. There are also problems of privacy when confidential information is lost or intercepted, lawfully or otherwise.
Forms of Cyber Crime
  •          Cyber Crime has various forms which may include
  •          hacking (illegal intrusion into a computer system without the permission of owner),
  •          phishing (pulling out the confidential information from the bank or financial institutional account holders by deceptive means),
  •          spoofing (getting one computer on a network to pretend to have the identity of another computer in order to gain access to the network),
  •          cyber stalking (following the victim by sending e-mails or entering the chat rooms frequently),
  •          cyber defamation (sending e-mails to all concerned or posting on websites, the text containing defamatory matters about the victim),
  •          threatening (sending threatening e-mails to victim),
  •          salami attacks (making insignificant changes which go unnoticed by the victim),
  •          net extortion,
  •          pornography (transmitting lascivious material),
  •          software piracy (illegal copying of the genuine software), email bombing,
  •          virus dissemination (sending malicious software which attaches itself to other software),
  •          IPR theft, identity theft, data theft, etc.

Q13) List out the advantages and disadvantages of multimedia.
Answer:
Advantages of multimedia:
  •   Increases learning effectiveness.
  •   Is more appealing over traditional, lecture-based learning methods.
  •   Offers significant potential in improving personal communications, education and training efforts.
  •   Reduces training costs.
  •   Is easy to use.
  •   Tailors information to the individual.
  •   Provides high-quality video images &amp; audio.
  •   Offers system portability.
  •   Frees the teacher from routine tasks.
  •   Gathers information about the study results of the student.

Disadvantages of multimedia:
  •   Expensive
  •   Not always easy to configure
  •   Requires special hardware
  •   Not always compatible

Q14) What are the objectives of e-governance? Explain.
Answer:
E-Governance implies technology driven governance. E-Governance is the application of Information and Communication Technology (ICT) for delivering government services, exchange of information communication transactions, integration of various stand-alone systems and services between Government-to-Citizens, Government-to-Business, Government-to-Government as well as back office processes and interactions within the entire government frame work. Through the e-Governance, the government services will be made available to the citizens in a convenient, efficient and transparent manner. The three main target groups that can be distinguished in governance concepts are Government, citizens and businesses/interest groups. In e-Governance there are no distinct boundaries. Generally four basic models are available: Government to Customer (Citizen), Government to Employees, Government to Government and Government to Business.

Q15) Write short notes on:
a)      Normalization
Answer:
Database normalization is the process of organizing the fields and tables of a relational database to minimize redundancy and dependency. Normalization usually involves dividing large tables into smaller (and less redundant) tables and defining relationships between them. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database using the defined relationships.
b)      Expert system
Answer:
In artificial intelligence, an expert system is a computer system that emulates the decision-making ability of a human expert. Expert systems are designed to solve complex problems by reasoning about knowledge, like an expert, and not by following the procedure of a developer as is the case in conventional programming. An expert system has a unique structure, different from traditional computer programming. It is divided into two parts, one fixed, independent of the expert system: the inference engine, and one variable: the knowledge base. To run an expert system, the engine reasons about the knowledge base like a human.


***Thank you*** 



Computer science, Number Systems, Boolean Algebra,QBASIC, C tutorial, SQL Tutorial, HTML 5 tutorial

Follow by Email