-->

NEB 2073 computer science questions and solutions

 NEB 2073 computer science questions:

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

set A

-




                                                            Group “A”

                                        Long Answer questions 4x10=40

Attempts any Four questions:

1.
a) What is loop? Differentiate between while and do-while loop. Describe with example.1+4

ans:
Loop
:-
It simply says execution of different statements/blocks again and again repeatedly under certain condition. When the condition dissatisfies, the execution stops. This is called iteration or looping.
Second part:-
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) Write a program to display first ten even numbers.5
ans:
/* a program to display first 10 even numbers*/
#include<stdio.h>
int main()
{
    int i=2,k=1;
    while(k<=10)
    {
        printf("%d,",i);
        i=i+2;
        k++;
    }
return 0;
}

2.What is string? Explain any four string handling functions with examples.2+8

ans:
String--
           It means series of characters used in our program. We can also use digits with characters. They also act as string or a part of it. It is used when we input our name or address or somewhere their combination.

Syntax
char identifier[value];
or char identifier[value][value];

We can use he upper one if we want to input single string then. And if we want to input multiple values then we use lower one(called 2-dimensional array in string).

For example,
char name[100];
gets(name)
Here, the variable accepts value having maximum characters 100. We can also write ,
char name[10]="kathmandu";
IT stores the value in following way.

It stores values from cell location '0' and ends at null character called escape sequence. This is used to show that there is no more character beyond that. This null character is used with strings only. For  numbers, it is not used.
                        Similarly, if we want to store multiple string with same name then one-dimensional is not applicable. We use two dimensional string.
We declare:

char name[5][50];
It means, we are going to store any five names having optimum 50 characters.
Let's look below. If we have five names :RAM,SHYAM,Nita then it would like

so sequentially it stores data in different row. We use loop to execute it with different data.
Or, instead of inputting string, if we initialize strings then it can be written as
  char name[5][50]={"RAM","Shyam","Nitu"};
second part:-
1) 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().

2)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));
}

We get output "elppa". Instead of putting in output line, we can put it before printf.

3)strlwr(): This function is used to convert given string into lower case.
syntax:-
strlwr(string);
Example;
#include<stdio.h>
#include<string.h>
void main()
{
char string[100]="APPLE";
printf("string in lowercase=%s",strlwr(string));
}

It gives us "apple" as an  output.

4)strupr():This string function is used to convert all characters of  string into upper case.

syntax:
strupr(string);

example:-
#include<stdio.h>
#include<string.h>
void main()
{
char string[100]="apple";
printf("string in uppercase=%s",strupr(string));
}

We get APPLE as an output after execution.


3.What is array? Write a program to sort twenty integers numbers in ascending order.2+8
ans:
array:-
Definition: A composite variable capable of holding multiple data of same data type under a single variable name is called array.
Features:
->stores multiple values
->helps to solve complex porblem
->can be used as array as pointer
->pixel based graphics programming made easier etc

Declaration of Array:

datatype array_name [size];

Example: - int marks [10]; int x[4]={1,2,3,4};

Array size is fixed at the time of array declaration.

Generally, we use for loop () to assign data or item in memory and also use this loop to extract data from memory location.

Types of Array:

There are 2 types of array.

a) One Dimensional Array (1-D): IT is an array where we use one subscript value.It stores value in row in contigous cells.
syntax:
data type arra[value/size];
For example:
int a[10];
This array stores ten value starting from location zero na dends at 9.

b) Two Dimensional Array (2-D):an array where we may use two or more than two subscript values.
In this we use matrix concept.
syntax:
data type arra[row size][column size];
For example:
int a[2][2];
It uses two rows and two columns.
Values are stored as:

 

Column zero

Column one

Row 0 Ã 

1(0,0)

2(0,1)

Row 1à

3(1,0)

4(1,1)

