-->

NEB year 2066 computer science questions and solutions

 NEB year 2066 computer science questions

old syllabus:

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

                                                                            Group-A (2x20=40)

Attempt any two questions.

q1)

      a)Write an algorithm  for a program that input cost of price (CP) an dselling price (SP) and determeine whether there is gain or loss.Convert this algorithm into program code.[5];

Ans:-

    Algorithm:

         
        Step1: Start

        Step 2: Input sp and cp

        Step 3: Check, is sp greater than cp?

                3.1 If yes, calculate gain=sp-cp and display gain.goto last step

                3.2 If no, calculate loss=cp-sp and display loss. goto last step

        Step 4: Stop

    C'' code:-
  
        #include <stdio.h>

        int main()

        {

            float sp,cp,gain,loss;

            printf("Enter selling price and cost price : ");

            scanf("%f%f",&sp,&cp);

            if(sp>cp)

            {

            gain=sp-cp;

            printf("Gain = NPR. %0.2f",gain);

            }

            else

            {

        loss=cp-sp;

        printf("Loss = NPR. %0.2f",loss);

        }

        return 0;

}

    b)Write a program to display the name of day on the basis of  entered number 1 to 7.For example ,1 for Sunday.[5]

    Ans:-

    /*WAP to display the name of day on the basis of entered number 1 to 7 using switch.

 For example, 1 for  Sunday.*/

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int choice;
int number,output;
printf("'we have following menu\n");
printf( "1.for Sunday\n");
printf("2. for Monday\n");
printf("3 for Tuesday\n");
printf("4 for Wednesday\n");
printf("5 for Thrusday\n");
printf("6 for Friday\n");
printf("7 for Saturday\n");
printf("enter your choice 1 or 2 or 3 or 4 or 5 or 6 or 7 or any other number to exit\n");
scanf("%d",&choice);
 switch(choice)
          {
                  case 1:
                            printf("It's Sunday\n");
                            
                break;
               case 2:
                            printf("It's Monday\n");
                 break;

               case 3:
                           printf("IT's Tuesday\n");                            
                 break;
             case 4:
                       printf("It's Wednesday\n");
            break;
          case 5:
                      printf("It's Thrusday\n");
          break;
           case 6:
                     printf("It's Friday\n");
            break;  
            case 7:
                        printf("It's Saturday\n");
           break; 
           default:
                            printf("sorry, not a valid input\n");
                            printf("thank u, terminating....\n");
          }
getch();
}

    c)Write a program to input an integer number and check whether it is prime or not.[5]

    Ans:-

#include <stdio.h>

int main()

{

    int i,n;

    printf("entera number\n");

    scanf("%d",&n);

    int count=0;

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

    {

            if(n%i==0)

            {

                count++;

            }

    }

        if(count==2)

        printf("%d is prime,",n);

        else

        printf("%d is composite,",n);

    return 0;

}

    d)Explain data types used in C programming language with example.[5]

    Ans:-

    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.

Q2)

    a)Write a program to store name and marks of 20 students.Sort the data according with marks in descending order and display that.[10]

    Ans:-

    /* 

C program to input name  and marks of 20 students and arrange
them in ascending order to the marks.
*/
#include <stdio.h>
#include<string.h>
struct shorting
{
  char name[100];
   int marks;
}var[20],var1;
int main()
{
    int i,j;
    printf("enter name and marks\n");
    for(i=0;i<=19;i++)
    {
        scanf("%s",var[i].name);
         scanf("%d",var[i].marks);
    }
for(i=0;i<=19;i++)
{
    for(j=i+1;j<=19;j++)
    {
        if(var[i].marks<var[j].marks)))
        {
            var1=var[i];
            var[i]=var[j];
            var[j]=var1;
        }
    }
}
for(i=0;i<=19;i++)
    {
        printf("name=%s marks=%d\n",var[i].name,var[i].marks);
       
    }
    return 0;
}


    b)Write a program to find the sum of 'n' integer number using function.[10]

    Ans:-

    //program to get sum of 'n' integers using function.

        #include<stdio.h>
        #include<conio.h>
        void sum();
        void main()
        {

        sum();
        getch();
        }
    void sum()
    {
        int k=1,n,sum=0;
        printf("enter value of 'n'\n");
        scanf("%d",&n);
        while(k<=n)
           {
              sum=sum+k;
              k++;
           }
        printf("sum=%d",sum);
    }

   q3)

    a)Write a program to store stdno,name and marks or n students in a data file.Display the records in appropriate format reading from the fiel.[10]

    Ans:-

    #include<stdio.h>

