NEB year 2076 computer science
2076
Group 'A'
(Long answer questions)
Attempt any four questions: 4x10=401. What is user defined function? Write a program to input length and breadth of a pond and find its area by using user defined function. [4+6]
2. What is 'while' loop statement. Write an algorithm and a C program to input a number and reverse it. [4+6].
3. Define array. Write a program to input any 10 numbers in an array and display it. Find the biggest number among the input numbers. 2+4+4
4. What is structure? Write a program to input employee id, name, address and post of 20 employees and display them properly. 2+8
5. a) What is the importance of file pointer in file handling? Explain with an example. 5
b) Explain any two string functions with examples. 5
Group 'B'
(Short answer questions)
Attempt any seven questions: 7x5=35
6. Define SDLC. Describe the feasibility analysis methods. 2+3
7. Explain the different types of data integrity in DBMS. 5
8. What is SQL? Describe the DML with an example. 2+3
9. Define network topology. Explain the Ring Topology. 2+3
10. Describe the wireless network system. List out deices and equipment necessary for Wi-Fi network. 3+2
11. Describe the different operator types in C program. 5
12. Describe the different mode of the file handling concept in C. 2.5+2.5
13. Define cyber bullying. Suggest the possible solutions to remain safe from cyber crime. 5
14. What are the roles of AI in our real life? List out AI related systems in our spciety. 1+4
15. Write short notes on : 2.5+2.5
a) Primary Key b) IP address
THE END
-----------------------------------------------------------------------------------------------------------
Answers
q1)What is user defined function? Write a program to input length and breadth of a pond and find its area by using user defined function. [4+6]
ans:
Answer:
Definition: A self –contained block of code that performs a particular task is called Function.
A function has 3 elements.
1. Function Declaration (Function Prototype)
2. Function Call
3. Function Definition
Additionally we can have return statement in function. Let's understand about them.
1. Function Declaration (Function Prototype)
A function declaration also known as Function Prototype consists of four parts. In some programs it is optional i.e. we can use function without declaration. Its major part are:
· Function type(return type)
· Function name
· Parameter list
· Terminating Semicolon
Syntax:
Function_type Function_name(Formal Parameter list);
Example:
int sum(int a, int b);
or
int sum(int, int);
Points to note:
1. The parameter list must be separated by commas.
2. The parameter names do not need to be the same in the prototype declaration and the function definition.
3. The types must match the types of parameters in the function definition, in number and order.
4. Use of parameter names in the declaration is optional.
Function Parameter:
The parameters used in function declaration and function definition are called formal parameter and those used in function call is called actual parameter.
The formal and actual parameters must match exactly in type, order and number. Their names, however, do not need to match.
Examples: sum=add (a, b, c); // here a, b, c are called actual parameter.
int add(int x , int y, int z); // here x, y, z are formal parameter.
Function Return: Function can be organized into 2 types.
a) Function that has not a return value i.e. void function.
b) Function that has a returned value i.e. int function.
2. Function Call
A function can be called by simply using the function name followed by a list of actual parameters, if any, enclosed in parenthesis.
Static variables are created and initialized once, on the first call to the function. Subsequent calls to the function do not recreate or re-initialize the static variable.
Example:
c=sum (a,b);
3. Function Definition
The function definition is an independent program module that is specially written to implement the requirement of the function.
A function definition, also known as function implementation shall include the following elements.
a) Function type
b) Function Name
c) List of parameters
d) Local variable declarations
e) Function statements
f) A return statement
All the six elements are grouped into two parts, namely,
· Function Header(First three elements)
· Function Body ( Second three elements)
Syntax:
Function_type Function_Name(Formal Parameter list)
{
Local variable declaration;
Executable statement 1;
Executable statement 2;
………………….
………………….
return statement;
}
Note that a semicolon is not used at the end of the Function Header of Function definition.
second part:
Definition: A self –contained block of code that performs a particular task is called Function.
A function has 3 elements.
1. Function Declaration (Function Prototype)
2. Function Call
3. Function Definition
Additionally we can have return statement in function. Let's understand about them.
1. Function Declaration (Function Prototype)
A function declaration also known as Function Prototype consists of four parts. In some programs it is optional i.e. we can use function without declaration. Its major part are:
· Function type(return type)
· Function name
· Parameter list
· Terminating Semicolon
Syntax:
Function_type Function_name(Formal Parameter list);
Example:
int sum(int a, int b);
or
int sum(int, int);
Points to note:
1. The parameter list must be separated by commas.
2. The parameter names do not need to be the same in the prototype declaration and the function definition.
3. The types must match the types of parameters in the function definition, in number and order.
4. Use of parameter names in the declaration is optional.
Function Parameter:
The parameters used in function declaration and function definition are called formal parameter and those used in function call is called actual parameter.
The formal and actual parameters must match exactly in type, order and number. Their names, however, do not need to match.
Examples: sum=add (a, b, c); // here a, b, c are called actual parameter.
int add(int x , int y, int z); // here x, y, z are formal parameter.
Function Return: Function can be organized into 2 types.
a) Function that has not a return value i.e. void function.
b) Function that has a returned value i.e. int function.
2. Function Call
A function can be called by simply using the function name followed by a list of actual parameters, if any, enclosed in parenthesis.
Static variables are created and initialized once, on the first call to the function. Subsequent calls to the function do not recreate or re-initialize the static variable.
Example:
c=sum (a,b);
3. Function Definition
The function definition is an independent program module that is specially written to implement the requirement of the function.
A function definition, also known as function implementation shall include the following elements.
a) Function type
b) Function Name
c) List of parameters
d) Local variable declarations
e) Function statements
f) A return statement
All the six elements are grouped into two parts, namely,
· Function Header(First three elements)
· Function Body ( Second three elements)
Syntax:
Function_type Function_Name(Formal Parameter list)
{
Local variable declaration;
Executable statement 1;
Executable statement 2;
………………….
………………….
return statement;
}
Note that a semicolon is not used at the end of the Function Header of Function definition.
second part:
C Program to find area of pond using user defined function
#include <stdio.h>
int area(int l, int b);
int main()
{
int l,b,c;
printf("Enter length and breadth ");
scanf("%d%d",&l,&b);
c=area(l,b);
printf("Area of pond is %d",c);
return 0;
}
int area(int l,int b)
{
int ar;
ar=l*b;
return (ar);
}
2. What is 'while' loop statement. Write an algorithm and a C program to input a number and reverse it. [4+6]
Answer:
While Loop
The while loop executes a statement or a black of statements as long as a condition evaluates to true. The while loop is mainly used in situations where you don’t know in advance how many times the loop will be executed. The loop terminates when the condition evaluates to false.
Syntax of while loop
Initialization;
while (condition)
{
Statements;
……………………….
Increment/decrement;
}
The while loop must initialize variable before the loop begin. The condition consists inside while parenthesis. The increment/decrement performed inside the body of loop i.e., within braces.
Algorithm to reverse a number
Start
Declare the integer type variables n, rev , r
Input a number
Is n not equal to zero? If yes go to step 5, otherwise go to step 9
r= num%10
rev=rev*10+r
n=n/10
go to step 4
Display rev
Stop
second part:-
#include <stdio.h>
int area(int l, int b);
int main()
{
int l,b,c;
printf("Enter length and breadth ");
scanf("%d%d",&l,&b);
c=area(l,b);
printf("Area of pond is %d",c);
return 0;
}
int area(int l,int b)
{
int ar;
ar=l*b;
return (ar);
}
2. What is 'while' loop statement. Write an algorithm and a C program to input a number and reverse it. [4+6]
Answer:
While Loop
The while loop executes a statement or a black of statements as long as a condition evaluates to true. The while loop is mainly used in situations where you don’t know in advance how many times the loop will be executed. The loop terminates when the condition evaluates to false.
Syntax of while loop
Initialization;
while (condition)
{
Statements;
……………………….
Increment/decrement;
}
The while loop must initialize variable before the loop begin. The condition consists inside while parenthesis. The increment/decrement performed inside the body of loop i.e., within braces.
Algorithm to reverse a number
Start
Declare the integer type variables n, rev , r
Input a number
Is n not equal to zero? If yes go to step 5, otherwise go to step 9
r= num%10
rev=rev*10+r
n=n/10
go to step 4
Display rev
Stop
second part:-
C Program to reverse a number
#include <stdio.h>
int main()
{
int n,rev=0,r;
printf("Enter a number ");
scanf("%d",&n);
while(n!=0)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
printf("Reverse number is %d",rev);
return 0;
}
3. Define array. Write a program to input any 10 numbers in an array and display it. Find the biggest number among the input numbers. 2+4+4
Answer:
Definition: A composite variable capable of holding multiple data of same data type under a single variable name is called array.
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)
b) Two Dimensional Array (2-D)
second part:-
#include <stdio.h>
int main()
{
int n,rev=0,r;
printf("Enter a number ");
scanf("%d",&n);
while(n!=0)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
printf("Reverse number is %d",rev);
return 0;
}
3. Define array. Write a program to input any 10 numbers in an array and display it. Find the biggest number among the input numbers. 2+4+4
Answer:
Definition: A composite variable capable of holding multiple data of same data type under a single variable name is called array.
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)
b) Two Dimensional Array (2-D)
second part:-
/*C Code to display entered 10 numbers*/
#include <stdio.h>
int main()
{
int n[10],i,big;
for(i=0;i<10;i++)
{
printf("Enter %d number ",i+1);
scanf("%d",&n[i]);
}
#include <stdio.h>
int main()
{
int n[10],i,big;
for(i=0;i<10;i++)
{
printf("Enter %d number ",i+1);
scanf("%d",&n[i]);
}
printf("Entered numbers are : \n ");
for(i=0;i<10;i++)
{
printf("%d\t",n[i]);
}
big=n[0];
for(i=0;i<10;i++)
{
if(n[i]>big)
big=n[i];
}
printf("Biggest number is %d",big);
return 0;
}
4. What is structure? Write a program to input employee id, name, address and post of 20 employees and display them properly. 2+8
Answer:
Definition: The user defined data type which can store the data of various data types such as int, char etc. is called Structure.
It is used to hold all the facts of single objects.
Example: Book [publication, title, author, price, page];
Student [roll no, class, name, telephone no, age];
There are 3 phases in structure.
1. Design Phase
2. Declaration phase
3. Data access phase
for(i=0;i<10;i++)
{
printf("%d\t",n[i]);
}
big=n[0];
for(i=0;i<10;i++)
{
if(n[i]>big)
big=n[i];
}
printf("Biggest number is %d",big);
return 0;
}
4. What is structure? Write a program to input employee id, name, address and post of 20 employees and display them properly. 2+8
Answer:
Definition: The user defined data type which can store the data of various data types such as int, char etc. is called Structure.
It is used to hold all the facts of single objects.
Example: Book [publication, title, author, price, page];
Student [roll no, class, name, telephone no, age];
There are 3 phases in structure.
1. Design Phase
2. Declaration phase
3. Data access phase
syntax:
struct tag
{
data type member1;
data type member 2;
data type member 3;
}variables;
example:
struct student
{
char name[100];
int roll;
}var;
second part:-
/*C Program code to input employee id, name ,address and post of 20 employees and display them on monitor
*/
#include <stdio.h>
struct employee
{
int id;
char name[30],address[30],post[30];
}e[20];
int main()
{
int i;
for(i=0;i<20;i++)
{
e[i].id=i+1;
printf("Enter %d employee name, address and post ",i+1);
scanf("%s%s%s",e[i].name,e[i].address,e[i].post);
}
printf("Records of employees are : \n");
for(i=0;i<20;i++)
{
printf("%d\t %s\t %s\t %s\n",e[i].id,e[i].name,e[i].address,e[i].post);
}
return 0;
}
5. a) What is the importance of file pointer in file handling? Explain with an example. 5
Answer:
first part:-
A file pointer is used to identify a file for any file operations. If you didn’t have a file pointer then the operations to read, write, or even close a file wouldn’t know what file to close. The Operating System doesn’t keep track of filenames, pointers and such, at least not in any way that one can access a filename given a file pointer. That is for the program/programmer of which to keep track. So when a file is opened, a file pointer is returned (at least in C - in C++ that stuff is kept hidden behind the scenes). You use that file pointer for any operations on files after that point so the operation knows on which file to perform its operation. And all a file pointer is a number.
· To demonstrate this notice that in C, you have to manually put the * in - FILE *fp;
· it’s not there by default so FILE is just a structure and the FILE * is a pointer to that structure in memory.
· In languages like Basic and PHP and even assembly language, the file pointer is just literally a number to an open file.
*/
#include <stdio.h>
struct employee
{
int id;
char name[30],address[30],post[30];
}e[20];
int main()
{
int i;
for(i=0;i<20;i++)
{
e[i].id=i+1;
printf("Enter %d employee name, address and post ",i+1);
scanf("%s%s%s",e[i].name,e[i].address,e[i].post);
}
printf("Records of employees are : \n");
for(i=0;i<20;i++)
{
printf("%d\t %s\t %s\t %s\n",e[i].id,e[i].name,e[i].address,e[i].post);
}
return 0;
}
5. a) What is the importance of file pointer in file handling? Explain with an example. 5
Answer:
first part:-
A file pointer is used to identify a file for any file operations. If you didn’t have a file pointer then the operations to read, write, or even close a file wouldn’t know what file to close. The Operating System doesn’t keep track of filenames, pointers and such, at least not in any way that one can access a filename given a file pointer. That is for the program/programmer of which to keep track. So when a file is opened, a file pointer is returned (at least in C - in C++ that stuff is kept hidden behind the scenes). You use that file pointer for any operations on files after that point so the operation knows on which file to perform its operation. And all a file pointer is a number.
· To demonstrate this notice that in C, you have to manually put the * in - FILE *fp;
· it’s not there by default so FILE is just a structure and the FILE * is a pointer to that structure in memory.
· In languages like Basic and PHP and even assembly language, the file pointer is just literally a number to an open file.
second part:
/* Write a program to store name, department and age
to file names “employee.dat” .*/
#include<stdio.h>
int main()
{
FILE *fp;
char name[30],dept[30];
int age;
fp=fopen("employee.dat","a");
printf("Enter name, dept and age of employee");
scanf("%s%s%d",name,dept,&age);
fprintf(fp,"\n %s\t %s\t %d",name,dept,age);
return 0;
}
/* Write a program which reads name, department and age
from a file names “employee.dat” and display them on monitor.*/
#include<stdio.h>
int main()
{
FILE *fp;
char name[30],dept[30];
int age;
fp=fopen("employee.dat","r");
while(fscanf(fp," %s %s %d",name,dept,&age)!=EOF)
{
printf("\n %s\t %s\t %d",name,dept,age);
}
return 0;
}
b) Explain any two string functions with examples. 5
Answer:
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.
Group 'B'
(Short answer questions)
Attempt any seven questions: 7x5=35
6. Define SDLC. Describe the feasibility analysis methods. 2+3
(Short answer questions)
Attempt any seven questions: 7x5=35
6. Define SDLC. Describe the feasibility analysis methods. 2+3
Ans:-
Feasibility study:-
It is the measure and the study of how beneficial the development of the system would be to the organization. This is known as feasibility study. The aim of the feasibility study is to understand the problem and to determine whether it is worth proceeding.
It has following types.
It has following types.
1.Technical feasibility: - This is concerned with availability of hardware and software required for the development of system.The issues with can be like:
1.1) Is the proposed technology proven and practical?
1.2)the next question is: does the firm possess the necessary technology it needs. Here we have to ensure that the required technology is practical and available. Now, does it have required hardware and software?
1.3)The Last issue is related to availability of technical expertise. In this case, software and hardware are available but it may be difficult to find skilled manpower.
2.Operational feasibility:- It is all about problems that may arise during operations. There are two aspects related with this issue:
2.1) what is the probability that the solution developed may not be put to use or may not work?
2.1) what is the inclination of management and end users towards solutions?
Besides these all some more issues;
a) Information: saying to provide adequate, timely, accurate and useful information to all categories of users.
b) Response time, it says about response about output in very fast time to users.
c) Accuracy: A software system must operate accurately. It means, it should provide value to its users. It says degree of software performance.
d) Services:- The system should be able to provide reliable services.
e)Security:- there should be adequate security to information and data from frauds.
f) Efficiency: The system needs to be able to provide desirable services to users.
3) Economic feasibility: - It is the measure of cost effectiveness of the project. The economic feasibility is nothing but judging whether the possible benefit of solving the problem is worthwhile or not. Under "cost benefit analysis", there are mainly two types of costs namely, cost of human resources and cost of training.
The first one says about salaries of system analysts, software engineers, programmers, data entry operators etc. whereas 2nd one says about training to be given to new staffs about how to operate a newly arrived system.
4) Legal feasibility: - It is the study about issues arising out the need to the development of the system. The possible consideration might include copyright law, labor law, antitrust legislation, foreign trade etc.
Apart from these all we have some more types:
behaviour feasibility, schedule feasibility study etc.
7. Explain the different types of data integrity in DBMS. 5Ans:-
Database integrity:
It 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 concerns the concept of a foreign key. The referential integrity rule states that any foreign key value can only be in one of two states. The usual state of affairs is that the foreign key value refers to a primary key value of some table in the database. Occasionally, and this will depend on the rules of the business, a foreign key value can be null. In this case we are explicitly saying that either there is no relationship between the objects represented in the database or that this relationship is unknown.
Or
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. What is SQL? Describe the DML with an example. 2+3Ans:-
SQL:
SQL stands for Structured Query Language; it is the most common language for extracting and organising data that is stored in a relational database. A database is a table that consists of rows and columns. SQL is the language of databases. It facilitates retrieving specific information from databases that are further used for analysis. Even when the analysis is being done on another platform like Python or R, SQL would be needed to extract the data that you need from a company’s database.
It is used for:
- Execute queries against a database
- Retrieve data from a database
- Insert records into a database
- Update records in a database
- Delete records from a database
ans:-
A data manipulation language (DML) is a computer programming language used for adding (inserting), deleting, and modifying (updating) data in a database. ... A popular data manipulation language is that of Structured Query Language (SQL), which is used to retrieve and manipulate data in a relational database.It uses statements select,from,where etc.
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"
9. Define network topology. Explain the Ring Topology. 2+3
Ans:-
Network topology:
Network topology is the arrangement of the elements of a communication network. Network topology can be used to define or describe the arrangement of various types of telecommunication networks, including command and control radio networks, industrial fieldbusses and computer networks.
Basically, ring topology is divided into the two types which are Bidirectional and Unidirectional. Most Ring Topologies allow packets to only move in one direction, known as a one-way unidirectional ring network. Others allow data to go, either way, called bidirectional.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.
10.Describe the wireless network system. List out deices and equipment necessary for Wi-Fi network. 3+2
Ans:-
wireless network:
A communications system that transmits and receives radio signals over the air. The term generally refers to Wi-Fi local area networks (LANs) or to the 3G/4G data services from the cellular carriers' wide area networks (WANs). Access points amplify Wi-Fi signals, so a device can be far from a router but still be connected to the network. When you connect to a Wi-Fi hotspot at a cafe, a hotel, an airport lounge, or another public place, you're connecting to that business's wireless network.
Devices for wi-fi network:-
The key hardware components of a wireless computer network include
- adapters,
- routers and access points,
- antennas,
- repeaters
- switch
- POE injector
11. Describe the different operator types in C program. 5
Ans:-
operator:- It is a symbol or a character used in programming. It is used to carry out some operation.
for example: +,-,= etc
It is of following types.
1)Arithmetic operator: It is used to do arithmetic calculations/operation.
It has following types.
+ -----------> used for addition.example is a+b. It means we are performing addition with the help of operand a and b
- ------------>It is used for subtraction.Example is a-b. It means we are performing subtraction with the help of operand a and b
* -------------------->used for multiplication.example is a*b. It means we are performing multiplication with the help of operand a and b
/---------------->used for division.example is a/b. It means we are performing division with the help of operand a and b
for example: +,-,= etc
It is of following types.
1)Arithmetic operator: It is used to do arithmetic calculations/operation.
It has following types.
+ -----------> used for addition.example is a+b. It means we are performing addition with the help of operand a and b
- ------------>It is used for subtraction.Example is a-b. It means we are performing subtraction with the help of operand a and b
* -------------------->used for multiplication.example is a*b. It means we are performing multiplication with the help of operand a and b
/---------------->used for division.example is a/b. It means we are performing division with the help of operand a and b
%---------------->used for remainder division.example is a%b. It means we are performing division with the help of operand a and b.It gives us remainder after division.
2)relational operator:
This operator is used to perform comparisons between variables.It supports us to take decision logically. example,x>y ,x>=y etc
Relational operator has following types.
>------> It is used to show greater than. like x>y
>=----->It is used to show greater than or equals to.like x>=y
<-------->It is used to show a variable is smaller than another.like x<y
<=-------> It is used to show smaller than or equals to with another variable.Like x<=y
!=----------> I simply says , two variables are not equal in value.like x!=y
==---------->It says two variables have same value.It is used to test values of two variables.
3)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.
4) Assignment operator:
an operator ,symbolized by '=' character,is called assignment operator.It assigns value to variable.
example:
int a=6;
It means, we are assignming value 6 to variable a.
5)Unary operator:- this operator works on one operand only.It has two types.
I) increment operator:- It increases the value of given variable by one.For example: ++y or y++
It can be classified into pre-increment and post increment.
pre-increment:- It is written as ++x.It means first increase the value and then use that.
post-increment: It is written as x++.It means, first use that and then increase its value by one.
II)decrement operator:- It decreases the value of given variable by one.For example: --y or y--
It can be classified into pre-decrement and post decrement.
pre-decrement:- It is written as --x.It means first decrease the value and then use that.
post-decrement: It is written as x--.It means, first use that and then decrease its value by one.
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.
4) Assignment operator:
an operator ,symbolized by '=' character,is called assignment operator.It assigns value to variable.
example:
int a=6;
It means, we are assignming value 6 to variable a.
5)Unary operator:- this operator works on one operand only.It has two types.
I) increment operator:- It increases the value of given variable by one.For example: ++y or y++
It can be classified into pre-increment and post increment.
pre-increment:- It is written as ++x.It means first increase the value and then use that.
post-increment: It is written as x++.It means, first use that and then increase its value by one.
II)decrement operator:- It decreases the value of given variable by one.For example: --y or y--
It can be classified into pre-decrement and post decrement.
pre-decrement:- It is written as --x.It means first decrease the value and then use that.
post-decrement: It is written as x--.It means, first use that and then decrease its value by one.
Besides these all, we have some other operators .like bitwise,
12. Describe the different mode of the file handling concept in C. 2.5+2.5Ans:-
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:
13. Define cyber bullying. Suggest the possible solutions to remain safe from cyber crime. 5
- 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();
}
#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();
}
Ans:-
Cyber bullying:-
In today’s world which has been made smaller by technology, new age problems have been born. No doubt technology has a lot of benefits; however, it also comes with a negative side. It has given birth to cyberbullying. To put it simply, cyberbullying refers to the misuse of information technology with the intention to harass others.In other words, cyberbullying has become very common nowadays. It includes actions to manipulate, harass and defame any person. These hostile actions are seriously damaging and can affect anyone easily and gravely. They take place on social media, public forums, and other online information websites. A cyberbully is not necessarily a stranger; it may also be someone you know.
Possible solutions:
- Children should not respond to the bully.
- Never leave your social media accounts, email accounts, etc. open while browsing on public computers
- Contact legal authorities whenever they come to know about such incidents.
- Never click on links or open files that are sent by unknown users.
- Use parental control software
etc
14. What are the roles of AI in our real life? List out AI related systems in our spciety. 1+4
Ans:-
Roles of 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.
Some AI related system in our society:
- Artificial Intelligence Influences Business
- Life-Saving AI
- Entertaining AI
- e-mail communications
- self driving cars and buses
- Navigation
- web searching
15. Write short notes on : 2.5+2.5
a) Primary Key b) IP address
a) Primary Key b) IP address
Ans:-
Primary key:
A primary key is a special relational database table column (or combination of columns) designated to uniquely identify each table record.
A primary key is used as a unique identifier to quickly parse data within the table. A table cannot have more than one primary key.
A primary key’s main features are:
A primary key might use one or more fields already present in the underlying data model, or a specific extra field can be created to be the primary key.
e.g.
A primary key is used as a unique identifier to quickly parse data within the table. A table cannot have more than one primary key.
A primary key’s main features are:
- It must contain a unique value for each row of data.
- It cannot contain null values.
- Every row must have a primary key value.
A primary key might use one or more fields already present in the underlying data model, or a specific extra field can be created to be the primary key.
e.g.
Here, in this table, we can see that name and grade can be same but id can be different.So id is primary key.
IP address:-
IP address stands for internet protocol address; it is an identifying number that is associated with a specific computer or computer network. When connected to the internet, the IP address allows the computers to send and receive information.Internet Protocol version 4 (IPv4) defines an IP address as a 32-bit number. However, because of the growth of the Internet and the depletion of available IPv4 addresses, a new version of IP (IPv6), using 128 bits for the IP address, was standardized in 1998.
An IP address allows computers to send and receive data over the internet. Most IP addresses are purely numerical, but as internet usage grows, letters have been added to some addresses.
There are four different types of IP addresses: public, private, static, and dynamic. While the public and private are indicative of the location of the network—private being used inside a network while the public is used outside of a network—static and dynamic indicate permanency.
functions:
1.It handles connection between devices
2.It handles the routing and addressing function at the Internet layer.
3.IP provides an unreliable, connectionless datagram delivery service.
4.IP is responsible for fragmentation.
THE END
source:
wikipedia.org
www.rogerclarke.com
https://plkcomputersir.blogspot.com/p/welcome.html
cisco.com
thank you
No comments:
Post a Comment