This array stores total four  values starting from location zero and ends at 1.
Second part:-
/* Write a C program that reads 20  integer numbers and arrange them in ascending order*/
#include <stdio.h>
int main()
{
    float numbers[20];
    int i,j,k;
    printf("Enter numbers\n");
    for(i=0;i<20;i++)
    {
        scanf("%f",&numbers[i]);
    }
    for(i=0;i<20;i++)
    {
        for(j=i+1;j<20;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<20;i++)
    {
        printf("%f\n",numbers[i]);
    }
    return 0;
}
4.

a) Write a program to add two integer numbers using function.5
ans:
// a function to add two integer numbers
#include <stdio.h>
int sum();
int main()
{
 sum();
return 0;
}
int sum()
{
int num1,num2;
printf("enter two numbers\n");
scanf("%d%d",&num1,&num2);
printf("sum=%d",num1+num2);
}

b) Define simple and compound statements. Describe logical operator with examples.
5

ans:

Simple statement:
A simple statement consists of an expression followed by a semicolon. The execution of a simple statement causes the expression to be evaluated. Example:
b=5;
c=d+e;
printf("Enter a number");
Compound statement:
A compound statement consists of several individual Statements enclosed in a pair of braces { } . It provides capability for embedding Statements within other statements.
Example:
{
r=5;
area=3.14*r*r;
}
It shows a compound statement to calculate the area of the circle.
Second part:
Logical operator:-
Logical operator:-
                                   This operator is quite helpful when we want to combine multiple  conditions and take decision.It returns values in the form of 0 o 1.It works logically.
Its types are:

3.a)and (&&)-----------> It is called 'and'operator.It is used to combine multiple conditions.It gives us true output if all of them are true otherwise we get false output.
 example:if(a>b && a>c)
                      {
                            display a     
                        }
 we can see here that to be greatest,value of 'a' must be greater than b and c. So we use here '&&'
   
  3.b)or(||):- It is called 'or'operator.It is used to combine multiple conditions.It gives us true output if anyone of them is true or all are true otherwise we get false output.
 example:if(a==90 || b==90 || c==90)
                      {
                            display right angle triangle  
                        }
 we can see here that to be right angled triangle,either 'a'or 'b'or 'c' a must be 90 . So we use here '||'.

3.c) !(not )operator:-
                                It is used to reverse the result.
example
int a=5;
if(!(a==5))
{
printf("it is\n");
}
else
{
printf("it is not\n");
}
here ,the value is 5 but we get output "it is not".It is called reversing the output.

a) What is pointer? Write its advantages..1+4

ans:

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.

some advantages:

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) Write a program to enter name, post and salary of a employee and write it in a file “employee.dat”.5

ans:
/*
 program to enter name, post and salary of a employee and write it in a file “employee.dat”.
*/
#include<stdio.h>
int main()
{
 FILE *p;
char name[100];
char post[100];
float salary;
p=fopen("employee.dat","w");
printf("enter name,post and salary\n");
printf("press ctrl+z to exit\n");
while((scanf("%s%s%f",name,post,&salary))!=EOF)
{
    fprintf(p,"%s%s%f",name,post,salary);
}
fclose(p);
return 0;
}








                                                                            Group “B”

                                                        Short Answer questions 7x5=35

Attempts any Seven questions:

6.Who is system analyst? Explain the roles of system analyst.1+4

ans:
System analyst:-
The persons who perform above task/system analysis,design and implementation activity is know as system analyst. Somewhere we say or call by names like business engineer, business analyst etc. The work of system analyst who designs an information system is just same as an architect of a house. They work as facilitators of the development of information systems and computer applications.
Roles:-

