-->

HISSAN 2072 computer science questions and solutions

 

HISSAN CENTRAL EXAMINATION – 2072 (2016)

COMPUTER SCEINCE [230-M2]

Time: 3 hrs                                                                                       Full  Marks : 75

                                                                                                      Pass Marks: 27

 

Group “A”

                                        

                                                    Long Answer questions 4x10=40

Attempts any Four questions:
1.Describe any five string handling functions with examples.10

Ans:-

1.strcat():-


The strcat() function is used to join or concatenate one string into another string.

Syntax:

strcat(strl,str2);

where str1,str2 are two strings. The content of string str2 is concatenated with string str1.

#include <stdio.h>

#include<string.h>

int main()

{

char str1[100],str2[100];

printf("Enter two strings = ");

scanf("%s%s",str1,str2);

strcat(str1,str2);

printf("After copying the string is %s ", str1);

return 0;

}

2.strcpy();- 
We use this function to copy one string to another. while copying, one replaces another.
Syntax:-
strcpy(string1,string2);
or strcpy(destination,source);

When we copy string, this is done from source to destination (string2 to string1). If first is empty then there would not be over-writing.

Example;
#include<stdio.h>
#include<string.h>
void main()
{
char string1[100]="APPLE";
char string2[100]="grapes";
printf("copied string =%s",strcpy(string1,string2));
}

output-
We get here string1=grapes. Because 'grapes' is copied to firs string named "APPLE". We can also write in reverse order.
3.strcmp():-

The strcmp() function is used to compare two strings, character by character and stops comparison when there is a difference in the ASCII value or the end of any one string and returns ASCII difference of the character that is integer.
Syntax:

v=strcmp(strl,str2);

Where, str1 and str2 are two strings to be compared and v is a value returned by the function which is either zero(equal), positive value(descending) or negative value(ascending).

#include <stdio.h>

#include<string.h>

int main()

{

char str1[50],str2[50];

printf("Enter two strings : ");

scanf("%s%s",str1,str2);

int v=strcmp(str1,str2);

if(v==0)

printf("Both strings are same and have same ASCII value");

else if(v>0)

printf("%s comes after %s or %s has more ASCII value than %s",str1,str2,str1,str2);

else

printf("%s comes before %s or %s has more ASCII value than %s",str2,str1,str2,str1);

return 0;

}



4.strlen():-
strlen(string);-It is used to get length of given string.

 syntax:
identifer=strlen(string);
For example,
#include<stdio.h>
#include<string.h>
void main()
{
char string[100]="apple";
int k;
k=strlen(string);
printf("length=%d",k);
}
It returns 5. It also counts white spaces present in a string.
If we want want , we can also input string using scanf() or gets().
 
5.strrev():-

 It reverses the string given by us.

syntax:- strrev(string);
example:

#include<stdio.h>
#include<string.h>
void main()
{
char string[100]="apple";
printf("reverseed string=%s",strrev(string));
}


2.a) Differentiate between while and do while loop with examples.5

Ans:-

Differences between while and do..while loop are given below.


while loop

do while loop

In the while loop, condition is checked in the beginning.

In the do while loop, condition is checked at the end.

It is also known as a pre-test or entry control loop.

It is also known as post-test or exit control loop.

It is not terminated with a semicolon.

It is terminated with a semicolon.

In the while loop, statements are not executed if the condition is false.

In the do while loop, statements are executed once even the condition is false.

It uses the keyword ‘while’.

It uses two keywords ‘do’ and ‘while’.

The syntax of while loop is as follows:

initialization;

while(condition)

{

  statements;

  increment/decrement;

}

The syntax of do-while loop is as follows:

initialization;

do

 {

  statements;

  increment/decrement;

 }while(condition);

The operation of while loop can be represented using flowchart as follows:



The operation of do while loop can be represented using flowchart as follows:



Example:
#include<stdio.h>

int main()

{

    int i=1;

    while(i>=10)

    {

        printf("I love my country");

        i++;

    }

    return 0;

}

Output: This program displays nothing as output; as condition is evaluated false in the beginning.

Example:

#include<stdio.h>

int main()