int main()

{

 FILE *p;

char name[100];

int stdno;

int eng,phy,maths,chem,csc;

p=fopen("student.dat","w");

printf("enter name,student no.and marks in eng,phy,maths,chem and csc\n");

printf("To exit ,press ctrl+z\n");

while((scanf("%s%d%d%d%d%d%d",name,&stdno,&eng,&phy,&maths,&chem,&csc))!=EOF)

{

 fprintf(p,"%s\t%d\t%d\t%d\t%d\t%d\t%d",name,stdno,eng,phy,maths,chem,csc);

}

fclose(p);

p=fopen("student.dat","r");

printf("data are\n");

while((fscanf(p,"%s%d%d%d%d%d%d",name,&stdno,&eng,&phy,&maths,&chem,&csc))!=EOF)

{

 printf("name=%s,stdno=%d, english=%d,physics=%d,maths=%d,chemistry=%d ,csc=%d \n",name,stdno,eng,phy,maths,chem,csc);

}

fclose(p);

return 0;

}

    b)Differentiate array and structure with examples.[10]

    Ans:-

    Differences between array and struct are given below.                                                                                                                                                

Arraystruct
1.It stores same type of data1. It stores dis-similar type of data.
2.It uses static memory allocation .2.I uses dynamic memory allocation.
3.It takes less time to access elements.3.It takes more time to access elements.
4.It uses index value to access elements.4.It takes help of period operator(.) to access elements.
5.It is derived data type.5. IT is user's defined data type.
6.We can not define array of array.          6.We can define array of structure.
7.Its syntax is                                          
data type identifier[value];








example,int a[20];
7.Its syntax is
struct tag
{datatype member1;
datatype member2;
data type member3;
}variable;
example,
struct det
{char name[100];
char add[40];
int  roll;
}variable;

                                                             Group-A (5x7=35)

Attempt any five questions.

4. Define Network Architecture. Explain client-server and peer-to-peer networking. [2+5]

Ans:-

Network Architecture:-

Network architecture refers to the way network devices and services are structured to serve the connectivity needs of client devices. Network devices typically include switches and routers. Types of services include DHCP and DNS. Client devices comprise end-user devices, servers, and. smart things.

             Client –server:
  • In this, one or two computers work as server and left all work as clients.

  • Clients computers give request to server for a task to be performed.

  • Clients computers may or may not have self processing capability. they rely on server.

  • Mostly servers use a powerful operating system like, Linux or Unix or Win advanced server2008 etc.

  • Through server, the sharing of files is done.

  • Everything is controlled by server so in the case of down, services can not be completed.

  • under heavy load, many servers share the tasks.

  • there is high level security in networking.

  • High traffic towards servers while processing.

       Peer to peer(P2P):
  • In this all the computers are treated equally.

  • No one computer is server or client.

  • All computers can be said working as client or server.

  • Computers have self processing capability and do not rely on others.

  • Computers have or can run with normal operating system like, XP, Me etc and application.

  • Easy sharing of files and allows us to have chatting.

  • failure of one does not mean others are down; networking goes on.

  • If heavy load is given, they may not give same performance. etc

  • low level security.

5. Explain about the system designing methodologies. [7]

Ans:-

Basically we have two design methodologies.

1.Top-down methodology

2. Bottom-up methodologies

Let's know about them:

1.Top-down methodology :-

            This methodology carries following properties.

  1. Breaks the massive problem into smaller subproblems.
  2. Submodules are solitarily analysed
  3. communication is not required in the top-down approach.
  4. Contain redundant information.
  5. Structure/procedural oriented programming languages (i.e. C) follows the top-down approach.
  6. It is mainly used in Module documentation, test case creation, code implementation and debugging.