Defining Requirement: It's very difficult duty of analyst to understand user's problems as well as requirements. some techniques like interview, questioning, surveying, data collection etc have to be used. The basic step for any system analyst is to understand the requirements of the users.
Prioritizing Requirements: Number of users use the system in the organization. Each one has a different requirement and retrieves different information and in different time. For this the analyst must have good interpersonal skill, convincing power and knowledge about the requirements and setting them in proper order of all users.
Gathering Facts, data and opinions of Users: After determining the necessary needs and collecting useful information the analyst starts the development of the system with active cooperation from the users of the system. Time to time, the users update the analyst with the necessary information for developing the system. The analyst while developing the system continuously consults the users and acquires their views and opinions.
Evaluation and Analysis: Analyst analyses the working of the current information system in the organization and finds out extent to which they meet user's needs. on the basis of facts,opinions, analyst finds best characteristic of new system which will meet user's stated needs.
Solving Problems: Analyst is actually problem solver. An analyst must study the problem in depth and suggest alternate solutions to management. Problem solving approach usually has steps: identify the problem, analyse and understand the problem, identify alternate solutions and select best solution.


7.Write the importance and necessity of SDLC.5

ans:
SDLC:-

SDLC is a structure or a process to develop a software followed by a development team within the software organization. It consists of a detailed plan describing how to develop, maintain and replace specific software. SDLC is also known as information systems development or application development. It is life cycle defining a methodology for improving the quality of software and the overall development process. 




Why SDLC:-

When business organization facing a keen competition in the market, rapid change of technology and fast internal demand, system development is necessary. In the system development, a business organization could adopt the systematic method for such development. Most popular system development method is system development life cycle (SDLC) which supports the business priorities of the organization, solves the identified problem, and fits within the existing organizational structure. And obviously software can be very difficult and complex. We need the SDLC as a framework to guide the development to make it more systematic and efficient

In summarized form we can say following reasons for SDLC.

          I. To create a better interface between the user and the system.

        II. For good accuracy and speed of processing.

       III. High security and backup of data used in system.

      IV. Sharing of data all over the world in very less and real time.

       V. new laws that force organizations to do new things, or do old things differently

      VI. changes in society, such as growing demand for better security over personal data

      VII. a desire to improve competitiveness in the fact of reducing profits and market share



8.What is DBMS? Differentiate between centralized and distributed database.2+3

ans:
DBMS:-
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. 
Second part:-
Following are differences between distributed and centralized database system.


Centralized system
Distributed System
1.Job is centralized.
1.Job is distributed.
2. Can not process if main server fails.
2. Can still be if a server fails;processing can be done by other servers.
3. Security is given to one machine.
3.Security is given to all.
4.No need to have network for communication.
4 Needs communication channel between all.
5.Not so expensive to set up.
5.It’s expensive to set up.
6.Data speed is comparatively fast.
6.Data speed is slow.
7.Low quality performance.

Diagrammatically it can be shown as



7.High quality performance.

Diagrammatically it can shown




9.Explain Relational database model.5

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

Disadvantages:-

1.Information loss

2.Complexity

3.Physical storage

4.Performance



10.Explain bus and star topology with advantages and disadvantages.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.


11.Explain class and object.2.5+2.5

ans:

Class:-

In the real world, you'll often find many individual objects all of the same kind. There may be thousands of other bicycles in existence, all of the same make and model. Each bicycle was built from the same set of blueprints and therefore contains the same components. In object-oriented terms, we say that your bicycle is an instance of the class of objects known as bicycles. A class is the blueprint from which individual objects are created. So it can be said as collection of same type of objects.for example in java,


simply we can create by writing ,

class name

{

members;

functions;

}

here, we can see a class named helloworld.It displays output hello world! by creating a class we create an object/s.

Object:-

An object can be considered a "thing" with some attributes and  can perform a set of related activities. The set of activities that the object performs defines the object's behavior. For example, the hand can grip something or a Student(object) can give the name or address. They all have state and behavior. like ,Dogs have state (name, color, breed, hungry) and behavior (barking, fetching, wagging tail). Bicycles also have state (current gear, current pedal cadence, current speed) and behavior (changing gear, changing pedal cadence, applying brakes).

   For example if “customer” and “account.” are two objects in a program, then the customer object may send a message to the account object requesting for the bank balance. Each object contains data and code to manipulate the data. Objects can interact without having to know details of each other’s data or code. 