{

    int i=1;

    do

    {

        printf("I love my country");

        i++;

    }while(i>=10);

    return 0;

}

Output: This program displays “I love my country as output at once.



b) WAP to check whether the given number is positive or negative.5

Ans:-

/* a program to know a number is positive or negative */

#include<stdio.h>

int main()

{

    int number;

    printf("enter a number\n");

    scanf("%d",&number);

    if(number>0)

    {

            printf("%d is positive",number);

    }

else if(number<0)

    {

        printf("%d is negative",number);

    }

else

    {

          printf("%d is zero",number);

    }

return 0;

}

3.WAP to ask Nth terms of numbers and sort them in ascending order.10

Ans:-

//program to sort 'n' elements in ascending order
  #include<stdio.h>
  #include<conio.h>
  void main()
  {
  clrscr();
  int arr[200];    
  int size;     
  int i,j,k;      
 printf("enter size of elements \n");
  scanf("%d",&size); 
printf("enter array's elements\n");                 
  for(i=0;i<size;i++)
   {                            
     printf("enter elements for location=%d\n",i);
     scanf("%d",&arr[i]);      
   }
   printf("elements' sorting process started\n");
   for(i=0;i<size;i++)
   {
       for(j=i+1;j<size;j++)
        {
           if(arr[i]>arr[j])
             {
                 k=arr[i];
                 arr[i]=arr[j];
                arr[j]=k;
             }
       }
}
printf("in ascending order,elements are\n");
for(i=0;i<size;i++)
   {                            
     printf("%d\n",arr[i]);      
   }
getch();
}
4.a) Differentiate between structure and union.5

Ans:-

The differences between struct and union are given below in tabular form.
                   

struct
Union
1.It stores dis-similar data.Each gets separate space in memory.They do not share memory
1. It stores dis-similar type of data.Total memory space is equal to the member with largest size.They share memory space.
2.we can access member in any sequence .
2.We can access that whose value is recently used.
3.It uses keyword 'struct'
3.It uses keyword 'union'
4.We can initialize values of member/s and in any order
4.We can initialize that member which is first declared.
5.It consumes more memory
5.It consumes less memory.
6.Its syntax
    struct tag
{
datatype member1;
datatype member2;
datatype member3;
}variable;

6.Its syntax
    union tag
{
datatype member1;
datatype member2;
datatype member3;
}variable;

Example
struct student
{
int roll;
char sex;
float percentage;
}var;

Example
union student
{
int roll;
char sex;
float percentage;
}var;


b) WAP to find factorial of a given number.5
Ans:-

//program to get factorial value of a positive number
#include<stdio.h>
include<conio.h>
void main()
{
int number,fact=1,i;
printf("enter any positive number\n");
scanf("%d",&number);
if(number>0)
{
for(i=1;i<=number;i++)
{
fact=fact*i;
}
}
else
{
printf("the number is not +ve\n");
}
printf("the factorial value for entered number=%d is =%d\n",number,fact);
getch();
}

5.
a) Describe fscanf and fprintf function.5

Ans:-
fscanf():-
The fscanf() function is used to read set of characters from file. It reads a word from the file and returns EOF at the end of file.
syntax:-
int fprintf(FILE *stream, const char *format [, argument, ...])
For example:-
fscanf(k,"%s%d",name,roll);
It reads data from a datafile pointed by file pointer k .name and roll are variables.
.fprintf():
The fprintf() function is used to write set of characters into file. It sends formatted output to a stream.
syntax:-int fprintf(FILE *stream, const char *format [, argument, ...])
For example:-
fprintf(k,"%s%d","Ram kumar",12);
It writes data to a file created by file pointer k
b) WAP which asks name, age and gender of student and write it in a file “student.dat”.5
Ans
:-
/* program which asks name, age and gender of student and write it in a file “student.dat”
*/
#include<stdio.h>
int main()
{
FILE *p;
char name[100];
char gender[100];
float age;
printf("enter name ,age and gender\n press ctrl+z to exit\n");
p=fopen("student.dat","w");
while((fscanf(p,"%s%f%s",name,&age,gender))!=EOF)
{
fprintf(p,"%s %f %s\n",name,age,gender);
}
fclose(p);
return 0;
}



 


