-->

NEB year 2077 computer science questions and solutions

 NEB 2077 computer science questions and solutions

------------------------------------------------------------

Questions:

Subject:computer science

Time:1:30hrs

Full marks:30

                                                                          Group-A(2x7.5=15)

Attempt any two questions.

q1.Define array.WRite a program to sort ten integer numbers in ascending order and print them.[2+5.5]


q2.Explain function with example.Write a program to demonstrate any two string functions in C.[2+5.5]

q3.

     a)Describe pointer with example.[4]

     b)Explain while loop with example.[3.5]

                                                                      Group-B(3x5=15)

Attempt any three questions.

q4.Describe 1N,2N and 3N normalization concept to database design.[5]

q5.compare star and ring topology.[5]

q6.What is variable?List the major data types used in C program.[2+3]

q7.What is A.I.Describe the applications of AI.

--------------------------------------------------------------------------------

Answers:-


   Group-A(2x7.5=15)

Attempt any two questions.

q1.Define array.WRite a program to sort ten integer numbers in ascending order and print them.[2+5.5]

Ans:-

Array:-

An array is a collection of similar types of data items treated as a single unit. It acts to store related data under the same name with an index, also known as a subscript which helps to access individual array elements. Array data type may be int, float, char etc, depending upon the nature of problems.

Features:

  • It is easier for handling similar types of data in a program.
  • It is efficient for solving problems like sorting, searching, indexing etc.
  • It is very close to matrix, therefore it is easy for solving matrix related problems.
  • Graphic is an array of pixels, so graphics manipulation can be easily done using an array.
It can be two types:one dimensional and multi dimensional

example:

one dimensional:-int a[10]

multi dimensional:int a[2][2]

second part:



/* program to sort ten integer numbers in ascending order and print them.

*/

#include <stdio.h>

int main()

{

int numbers[100];

int n,i,j,k;

printf("enter the size of n\n");

scanf("%d",&n);

printf("Enter numbers\n");

for(i=0;i<n;i++)

{

scanf("%d",&numbers[i]);

}

for(i=0;i<n;i++)

{

for(j=i+1;j<n;j++)

{

if(numbers[i]>numbers[j])

{

k=numbers[i];

numbers[i]=numbers[j];

numbers[j]=k;

}

}

}

printf("numbers in ascending order are=:\n");

for(i=0;i<n;i++)

{

printf("%d\n",numbers[i]);

}

return 0;

}

q2.Explain function with example.Write a program to demonstrate any two string functions in C.[2+5.5]

Ans:-

Function:-

Function:-
Definition: A self –contained block of code that performs a particular task is called Function.
A function has 4 elements.

1. Function Declaration (Function Prototype)

2. Function Call

3. Function Definition
4.Returning some value
Features of function:
1.fast development
2.can be developed in team
3.More flxibility
4.Fast fault finding
5.Top-down approach to solve the problem

For example,
int sum(int,int);
int main()
{
  sum(2,3);
  return 0;
}
int sum(int a,int b)
{
 return a+b;
}
Here,
int sum(int,int); is called prototype.It contains two parameters.
sum(2,3) is called calling of function.
In sum(2,3), 2 and 3 are called real arguments.
int sum(int a,int b)
{
 return a+b;
}
is called body part of function.

second part:
/*program to demonstrate two string functions in C*/
#include<stdio.h>
#include<string.h>
void main()
{
char string[100]="apple";
int k;
k=strlen(string);
printf("length=%d",k);
printf("reverse of string is=%s",strrev(string));
}
Here we have used two string functions strlen()-it is used to find length;strrev()-it is used to find reverse of a string.
the output is:
length=5
reverse is=elppa

q3.

     a)Describe pointer with example.[4]

Ans:-

Pointer:-

A pointer is a variable that stores a memory address.  Pointers are used to store the addresses of other variables or memory items.  Pointers are very useful for another type of parameter passing, usually referred to as Pass By Address.  Pointers are essential for dynamic memory allocation.

Features:

1.It handles memory effectively.

2.Useful in file handling

3.Reduces spaces.

4.REduces execution time.

Example:

 

#include<stdio.h>

int main()