12.What is AI? Explain cyber Law.5

ans:
A.I.:-
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.
 cyber Law:-
This law is commonly known as the law of the internet. It governs the legal issues of computers, Internet, data, software, computer networks and so on. These terms of legal issues are collectively known as cyberspace. In other words, it is a type of law which rules on the Internet to prevent Internet related crime.

Cyber law is a new and quickly developing area of the law that pertains to persons and companies participating in e-commerce development, online business formation, electronic copyright, web image trademarks, software and data licenses, online financial transactions, interactive media, domain name disputes, computer software and hardware, web privacy, software development and cybercrime which includes, credit card fraud, hacking, software piracy, electronic stalking and other computer related offenses.

13.Explain the components of multimedia.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: Text is the most common medium of representing the information. In multimedia, text is mostly use for titles, headlines,menu etc. The most commonly used software for viewing text files are Microsoft Word, Notepad, Word pad etc. Mostly the text files are formatted with ,DOC, TXT etc extension.

2)Audio: In multimedia audio means related with recording, playing etc. Audio is an important components of multimedia because this component increase the understandability and improves the clarity of the concept. audio includes speech, music etc. The commonly used software for playing audio files are:
i) Quick Time
ii) Real player
iii) Windows Media Player

3)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.

4)Video: Video means moving pictures with sound. It is the best way to communicate with each other. In multimedia it is used to makes the information more presentable and it saves a large amount of time. The commonly used software for viewing videos are:
i) Quick Time
ii) Window Media Player
iii) Real Player

5)Animation: In computer animation is used to make changes to the images so that the sequence of the images appears to be moving pictures. An animated sequence shows a number of frames per second to produce an effect of motion in the user's eye.


14.Define the terms e-learning and virtual reality.2.5+2.5

Ans:-

e-learning:-
 E-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.

Virtual reality
Virtual reality is a new computational paradigm that redefines the interface between human and computer becomes a significant and universal technology and subsequently penetrates applications for education and learning.
 
Application fields of Virtual reality
Virtual Reality in the Military: 
A virtual reality simulation enables them to do so but without the risk of death or a serious injury. They can re-enact a particular scenario, for example engagement with an enemy in an environment in which they experience this but without the real world risks.
Virtual Reality in Education: 
Education is another area which has adopted virtual reality for teaching and learning situations. The advantage of this is that it enables large groups of students to interact with each other as well as within a three dimensional environment.
Virtual Reality in Healthcare: 
Healthcare is one of the biggest adopters of virtual reality which encompasses surgery simulation, phobia treatment, robotic surgery and skills training.
Virtual Reality in Business: 
Many businesses have embraced virtual reality as a cost effective way of developing a product or service. For example it enables them to test a prototype without having to develop several versions of this which can be time consuming and expensive.

15.Write short notes on :

a) WiFi b) Normalization

Ans:-

WiFi:-
Ans:-
Wi-Fi is the wireless technology used to connect computers, tablets, smartphones and other devices to the internet. Wi-Fi is the radio signal sent from a wireless router to a nearby device, which translates the signal into data you can see and use.
Internet connectivity occurs through a wireless router. When you access Wi-Fi, you are connecting to a wireless router that allows your Wi-Fi-compatible devices to interface with the Internet.
It works using access point.What a wireless access point does for your network is similar to what an amplifier does for your home stereo. An access point takes the bandwidth coming from a router and stretches it so that many devices can go on the network from farther distances away. But a wireless access point does more than simply extend Wi-Fi. It can also give useful data about the devices on the network, provide proactive security, and serve many other practical purposes.

Normalization:-
Ans:-
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.
It is of following types:
1N
2N
3N
4N
and 5N
Advantages:-

Some of the major benefits include the following :

  • Greater overall database organization
  • Reduction of redundant data
  • Data consistency within the database