2. Bottom-up methodologies:-
  1. Solves the fundamental low-level problem and integrates them into a larger one.
  2. Examine what data is to be encapsulated, and implies the concept of information hiding.
  3. Needs a specific amount of communication.
  4. Redundancy can be eliminated.
  5. Object-oriented programming languages (like C++, Java, etc.) follows the bottom-up approach.
  6. It is used mainly intesting.


6. Explain about OSI/ISO model of networking,[7]

Ans:-

OSI model:-

The OSI, or Open System Interconnection, model defines a networking framework for implementing protocols in seven layers. Control is passed from one layer to the next, starting at the application layer in one station, and proceeding to the bottom layer, over the channel to the next station and back up the hierarchy.

---------------------->Application (Layer 7)

  • This layer supports application and end-user processes. 

  • Communication partners are identified, quality of service is identified, user authentication and privacy are considered, and any constraints on data syntax are identified. 

----------------------->Presentation layer (layer 6):-

  • This layer provides independence from differences in data representation (encryption) by translating from application to network format, and vice versa. 

  • The presentation layer works to transform data into the form that the application layer can accept.

------------------------>Session (Layer 5)

  • This layer establishes, manages and terminates connections between applications.

----------------------->Transport (Layer 4)

  • This layer provides transparent transfer of data between end systems, or hosts, and is responsible for end-to-end error recovery and flow control.

  •  It ensures complete data transfer.

------------------------->Network (Layer 3)

  • This layer provides switching and routing technologies, creating logical paths, known as virtual circuits, for transmitting data from node to node

------------------------>Data Link (Layer 2)

  • At this layer, data packets are encoded and decoded into bits.

  •  It furnishes transmission protocol knowledge and management and handles errors in the physical layer, flow control and frame synchronization

------------------------->Physical (Layer 1)

  • This layer conveys the bit stream - electrical impulse, light or radio signal -- through the network at the electrical and mechanical level. 

  • It provides the hardware means of sending and receiving data on a carrier, including defining cables, cards and physical aspects

7. Define database and DBMS. Explain the advantage of Database system over flat-file system. [2+5]

Ans:-

Database:-

Simply well organized collection of data is database.

 One way of classifying databases involves the type of content, for example: bibliographic, full-text, numeric, and image. Databases consist of software-based "containers" that are structured to collect and store information so users can retrieve, add, update or remove such information in an automatic fashion. Database programs are designed for users so that they can add or delete any information needed. The structure of a database is tabular, consisting of rows and columns of information.

Advantages

  • Reduced data redundancy

  • Improved data security

  • Reduced data entry, storage, and retrieval costs

  • Facilitated development of new applications program

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

Second part:-

Advantages of DBMS over flat file system:-

It used to have following advantage over flat file approach:-

1) Data redundancy

2) Data integrity

3) Data consistency

4) Security, sharings

5) Isolation of data.

etc

8. Explain about the importance of computer security in this knowledge based society. [7]

Ans:-

Computer security goes hand-in-hand with data security. System security describes the controls and safeguards that an organization takes to ensure its networks and resources are safe from downtime, interference or malicious intrusion.
Some common cyber attacks done to harm our server/computers:

1.Malware
2.Denial of Service
3.Backdoor attack
4.Direct Access Attack
5.Phising
6.Salami saving
etc
To be safe from these types of attacks, we can use following methods.
1.Using antivirus software
2.Using genuine software
3.Downloading files/softwares from secured sites.
4.Using powerful OS.
5.Enabling our firewall.
6.By noticing symptoms of computer.
7.By putting secured password and not shring withanyone.

9. What are the different program logic tools? Explain about the decision table and decision tree with examples.[2+5]

Ans:-

Different program logic tools are given below.

1.Algorithm

2.Flowchart

3.Pseudocode

4.Decision table

5.Decision tree

6.DFD

7.UML

Let's understand about decision table and decision tree.

Decision table:- A decision table is a table with various conditions and their corresponding actions. Decision table is a two dimensional matrix. It is divided into four parts, condition stub, action stub, condition entry, and action entry. See the first figure listed below. Condition stub shows the various possible conditions. Condition entry is used for specifying which condition is being analyzed. Action stub shows the various actions taken against different conditions.

And action entry is used to find out which action is taken corresponding to a particular set of conditions.

condition stub                                               condition entry


1

2

3

4

5