Group “B”

                                          Short Answer questions                                                7x5=35



Attempts any Seven questions:

6.Describe different types of feasibility.5
Ans:-
feasibility study:
 It is the measure and the study of how beneficial the development of the system would be to the organization. This is known as feasibility study. The aim of the feasibility study is to understand the problem and to determine whether it is worth proceeding.

Components of feasibility study:-


1.Technical feasibility: - This is concerned with availability of hardware and software required for the development of system.The issues with can be like:
1.1) Is the proposed technology proven and practical?
1.2)the next question is: does the firm possess the necessary technology it needs. Here we have to ensure that the required technology is practical and available. Now, does it have required hardware and software?
1.3)The Last issue is related to availability of technical expertise. In this case, software and hardware are available but it may be difficult to find skilled manpower.
2.Operational feasibility:- It is all about problems that may arise during operations. There are two aspects related with this issue:
2.1) what is the probability that the solution developed may not be put to use or may not work?
                                   2.1) what is the inclination of management and end users towards solutions?
Besides these all some more issues;
                                                           a) Information: saying to provide adequate, timely, accurate and useful information to all categories of users.
                                                       b) Response time, it says about response about output in very fast time to users.
                                            c) Accuracy: A software system must operate accurately. It means, it should provide value to its users. It says degree of software performance.
           d) Services:- The system should be able to provide reliable services.
             e)Security:- there should be adequate security to information and data from frauds.
f) Efficiency: The system needs to be able to provide desirable services to users.
3) 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 problem is worthwhile or not. Under "cost benefit analysis", there are mainly two types of costs namely, cost of human resources and cost of training.
                                                             The first one says about salaries of system analysts, software engineers, programmers, data entry operators etc. whereas 2nd one says about training to be given to new staffs about how to operate a newly arrived system.

4) Legal feasibility: - It is the study about issues arising out the need to the development of the system. The possible consideration might include copyright law, labor law, antitrust legislation, foreign trade etc.
Apart from these all we have some more types:
behaviour feasibility, schedule feasibility study etc.

7.Define DBMS. List out the objectives of DBMS.1+4
Ans:-

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. DBMSs may use any of a variety of database models, such as the network model or relational model. In large systems, a DBMS allows users and other software to store and retrieve data in a structured way. Instead of having to write computer programs to extract information, user can ask simple questions in a query language. 

              Its roles/objectives can be listed as given below.

1. provides an interface to the user as well as to application

2. lets user to create,maintain databases.

3. provides high integrity and security to its data.

4. provides sharing facility to many users.

5. provides relationships between tables.

6. provides access level to different users.

7. maintains integrity,consistency of data e


8.What is relational database model? List the advantages of relational database model.1+4
Ans:-

Three key terms are used extensively in relational database models: relations, attributes, and domains. A relation is a table with columns and rows. The named columns of the relation are called attributes, and the domain is the set of values the attributes are allowed to take.

The basic data structure of the relational model is the table, where information about a particular entity is represented in columns and rows. Thus, the "relation" in "relational database" refers to the various tables in the database; a relation is a set of tuples.So,


Relational databases

  • Data is organized into two-dimensional tables, or relations

  • Each row is a tuple (record) and each column is an attribute (field)

  • A common field appears in more than one table and is used to establish relationships

  • Because of its power and flexibility, the relational database model is the predominant design approach


name

street

city

id no.

balance

RAm

Thapagaun

KTm

00321

Rs. 900087

ekan

BAneshwor

Pokhara

008

Rs.45666

Hary

Kalanki

Ktm

9870

Rs. 65799

Sam

Koteshwor

Ktm

7890

Rs. 5600

Kale

Kalnki

Ktm

456

Rs. 65400


In this table we have used different concept like field (each column),record (each row). Each row gives us a complete information. If we have many tables then we relate them for data extractions,this is called relationship between tables.Apart from these, we also use other concept like,primary key,foreign key,Entity etc.

Advantages:

1.Faster

2.Multiuser

3.High accuracy

4.more Simple


9.Define the terms DDL and SQL.5
Ans:-
DDL:

This is the means by which the content & format data to be stored is described & structure of database is defined, including relationship between records & indexing strategies. This definition of database is known as schema.

 DDL is essentially link between logical & physical views of database. Here logical refers to the way the users view the data, physical refers to the way the data are physically stored. The logical structure of database sometimes is known as schema.

Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples:

  • CREATE - to create objects in the database

  • ALTER - alters the structure of the database

  • DROP - delete objects from the database

  • TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed

Example:-
CREATE TABLE Persons (
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
SQL:-
SQL stands for  Structured Query Language; it is the most common language for extracting and organising data that is stored in a relational database. A database is a table that consists of rows and columns. SQL is the language of databases. It facilitates retrieving specific information from databases that are further used for analysis. Even when the analysis is being done on another platform like Python or R, SQL would be needed to extract the data that you need from a company’s database.
It is used for:
  • Execute queries against a database
  • Retrieve data from a database
  • Insert records into a database
  • Update records in a database
  • Delete records from a database

10.What is computer network? Write its advantages.1+4
Ans:-

computer network, often simply referred to as a network, is a collection of computers and devices connected by communications channels that facilitates communications among users and allows users to share resources with other users. Networks may be classified according to a wide variety of characteristics. 

Purpose of networking:-

  • Networking for communication medium (have communication among people;internal or external)

  • Resource sharing (files, printers, hard drives, cd-rom/) 

  • Higher reliability ( to support a computer by another if that computer is down)

  • Higher flexibility( different system can be connected without any problems)

Uses cum advantages:-

  1. Sharing devices such as printers saves money.
  2. Site (software) licences are likely to be cheaper than buying several standalone licences.
  3. Files can easily be shared between users.
  4. Network users can communicate by email and instant messenger.
  5. Security is good - users cannot see other users' files unlike on stand-alone machines.
  6. Data is easy to backup as all the data is stored on the file server.
11.Describe any two network topology with diagram.2.5+2.5
Ans:-
Bus topology:
A linear bus topology consists of a main run of cable with a terminator at each end (See fig. 1). All nodes (file server, workstations, and peripherals) are connected to the linear cable.

Fig. 1. Linear Bus topology

Advantages of a Linear Bus Topology

  • Installation is easy and cheap to connect a computer or peripheral to a linear bus.
  • Requires less cable length than a star topology.

Disadvantages of a Linear Bus Topology

  • Entire network shuts down if there is a break in the main cable.
  • Difficult to identify the problem if the entire network shuts down.
  • Not meant to be used as a stand-alone solution in a large building.
star topology:
A star topology is designed with each node (file server, workstations, and peripherals) connected directly to a central network hub, switch, or concentrator (See fig. 2).
Data on a star network passes through the hub, switch, or concentrator before continuing to its destination. The hub, switch, or concentrator manages and controls all functions of the network.
 It also acts as a repeater for the data flow. This configuration is common with twisted pair cable; however, it can also be used with coaxial cable or fiber optic cable.



                Fig. 2. Star topology

Advantages of a Star Topology

  • Easy to install and wire.

  • No disruptions to the network when connecting or removing devices.

  • Easy to detect faults and to remove parts.

Disadvantages of a Star Topology

  • Requires more cable length than a linear topology.

  • If the hub, switch, or concentrator fails, nodes attached are disabled.


12.What is OOP? List the characteristics of OOP.1+4
Ans:-
As the name suggests, Object-Oriented Programming or OOPs refers to languages that uses objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism etc in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.
Some its important chaarcteristics are:


  • Abstraction: 
  • Objects: 
  • Class: 
  • Encapsulation: 
  • Information hiding: 
  • Inheritance: I
  • Interface: 
  • Polymorphism: 
  • Procedures are sections of programs tasked with specific jobs.
  • Since it has these features so it is widely used and popular among the developers. and we can not find these features in POP platforms.

    13.Describe application of AI.5
    Ans:-
    Artificial intelligence is where machines can learn and make decisions similarly to humans. There are many types of artificial intelligence including machine learning, where instead of being programmed what to think, machines can observe, analyse and learn from data and mistakes just like our human brains can. This technology is influencing consumer products and has led to significant breakthroughs in healthcare and physics as well as altered industries as diverse as manufacturing, finance and retail.
    Uses:-We can use AI in following fields.

    game playing
    You can buy machines that can play master level chess for a few hundred dollars. There is some AI in them, but they play well against people mainly through brute force computation--looking at hundreds of thousands of positions. To beat a world champion by brute force and known reliable heuristics requires being able to look at 200 million positions per second.
    speech recognition
    In the 1990s, computer speech recognition reached a practical level for limited purposes. Thus United Airlines has replaced its keyboard tree for flight information by a system using speech recognition of flight numbers and city names. It is quite convenient. On the the other hand, while it is possible to instruct some computers using speech, most users have gone back to the keyboard and the mouse as still more convenient.
    understanding natural language
    Just getting a sequence of words into a computer is not enough. Parsing sentences is not enough either. The computer has to be provided with an understanding of the domain the text is about, and this is presently possible only for very limited domains.
    computer vision
    The world is composed of three-dimensional objects, but the inputs to the human eye and computers' TV cameras are two dimensional. Some useful programs can work solely in two dimensions, but full computer vision requires partial three-dimensional information that is not just a set of two-dimensional views. At present there are only limited ways of representing three-dimensional information directly, and they are not as good as what humans evidently use

    14.List out the components of multimedia and explain any one.5
    Ans:-
    Multimedia:-
    Multimedia is content that uses a combination of different content forms such as text, audio, images, animations, video and interactive content. Multimedia contrasts with media that use only rudimentary computer displays such as text-only or traditional forms of printed or hand-produced material.
    Components:-
    1)Text: .

    2)Audio:
    i) Quick Time
    ii) Real player
    iii) Windows Media Player

    3)Graphics: 

    4)Video: 
    i) Quick Time
    ii) Window Media Player
    iii) Real Player

    5)Animation: 
    Let's understand about graphics:
    Graphics: Every multimedia presentation is based on graphics. The used of graphics in multimedia makes the concept more effective and presentable.the commonly used software for viewing graphics are windows Picture, Internet Explorer etc. The commonly used graphics editing software is Adobe Photoshop through which graphics can be edited easily and can be make effective and attractive.


    15.Write short notes on :2.5+2.5

    a) Inheritance b) E-learning
    Ans:-
    Inheritance:-
    Inheritance
    Inheritance is mainly used for code reusability.In the real world there are many objects that can be specialized. In OOP, a parent class can inherit its behavior and state to children classes. Inheritance means using the Predefined Code. This is very main feature of OOP, with the advantage of Inheritance we can use any code that is previously created. This concept was developed to manage generalization and specialization in OOP.  Lets say we have a class called Car and Racing Car . Then the attributes like engine no. , color of the Class car can be inherited by the class Racing Car . The class Car will be Parent class , and the class Racing Car will be the derived class or child class
    The following OO terms are commonly used names given to parent and child classes in OOP:
    Superclass: Parent class.
    Subclass: Child class.
    Base class: Parent class.
    Derived class: Child class
    It can have many types.
    single inheritance:-one derived class inherits property from one base class
    multiple              “  :- one derived class inherits property from many base classes.
    multi level          “ :-in this many derived classes are inherited from many base classes
    hierarchical       “ :-under this many derived classes can be inherited from single base class
    hybrid                 “:-it’s a combination of hierarchical and multilevel.

    E-learning:-

    A learning system based on formalised teaching but with the help of electronic resources is known as E-learning. While teaching can be based in or out of the classrooms, the use of computers and the Internet forms the major component of E-learning. E-learning can also be termed as a network enabled transfer of skills and knowledge, and the delivery of education is made to a large number of recipients at the same or different times. Earlier, it was not accepted wholeheartedly as it was assumed that this system lacked the human element required in learning.


    1 comment:

    1. Wynn Las Vegas - Restaurants Near Wynn Las Vegas
      Wynn Las 바카라 롤링 Vegas · Wynn Tower Suite Salon 우리 카지노 계열사 · Encore Tower Suite King 카지노 사이트 쿠폰 · 우리 카지노 계열사 Encore Tower Suite Salon · Encore Tower Suite 샌즈 카지노 Salon · Encore Tower Suite King · Encore

      ReplyDelete