etc
-------------------------------------------------------------------------------------------------------------------
Set B
--------
                                                                    Group “A”

                                                    Long Answer questions 4x10=40
Attempts any Four questions:

1.

a) Describe the switch statement with example.5
Ans:-
Switch case statement is a multipath decision making statement that allows selection and execution of a particular block of statements from several blocks of statement based upon the value of expression which is included within the switch statement and branches accordingly. The expression must be of an integral value (“integral” values are simply values that can be expressed as an integer, such as the value of a char).

Syntax:

switch(expression)

{

case constant 1:

          statement 1;

break;

case constant 2:

        statement 2;

break;


        case constant n-1:

statement n-1;

break;

default:

statement n;

}
Description:-

When the switch statement is executed, the value of expression is compared with the value of case constant (constant1 , constant2...)
Then the block of statements associated with the case whose value is matched with expression will be executed.
a break statement at the end of block indicates the end of the particular case and cause an exit from switch statement and control will be transferred to statements following with switch.
If none of the cases match with the value of the expression, then the block of statement under default is executed.

Flowchart: Its flowchart can be represented as:




switch diagram

































Example:

#include <stdio.h>
int main()
char ch;
printf("enter choice\n");
scanf("%c",&ch);
switch(ch)
{
case 'b': case 'B':
printf("It is second letter");
break;
case 'z': case 'Z':
printf("It is last letter");
break;
default:
printf("other letter");
}
return 0;
}


In this program if we enter characters as used in program, it prints related message. Otherwise, it says other letter. It tests the characters in parallel form rather serial.So it is
supposed to be faster than if..else if ladder




b) What are the difference between While and Do while loop? Explain with syntax.3+2
Ans:-



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.



2.Write a program to read five positive number using array and find out the smallest among them.10
Ans:-

/*to find the smallest value*/
#include<stdio.h>
int main()
{
    int numbers[5];
    int i,small;
    printf("enter numbers\n");
    for(i=0;i<=4;i++)
    {
        scanf("%d",&numbers[i]);
    }
    
    small=numbers[3];
    
for(i=0;i<=4;i++)
    {
       
        if(small>numbers[i])
        {
            small=numbers[i];
        }
    }
    printf("smallest number=%d",small);
    return 0;
}




3.
a) Describe the string manipulation function in C. Explain strcpy and strcmp with example.2+3
Ans:-
String manipulation function:- 
Some library functions existing inside string.h which are used to process  string are called string 
manipulation functions.
For example,
We can use strlen() to find length of string.

Second part:-
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.
2.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).-
example:
#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;

}


b) Write a program to demonstrate the value of variables and address of variable using pointer in C.5

Ans:-
call by value:-
                         We can pass argments/parameters either by value or address.
 passing by value means we are going to copy the value directly to the formal arguments from real arguments. the change is formal arguments have no effect in real argument.Example is here.
// call by value
#include <stdio.h>

void callbyvalue(int, int);                            
void main()                                               
{
  int x = 10, y= 20;                                

                                                                   
  callbyalue(x, y);                           
  printf("x= %d, y= %d\n", x, y);    
}

void callbyvalue(int m, int n)             
{
  int t;
  t = m;
m = n;
 n = t;                              
}

out put is: x=10,y=20
Here, the values of x and y are no affected by  values of m and n. so there will be no swapping.

call by reference:- We have now second method to pass our arguments/paramenter.In this, we use pointer to pass addressof parametersto the functions. in this way the values are copied to formalparameter and process continues there.example is given here.


// call by value reference
#include <stdio.h>
void callbyref(int*, int*);                                                        

void main()                                                                                  
{
  int x = 10, y = 20;                                                             
                                                                                              
  callbyref(&x, &y);                                                             
  printf("x: %d, y: %d\n", x, y);                                          
}

void callbyref(int *m, int *n)
{
  int t;
  t = *m; *m = *n; *n = t;                                                    
}