6

7

8

Is a person SLC pass ?

y

y

y

n

n

n

n

y

Is a person with percentage>=60

y

y

n

y

n

n

y

n

Is a person with entrance marks>=40

y

n

y

y

n

y

n

n

admit him

x

x

x






no, do not admit him




x

x


x


can be but under re-entrance




x

x

x

x


action stub action entry


Decision tree is a set of rules for what to do in certain condition and if particular condition  






satisfies, do that otherwise go to this step. They can be used to enforce strict compliance with local procedures, and avoid improper behaviors, especially in complex procedures or life-and-death situations.

E.g. If the photocopier breaks down, call Raj. If Raj is not available, call Aasha. If Aasha is away, ring Sary.

They are valuable when setting out how the system should behave, and what conditions it will need to be able to cope with. A decision tree showing decisions and actions required of a software system

In above diagram we can see how an applicant is selected or hired under different condition.Sometimes in critical situation it can be used for decision taking. 

10. What are the advantages of distributed database system over centralized database system? [7]

Ans:-

Distributed database system:-

A distributed database is basically a database that is not limited to one system, it is spread over different sites, i.e, on multiple computers or over a network of computers. A distributed database system is located on various sites that don’t share physical components. This may be required when a particular database needs to be accessed by various users globally. It needs to be managed such that for the users it looks like one single database.

 

Following are some advantages over centralized daatbase.

1.It is highly secured.

2.If  a computer fails, entire system keeps on runnig.

3.There is load balancing.

4.High performance.

5.Faster response time.

6.Fast data sharing.

etc.

11. Explain about the different testing techniques during the system development [7]

Ans:-

System Testing Methodologies:
1.Functional   Testing:Functional testing involves testing the application against the business requirements. It incorporates all test types designed to guarantee each part of a piece of software behaves as expected by using uses cases provided by the design team or business analyst. We perform following testing under this.
  • Unit Testing. 
Unit testing is the first level of testing and is often performed by the developers themselves.
  • Integration Testing:-
After each unit is thoroughly tested, it is integrated with other units to create modules or components that are designed to perform specific tasks or activities.
  • System Testing:-
System testing is a black box testing method used to evaluate the completed and integrated system, as a whole, to ensure it meets specified requirements.
  • Acceptance Testing:
Acceptance testing is the last phase of functional testing and is used to assess whether or not the final piece of software is ready for delivery

2. Non-functional Testing:- It incorporates all test types focused on the operational aspects of a piece of software. These include:
  • Performance Testing:-
                              Performance testing is a non-functional testing technique used to determine how an application will behave under various conditions.      
  • Security Testing
                        Security testing is a non-functional software testing technique used to determine if the information and data in a system is protected. 
  • Usability Testing
                    Usability testing is a testing method that measures an application’s ease-of-use from the end-user perspective and is often performed during the system or acceptance testing stages.

12. Write short notes: [3.5+3.5)

a)E-commerce b) Inheritance

Ans:-

E-commerce:-

E-commerce is a transaction of buying or selling online. Electronic commerce draws on technologies such as mobile commerceelectronic funds transfersupply chain managementInternet marketingonline transaction processingelectronic data interchange (EDI), inventory management systems, and automated data collection systems. Modern electronic commerce typically uses the World Wide Web for at least one part of the transaction's life cycle although it may also use other technologies such as e-mail.
E-commerce businesses may employ some or all of the following:

  • Online shopping web sites for retail sales direct to consumers
  • Providing or participating in online marketplaces, which process third-party business-to-consumer or consumer-to-consumer sales
  • Business-to-business buying and selling
  • Gathering and using demographic data through web contacts and social media
  • Business-to-business (B2B) electronic data interchange
  • Marketing to prospective and established customers by e-mail or fax (for example, with newsletters)
  • Engaging in pretail for launching new products and services

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.

sources:-

techdifferences.com

smartbear.com

1 comment:

  1. Top 10 casino games from RealTime Gaming
    The first 온 카지노 time หาเงินออนไลน์ you're playing the casino game online in your browser doesn't feel 더킹 카지노 like 먹튀 커뮤니티 you have logged in to 온라인 카지노 먹튀 play it. The casino games are designed to

    ReplyDelete