{

int *k;

int m=90;

k=&m;

printf("address=%d",k);

printf("value=%d",*k);

return 0;

}
here , k is a pointer and will store address of a variable m. It is then printed using printf(). To print its value we have to use  indirection operator.

     b)Explain while loop with example.[3.5]

Ans:-Let's understand while loop with the help of following points.

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

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

It is not terminated with a semicolon.

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

It uses the keyword ‘while’.

The syntax of while loop is as follows:

initialization;

while(condition)

{

  statements;

  increment/decrement;

}

The operation of 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.

                                                                      Group-B(3x5=15)

Attempt any three questions.

q4.Describe 1N,2N and 3N normalization concept to database design.[5]

Ans:-

Normalization:-

In the field of relational database design, normalization is a systematic way of ensuring that a database structure is suitable for general-purpose querying and free of certain undesirable characteristics—insertion, update, and deletion anomalies that could lead to a loss of integrity.

1 NF:

        

A TABLE IS SAID TO BE IN 1n IF there is not repeating groups or information in a table..Here, repeating group means a set of columns that stores similar information that repeats in the same table.

Let’s consider following SQL commands.

Create table contacts

(

Contact Id               Integer                    not null,

L_name                  varchar(20)            not null,

F_name                  varchar(20)           

Contact_date1      date,

Contact_desc1      varchar(50),

Contact_date2      date,

Contact_desc2      varchar(50),

);

We can see here in this table that there is a repeating group of date and description.

Now to convert into 1 N, we have to make a new table and shift that repeating group into new table.

Like,

Create table contacts

(

Contact_ID integer        not null,

L_name      varchar(20) not null,

F_name      varchar(20)

);

 

Create table conversation

(

Contact_id integer        not null,

Contact_date date,

Contact_desc        varchar(50)

);


2N:

A table is said to be in 2 N if it is in 1N and there is no redundant data in table i.e. if a value of column is dependent on one column(primary key only) but not another.

For example:

Create table employee

(

Emp_no     integer        not null,

L-name       varchar(20) not null,

F_name      varchar(20),

Dept_code integer,

Description varchar(50),

);

This table contains redundant data i.e. the value of column(field) “description” depends on dept_code but does not depend on primary key “emp_no”.So let’s make a new table and shift them into that.

Create table employee

(

Emp_no     integer        not null,

L_name      varchar(20) not null,

F_name      varchar(20),

Dept_code integer,

);

 

Create table department

(

Dept_code integer        not null,

Description varchar(50) not null,

);

We got two tables named employee and department with fields. Both the tables are related by primary key called dept_code. Now there is no redundancy and table is in 2N.


3N:-

An entity is said to be in the third normal form when,

1) It satisfies the criteria to be in the second normal form.

2) There exists no transitive functional dependency. (Transitive functional dependency can be best explained with the relationship link between three tables. If table A is functionally dependent on B, and B is functionally dependent on C then C is transitively dependent on A and B).

Example:

Consider a table that shows the database of a bookstore. The table consists of details on Book id, Genre id, Book Genre and Price. The database is maintained to keep a record of all the books that are available or will be available in the bookstore. The table of data is given below.

Book id

Genre id

Book genre

price

121

2

fiction

150

233

3

travel

100

432

4

sports

120

123

2

fiction

185

424

3

travel

140

The data in the table provides us with an idea of the books offered in the store. Also, we can deduce that BOOK id determines the GENRE id and the GENRE id determines the BOOK GENRE. Hence we can see that a transitive functional dependency has developed which makes certain that the table does not satisfy the third normal form.

Book id

Genre id

price

121

2

150

233

3

100

432

4

120

123

2

185

424

3

140


                                                                           table book

Genre id

Book genre

2

fiction

3

travel

4

sports


                                                                           table genre

After splitting the tables and regrouping the redundant content, we obtain two tables where all non-key attributes are fully functional dependent only on the primary key.

When all the column in a table describe and depend upon the primary key,the table is 3N.

q5.compare star and ring topology.[5]

Ans:-

With the help of following paragraphs, we can understand about ring and star topology.

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.


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.