output: x=20,y=10
In above example we have passed address of identifier x and y to the function.while passing address,its vale is copied to formal parameter and then swapping takes place. It means by passing address we can alter the value in real parameter which was not possible in call by value,

4.Describe the function in C. Write a program to find the sum of “n” integer number using function in C.4+6
Ans:-
Function:-
Definition: A self –contained block of code that performs a particular task is called Function.
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

A function has 4 elements.

1. Function Declaration (Function Prototype)

2. Function Call

3. Function Definition
4.Returning some value


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 find the sum of “n” integer number using function in C
*/
#include<stdio.h>
#include<conio.h>
void sum();
void main()
{

sum();
getch();
}
void sum()
{int k=1,n,number,sum=0;
printf("enter value of 'n' as total number\n");
scanf("%d",&n);
while(k<=n)
   {
        printf("enter %d value\n",k);
     scanf("%d",&number);
      sum=sum+number;
      k++;
   }
printf("sum=%d",sum);
}
5.Differentiate between structure and union. Write a program to input the employee name and post of five employees and display the records in proper format using structure.3+7

Ans:-
Difference between struct and union are given below.
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;


Second part:-
/*a program to input the employee name and post of five 
employees and display the records in proper format using structure.
*/

#include <stdio.h>
struct emp
{
    char name[100];
  char post[100];
}var[5];
int main()
{
    int i;
    printf("enter name and post\n");
    for(i=0;i<=4;i++)
    {
        scanf("%s",var[i].name);
        scanf("%s",var[i].post);
    }
    printf(" name and post of employees are:\n");
    for(i=0;i<=4;i++)
    {
        printf("name=%s,post=%s \n",var[i].name,var[i].post);       
    }
    return 0;
}



                                                                    Group “B”


                                                    Short Answer questions 7x5=35
Attempts any Seven questions:

6.What the major activities in SDLC with based on waterfall model?5
Ans:-

Waterfall model:-

This Model also called Linear sequential Development Model, this model suggest a systematic Sequential approach to Software development that begins at the different level and progress through analysis, design, coding ,testing , and support .Here a stage cannot begin unless the preceding stage is completed  like in a waterfall, water flows down to from the upper steps. 




Requirement Analysis- This is the most crucial phase for the whole project, here project team along with the customer makes a detailed list of user requirements. The project team chalks out the functionality and limitations(if there are any) of the software they are developing, in detail. 

system  Design- Before a starting for actual coding, it is highly important to understand what we are going to create and what it should look like? The requirement specifications from first phase are studied in this phase and system design is prepared. This step is used for hardware and software interfaces.

Implementation and Unit Testing:

Now that we have system design, code generation begins. Code generation is conversion of design into machine-readable form. If designing of software and system is done well, code generation can be done easily. 

Integration and System testing:

Now the units of the software are integrated together and a system is built. So we have a complete software at hand which is tested to check if it meets the functional and performance requirements of the customer.

Operation & maintenance:

Now that we have completed the tested software, we deliver it to the client. His feedbacks are taken and any changes,if required, are made in this phase. This phase goes on till the software is retired.

Benefits-

•    Easy to understand, easy to use.

•    Appropriate for small Software.

Disadvantages

    Not appropriate for large Software.

  When any changes need than we have to go to initial phase.


7.What is DBMS? Explain data integrity with suitable example.2+3

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.

Data integrity: 

                   Integrity is consistency of actions, values, methods, measures, principles, expectations and outcome. 

Data integrity is a term used in computer science and telecommunications that can mean ensuring data is "whole" or complete, the condition in which data are identically maintained during any operation (such as transfer, storage or retrieval), the preservation of data for their intended use, or, relative to specified operations, the a priori expectation of data quality. 

                    Or

Database integrity means the correctness and consistency of data. It is another form of database protection.

Put simply, data integrity is the assurance that data is consistent and correct.

Data integrity is normally enforced in a database system by a series of integrity constraints or rules. 

          Three types of integrity constraints are an inherent part of the relational data model: entity integrity, referential integrity