Advantages of Ring topology:

  • Reduced chances of data collision as each node release a data packet after receiving the token.
  • Token passing makes ring topology perform better than bus topology under heavy traffic.
  • No need of server to control connectivity among the nodes.10. Describe the wireless network system. List out deices and equipment necessary for Wi-Fi network. 3+2
disadvantages:-
1.It is difficult to find the problem.
2.To add extra noe or computer, we have to di-assemble entire networks.
3.It is expensive
4.Shutting down of one node leads entire networking to be down.

q6.What is variable?List the major data types used in C program.[2+3]

Ans:-

Variable:-

A variable is a value that can change any time. It is a memory location used to store a data value. A variable name should be carefully chosen by the programmer so that its use is reflected in a useful way in the entire program. Any variable declared in a program should confirm to the following:

They must always begin with a letter, although some systems permit underscore as the first character.

  • White space is not allowed.
  • A variable name should not be a keyword.
  • It should not contain any special characters.

Examples of invalid variable names are:

123 (area) 6th % abc
And valid variables are:int a1,int a_1 etc
Data types:-
C language provides us the way to hold any type of data in it. It is called data type. In C language data types classified into two categories:-
1.Primary data type
2.secondary data type
Major data types  used in C:-Mostly we use primary data types.they are
int,float,double,char

Integers:- An integer can be a whole number but not a fractional number. It can accept any + ve or –ve number.  It is very common type of data used by computer. When we add/subtract/divide/multiply, we get integer but if output is in fractional, the system just truncates that decimal part and returns only integer part. Like 1+2 yields 3. 3 divided by 2 yields 1. For this data type in some language, we use some suffix like % or word like ‘int’.

                  

Floating part:- If we are going to write a program which includes some like fraction type of data then we use this data type. Like, 1.23, -.34.45 etc. the computers recognize the real numbers having fractions easily and processes accordingly. For float type of data, we use some words like ‘float’ and some where suffix like ! or #.

                            

                        

Character type:- Simply a letter or a number or space or any other symbol which we use in program is called character. A single character is placed in a single quote like ‘a’ or ‘,’ or ‘1’ etc. but, if we combine many characters then we put inside double quote like “computer”, it has 8 characters. For this type, we use reserved word like ‘char’ in C and some where it is not needed.

                            

                       String type: A data type which contains many characters together and mostly put inside double quote (in most language) is called string. Like “computing” or “education” etc. for this, we use reserved word char with some index value. In C, we can write char name[20];. Here name is a string type of data and holds up to 20 characters.


Double:-  
This data type is used for exponential values and for more accuracy of digits.It's working range is more than others. so if we want to use long numbers of any type and high accuracy then...? for example,
   data type variable;
double ab;
'ab' is a variable of double type. It can store exponential values (3x104). It ca n be written as 3e+4 or 3E+4. If power is in negative form then it can be in 3e-4 or 3E-4. It has one advantage over others that it can be used in place of others easily. 

q7.What is A.I.Describe the applications of AI.
Ans:-
Artificial Intelligence:-
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. In part due to the tremendous amount of data we generate every day and the computing power available, artificial intelligence has exploded in recent years. We might still be years away from generalised AI—when a machine can do anything a human brain can do—, but AI in its current form is still an essential part of our world

Applications:-
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
J
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
.
expert systems
A ``knowledge engineer'' interviews experts in a certain domain and tries to embody their knowledge in a computer program for carrying out some task. How well this works depends on whether the intellectual mechanisms required for the task are within the present state of AI. When this turned out not to be so, there were many disappointing results. One of the first expert systems was MYCIN in 1974, which diagnosed bacterial infections of the blood and suggested treatments. It did better than medical students or practicing doctors, provided its limitations were observed. Namely, its ontology included bacteria, symptoms, and treatments and did not include patients, doctors, hospitals, death, recovery, and events occurring in time. Its interactions depended on a single patient being considered. Since the experts consulted by the knowledge engineers knew about patients, doctors, death, recovery, etc., it is clear that the knowledge engineers forced what the experts told them into a predetermined framework. In the present state of AI, this has to be true. The usefulness of current expert systems depends on their users having common sense.

No comments:

Post a Comment