Entity integrity concerns the concept of a primary key. Entity integrity is an integrity rule which states that every table must have a primary key and that the column or columns chosen to be the primary key should be unique and not null. It means the primary key’s data must not be missing in table/s.

    or

The entity integrity is a constraint on primary key value. It states that any attribute of a primary key cannot contain null value. If primary key contains null value, it is not possible to uniquely identify a record in a relation. Entity integrity ensures that it should be easy to identify each entity in the database.


Referential Integrity

Referential integrity ensures that the relationship between the primary key (in a referenced table) and the foreign key (in each of the referencing tables) is always maintained. The maintenance of this relationship means that:

  • A row in a referenced table cannot be deleted, nor can the primary key be changed, if a foreign key refers to the row. For example, you cannot delete a customer that has placed one or more orders.

  • A row cannot be added to a referencing table if the foreign key does not match the primary key of an existing row in the referenced table. For example, you cannot create an order for a customer that does not exist.


Domain Integrity

Domain (or column) integrity specifies the set of data values that are valid for a column and determines whether null values are allowed. Domain integrity is enforced by validity checking and by restricting the data type, format, or range of possible values allowed in a column.


8.Define DML and DDL with example.3+2
Ans:-
DML:

Data Manipulation Language (DML) is a family of computer languages used by computer programs database users to retrieve, insert, delete and update data in a database.

Currently the most popular data manipulation language is that of SQL, which is used to retrieve and manipulate data in a Relational database. Data Manipulation Languages have their functional capability organized by the initial word in a statement, which is almost always a verb. In the case of SQL, these verbs are:

Select

Insert

Update

Delete

etc

Example:-

For example, if we have a table named students with some records, then to extract data with some condition, we use DML as
select *
from students

where name="ram"

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)
);
9.Describe the Bus and Star topology with suitable 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.



10.Differentiate between guided and unguided networking media.5
Ans:-
Difference between guided and unguided are given below.

S.No.

Guided Media

Unguided Media

1.

The signal energy propagates through wires in guided media.

The signal energy propagates through air in unguided media.

2.

Guided media is used for point to point communication.

Unguided media is generally suited for radio broadcasting in all directions.

3.

Discrete network topologies are formed by the guided media.

Continuous network topologies are formed by the unguided media.

4.

Signals are in the form of voltage, current or photons in the guided media.

Signals are in the form of electromagnetic waves in unguided media.

5.

<Examples of guided media are twisted pair wires, coaxial cables, optical fiber cables.

Examples of unguided media are microwave or radio links and infrared light.

6.

By adding more wires, the transmission capacity can be increased in guided media.

It is not possible to obtain additional capacity in unguided media.


11.What is variable in programming? List out the different data types used in C.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

Examples of valid variable names are

Sun number Salary Emp_name averagel

Second part:
Data type:-
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.
Primary and secondary data types can be shown in following table.

Variable Type

Keyword

Storage 

Size

Range

Character

char

1 byte

-128 to 127

Unsigned character

unsigned char

1 byte

0 to 255

Integer

int

2 byte

-32768 to 32767

Short integer

short int

2 byte 

-32768 to 32767

Long integer

long int

4 byte

-2,147,483,648 to 2,147,483,647

Unsigned integer

unsigned int

2 byte

0 to 65535

Unsigned short integer

unsigned short int

2 byte

0 to 65535

Unsigned Long integer

unsigned long int

4 byte

0 to 4,294,967,925

Float

float

4 byte

1.2 E-38 to 3.4E+38

Double

double

8 byte

2.2E-308 to 1.7 E+308

Long double

long double

10 byte

3.4 E-4932 to 1.1 E+308


12.Describe the different mode of file handling concept in C.5
Ans:-
Data file concept:-
We know that when we enter data in our program, it gets lost when the program is terminated.we have to preserve our data permanently such that it can be accessed any time.For this, we use data file concept. we can either  store our data in text form or binary form.
When we store data in a file, we can work in following modes.
There are many modes for opening a file:
  • r - open a file in read mode.
  • w - opens or create a text file in write mode.
  • a - opens a file in append mode.
  • r+ - opens a file in both read and write mode.
  • a+ - opens a file in both read and write mode.
  • w+ - opens a file in both read and write mode.
for example,
//WAP to store details about book(any 'n') having fields name,price,edition.
#include<stdio.h>
include<conio.h>
void main()
{
FILE *k;                                                               
char book_name[30],choice;                                                 
int book_price,edition;                                            
k=fopen("book.dat","w");
do
{
printf("enter book's name\n");                                    
gets(book_name);
printf("enter edition\n");
scanf("%d",&edition);
printf("enter book's price\n");
scanf("%d",&book_price);
fprintf(k,"%s %d %d",book_name,edition,book_price); 
printf("want to continue y/n\n");
choice=getche();                                                        
}while(choice!='n');                                                    
printf("writing process completed successfully\n");
fclose(k);                                                                                  
getch();
}

13.Describe the cyber crime in Nepal. What are protection methods to the cyber crime?2+3
Ans:-
Alternatively referred to as cyber crime, e-crime, electronic crime, or hi-tech crime. Computer crime is an act performed by a knowledgeable computer user, sometimes referred to as a hacker that illegally browses or steals a company's or individual's private information. In some cases, this person or group of individuals may be malicious and destroy or otherwise corrupt the computer or data files.


Below is a listing of the different types of computer crimes today. Clicking on any of the links below gives further information about each crime.

Different types of crime:-
1.Pornogrphy
2.Hacking
3.DOS
4.Phising etc

Protection method:

1. Use a full-service internet security suite
2. Use strong passwords
3. Keep your software updated
4. Manage your social media settings
5.Talk to your children about the internet
6. Keep up to date on major security breaches


14.What is multimedia? List out the component of multimedia.2+3

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: Text is the most common medium of representing the information. In multimedia, text is mostly use for titles, headlines,menu etc. The most commonly used software for viewing text files are Microsoft Word, Notepad, Word pad etc. Mostly the text files are formatted with ,DOC, TXT etc extension.

2)Audio: In multimedia audio means related with recording, playing etc. Audio is an important components of multimedia because this component increase the understandability and improves the clarity of the concept. audio includes speech, music etc. The commonly used software for playing audio files are:
i) Quick Time
ii) Real player
iii) Windows Media Player

3)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.

4)Video: Video means moving pictures with sound. It is the best way to communicate with each other. In multimedia it is used to makes the information more presentable and it saves a large amount of time. The commonly used software for viewing videos are:
i) Quick Time
ii) Window Media Player
iii) Real Player

5)Animation: In computer animation is used to make changes to the images so that the sequence of the images appears to be moving pictures. An animated sequence shows a number of frames per second to produce an effect of motion in the user's eye.
15.Write short notes on :2.5+2.5

a) DBMS b) Network Protocols
Ans:-
a)DBMS:-

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.

b)Network protocols:-
Ans:-
A communications protocol is a formal description of digital message formats and the rules for exchanging those messages in or between computing systems and in telecommunications. Protocols may include signaling, authentication and error detection and correction capabilities. A protocol describes the syntax, semantics, and synchronization of communication and may be implemented in hardware or software, or both.

We have many examples like http, ftp, stp, tcp/IP etc.

TCP is one of the main protocols in TCP/IP networks. Whereas the IP protocol deals only with packets, TCP enables two hosts to establish a connection and exchange streams of data. TCP guarantees delivery of data and also guarantees that packets will be delivered in the same order in which they were sent.

Where as IP specifies the format of packets, also called datagram, and the addressing scheme. Most networks combine IP with a higher-level protocol called Transmission Control Protocol (TCP), which establishes a virtual connection between a destination and a source
------------------------------------
credits:-
floridatechonline.com
and some other sites
Thank you.

 

No comments:

Post a Comment