C Programming Question and Answers notes, Exams of Computer Science

This document includes notes of C programming

Typology: Exams

2018/2019

Uploaded on 04/30/2019

psmagar1234
psmagar1234 🇳🇵

5

(1)

3 documents

1 / 96

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60

Partial preview of the text

Download C Programming Question and Answers notes and more Exams Computer Science in PDF only on Docsity!

FUNDAMENTALS

OF

COMPILED BY PRABIN T.M.

Data and Database Management System In computing, data is information that has been translated into a form that is efficient for movement or processing. In general, data is any set of characters that has been gathered and translated for some purpose, usually analysis. It can be any character, including text and numbers, pictures, sound, or video. Data processing Data processing is simply the conversion of raw data to meaningful information through a process. Data is technically manipulated to produce results that lead to a resolution of a problem or improvement of an existing situation. Similar to a production process, it follows a cycle where inputs (raw data) are fed to a process (computer systems, software, etc.) to produce output (information and insights). Data processing occurs when data is collected and translated into usable information. Stages of the Data Processing Cycle:

  1. Collection is the first stage of the cycle, and is very crucial, since the quality of data collected will impact heavily on the output. The collection process needs to ensure that the data gathered are both defined and accurate, so that subsequent decisions based on the findings are valid. This stage provides both the baseline from which to measure, and a target on what to improve.
  2. Preparation is the manipulation of data into a form suitable for further analysis and processing. Raw data cannot be processed and must be checked for accuracy. Preparation is about constructing a data set from one or more data sources to be used for further exploration and processing. Analyzing data that has not been carefully screened for problems can produce highly misleading results that are heavily dependent on the quality of data prepared.
  3. Input is the task where verified data is coded or converted into machine readable form so that it can be processed through an application. Data entry is done through the use of a keyboard, scanner, or data entry from an existing source. This time-consuming process requires speed and accuracy. Most data need to follow a formal and strict syntax since a great deal of processing power is required to breakdown the complex data at this stage. Due to the costs, many businesses are resorting to outsource this stage.
  4. Processing is when the data is subjected to various means and methods of powerful technical manipulations using Machine Learning and Artificial Intelligence algorithms to generate an output or interpretation about the data. The process may be made up of multiple threads of execution that simultaneously execute instructions, depending on the type of data. There are applications like Anvesh available for processing large volumes of heterogeneous data within very short periods.
  5. Output and interpretation is the stage where processed information is now transmitted and displayed to the user. Output is presented to users in various report formats like graphical reports,

This method of processing data is very fast and accurate. For example, in a computerized education environment results of students are prepared through computer; in banks, accounts of customers are maintained (or processed) through computers etc. Types of data processing on basis of process/steps performed BATCH PROCESSING To save computational time, before the widespread use of distributed systems architecture, or even after it, stand-alone computer systems apply batch processing techniques. This is particularly useful in financial applications or where data was secure such as medical records. Batch processing completes a range of data processes as a batch, by simplifying single commands to provide actions to multiple data sets. This is a little like the comparison of a computer spreadsheet to a calculator in some ways. A calculation can be applied with one function that is one step, to a whole column or series of columns, giving multiple results from one action. The same concept is achieved in batch processing for data. A series of actions or results can be achieved by applying a function to a whole series of data. In this way, the computer processing time is far less. Batch processing can complete a queue of tasks without human intervention, and data systems may program priorities to certain functions or set times when batch processing can be completed. Banks typically use this process to execute transactions after the close of business, where computers are no longer involved in data capture and can be dedicated to processing functions. REAL TIME DATA PROCESSING For commercial uses, many large data processing applications require real-time processing. That is they need to get results from data exactly as it happens. One application of this that most of us can identify with is tracking stock market and currency trends. The data needs to be updated immediately since investors buy in real time and prices update by the minute. Data on airline schedules and ticketing and GPS tracking applications in transport services have similar needs for real-time updates. The most common technology used in real time processing is stream processing. The data analytics are drawn directly from the stream, that is, at the source. Where data is used to draw conclusions without uploading and transforming, the process is much quicker. Data virtualization techniques are another important development in real-time data processing, where the data remains in its source form, the only information is pulled for the data processing. The beauty of data virtualization is that where transformation is not necessary, so the error is reduced. Data virtualization and stream processing mean that data analytics can be drawn in real time much quicker, benefiting many technical and financial applications, reducing processing times and errors.

Other than these popular Data processing Techniques there are three more processing techniques which are mentioned below- ONLINE PROCESSING This data processing technique is derived from Automatic data processing. This technique is now known as immediate or irregular access handling. Under this technique, the activity by the framework is prepared at the time of operation/processing. This can be viewed easily with continuous preparing of data sets. This processing method highlights the fast contribution of exchange of data and connects directly with the databases. MULTI PROCESSING This is the most commonly used data processing technique. However, it is used all over the globe where we have the computer- based setups for Data capture and processing. As the name suggests – Multiprocessing is not bound to one single CPU, with this, it has a collection of several CPU’s. As the various set of processing devices are included in this method, therefore the outcome efficiency is very useful. The jobs are broken into frames and then sent to the multiprocessors for processing. The result obtained is expected to be in less time and the output is increased. The additional benefit is every processing unit is independent thus failure of any will not impact the working of other processing units. TIME SHARING This kind of Data processing is entirely based on Time. In this, one unit of processing data is used by several users. Each user is allocated with the set timings on which they need to work on the same CPU/processing Unit. Intervals are divided into segments and thus to users so there is no collapse of timings which makes it as a multi-access system. This processing technique is also widely used and mostly entertained in startups. Database Database refers to a collection of electronic records that could be processed to produce useful information. The data can be accessed, modified, managed, controlled and organized to perform various data-processing operations. Database is a collection of inter-related data which helps in efficient retrieval, insertion and deletion of data from database and organizes the data in the form of tables, views, schemas, reports etc. For Example, university database organizes the data about students, faculty, and admin staff etc. which helps in efficient retrieval, insertion and deletion of data from it.

A database management system (DBMS) is system software for creating and managing databases. A database management system (DBMS) is a software package designed to define, manipulate, retrieve and manage data in a database. A DBMS generally manipulates the data itself, the data format, field names, record structure and file structure. It also defines rules to validate and manipulate this data. A DBMS relieves users of framing programs for data maintenance. Some other DBMS examples include: MySQL, SQL Server, Oracle, dBASE, FoxPro etc. Types of Database Model

1. Hierarchical Database Model A hierarchical model represents the data in a tree-like structure in which there is a single parent for each record. To maintain order there is a sort field which keeps sibling nodes into a recorded manner. These types of models are designed basically for the early mainframe database management systems, like the Information Management System (IMS) by IBM. This model structure allows the one-to-one and a one-to-many relationship between two/ various types of data. This structure is very helpful in describing many relationships in the real world; table of contents, any nested and sorted information. In hierarchical model, data is organized into tree-like structure with one one-to-many relationship between two different types of data, for example, one department can have many courses, many professors and of course many students. Advantages:  The relationship between various layers is logically simple.  This system provides a tough database security.  Hierarchical database system maintains data independence i.e. if a data is altered in one table; it does not affect the other location.  There is always a parent-child relationship and data integrity is maintained.  For a large volume of data and 1: M relationship, it is very efficient model.

Disadvantages:  The physical implementation of the database is complicated.  Alternation in database structure is difficult to manage.  Structural independence exists when changes in the database structure do not affect the DBMS.  Application programming use complexity which many exist in many cases.  Implementation limitations due to the incapability of managing the relation such as M: N.  It lacks in DDL and DML standard of commands.

2. Network Database Model This is an extension of the Hierarchical model. In this model data is organized more like a graph, and are allowed to have more than one parent node. In this database model data is more related as more relationships are established in this database model. Also, as the data is more related, hence accessing the data is also easier and fast. This database model was used to map many-to-many data relationships. This was the most widely used database model, before Relational Model was introduced. In many aspects, the network database model resembles the hierarchical database model. It also uses the same principle of 1: M relationship. However, quite unlike the hierarchical model, the network model allows a record to have more than one parent. Therefore, the commonly encountered relationships can be handled easily by the network database model. Advantages:  The database is conceptually simple in structure.  It can handle more relationships types.  It has data access flexibility such as accessing its own record and all the member records in the set.  Promotes database integrity since owner record and member records are defined precisely.  Changes in the data integrity since owner record and member records are defined precisely.  Changes in the data do not require a change in access methods which is the benefit of data independence.  It confirms the standards such as DDL (Data Definition Language) and DML. Disadvantages:  Since, the system is complex the system navigators, database administrators, programmer and end users must be very familiar with the internal structure in order to access the database.  Lack of structural independence.  Although, the network mode achieves data independence, it still does not produce structural independence. 3. Relational Database Model

In this database model, relationships are created by dividing object of interest into entity and its characteristics into attributes. Different entities are related using relationships. E-R Models are defined to represent the relationships into pictorial form to make it easier for different stakeholders to understand. This model is good to design a database, which can then be turned into tables in relational model (explained below). Let's take an example, if we have to design a School Database, then Student will be an entity with attributes name, age, address etc. As Address is generally complex, it can be another entity with attributes street name, pincode, city etc., and there will be a relationship between them. Relationships can also be of different types. To learn about E-R Diagrams in details, click on the link. Advantages:  It yields a particularly easily viewed and understood conceptual view of database’s main entities and their relationships.  The ERM gives the designers visual representation very clearly.  The ERM has become one of significant effective communication tools in RDBMS.  The ERM is well integrated with the relational database model. Disadvantages:  Limited constraint representation due to limited model.  The relationship between attributes within entities cannot be represented. Example, there is no way of completed hours and classification of a student.  It lacks in data manipulation language or commands.  The models become crowded due to more presence of entities. DBMS was designed to solve the fundamental problems associated with storing, managing, accessing, securing and auditing data in traditional file systems. Traditional database applications were developed on top of the databases, which led to challenges such as data redundancy, isolation, integrity constraints and difficulty in managing data access. A layer of abstraction was required between users or apps and the databases at a physical and logical level. By introducing a technology solution to manage databases in the form of DBMS software, the following key benefits are realized:  Data Security: DBMS allows organizations to enforce policies that enable compliance and security. The databases are available for appropriate users as per organizational policies. The DBMS system is also responsible to maintain optimum performance of querying operations while ensuring the validity, security and consistency of data items updated to a database.  Data Sharing: Fast and efficient collaboration between users.

Data Access and Auditing: Controlled access to databases. Logging associated access activities allows organizations to audit for security and compliance.  Data Integration: Instead of operating island of database resources, a single interface is used to manage databases with logical and physical relationships.  Abstraction and Independence: Organizations can change the physical schema of database systems without necessitating changes to the logical schema that govern database relationships. As a result, organizations can upgrade storage and scale the infrastructure without impacting database operations. Similarly, changes to the logical schema can be applied without altering the apps and services that access the databases.  Uniform Management and Administration: A single console interface to perform basic administrative tasks makes the job easier for database admins and IT users.  Minimized data inconsistency: Data inconsistency exists when different versions of the same data appear in different places. For example, data inconsistency exists when a company’s sales department stores a sales representative’s name as “Bill Brown” and the company’s personnel department stores that same person’s name as “William G. Brown,” or when the company’s regional sales office shows the price of a product as $45.95 and its national sales office shows the same product’s price as $43.95. The probability of data inconsistency is greatly reduced in a properly designed database.  Improved data access : The DBMS makes it possible to produce quick answers to ad hoc queries. From a database perspective, a query is a specific request issued to the DBMS for data manipulation—for example, to read or update the data. Simply put, a query is a question, and an ad hoc query is a spur-of-the-moment question. The DBMS sends back an answer (called the query result set) to the application. For example, end users, when dealing with large amounts of sales data, might want quick answers to questions (ad hoc queries).  Improved decision making: Better-managed data and improved data access make it possible to generate better-quality information, on which better decisions are based. The quality of the information generated depends on the quality of the underlying data. Data quality is a comprehensive approach to promoting the accuracy, validity, and timeliness of the data. While the DBMS does not guarantee data quality, it provides a framework to facilitate data quality initiatives.  Increased end-user productivity: The availability of data, combined with the tools that transform data into usable information, empowers end users to make quick, informed decisions that can make the difference between success and failure in the global economy. Disadvantages of Database Management System (DBMS): Although the database system yields considerable advantages over previous data management approaches, database systems do carry significant disadvantages. For example:  Increased costs: One of the disadvantages of DBMS is Database systems require sophisticated hardware and software and highly skilled personnel. The cost of maintaining the hardware,

SQL code is divided into four main categories:  Queries are performed using the ubiquitous yet familiar SELECT statement, which is further divided into clauses, including SELECT, FROM, WHERE and ORDER BY.  Data Manipulation Language (DML) is used to add, update or delete data and is actually a SELECT statement subset and is comprised of the INSERT, DELETE and UPDATE statements, as well as control statements, e.g., BEGIN TRANSACTION, SAVEPOINT, COMMIT and ROLLBACK.  Data Definition Language (DDL) is used for managing tables and index structures. Examples of DDL statements include CREATE, ALTER, TRUNCATE and DROP.  Data Control Language (DCL) is used to assign and revoke database rights and permissions. Its main statements are GRANT and REVOKE. Applications of SQL (Structured Query Language) Have a look at some main SQL applications:  Data Integration Scripts : The main application of SQL is to write data integration scripts by the database administrators and developers.  Analytical Queries : The data analysts use structured query language for setting and running analytical queries on a regular basis.  Retrieve Information : Another popular application of this language is to retrieve the subsets of information within a database for analytics applications and transaction processing. The most commonly used SQL elements are select, insert, update, add, delete, create, truncate and alter.  Other Important Applications : The SQL is used for modification of the index structures and database table. Additionally, the users can add, update and delete the rows of the data by using this language. Advantages of SQL There are numerous advantages of Structured Query Language and some of them are mentioned below:  No coding needed : It is very easy to manage the database systems without any need to write the substantial amount of code by using the standard SQL.  Well defined standards : Long established are used by the SQL database that is being used by ISO and ANSI. There are no standards adhered by the non-SQL databases.  Portability : SQL can be used in the program in PCs, servers, laptops, and even some of the mobile phones.  Interactive Language : This domain language can be used for communicating with the databases and receive answers to the complex questions in seconds.

Multiple data views : With the help of SQL language, the users can make different views of database structure and databases for the different users. Disadvantages of SQL Along with some benefits, the structured query language also has some certain disadvantages:  Difficult Interface : SQL has a complex interface that makes it difficult for some users to access it.  Partial Control : The programmers who use SQL don’t have a full control over the database because of the hidden business rules.  Implementation : Some of the databases go to the proprietary extensions to standard SQL for ensuring the vendor lock-in.  Cost : The operating cost of some SQL versions makes it difficult for some programmers to access it. Database Architecture The design of a DBMS depends on its architecture. It can be centralized or decentralized or hierarchical. The architecture of a DBMS can be seen as either single tier or multi-tier. An n-tier architecture divides the whole system into related but independent n modules, which can be independently modified, altered, changed, or replaced. In 1-tier architecture, the DBMS is the only entity where the user directly sits on the DBMS and uses it. Any changes done here will directly be done on the DBMS itself. It does not provide handy tools for end-users. Database designers and programmers normally prefer to use single-tier architecture. If the architecture of DBMS is 2-tier, then it must have an application through which the DBMS can be accessed. Programmers use 2-tier architecture where they access the DBMS by means of an application. Here the application tier is entirely independent of the database in terms of operation, design, and programming. 3 - tier Architecture A 3-tier architecture separates its tiers from each other based on the complexity of the users and how they use the data present in the database. It is the most widely used architecture to design a DBMS.  Database (Data) Tier − At this tier, the database resides along with its query processing languages. We also have the relations that define the data and their constraints at this level.  Application (Middle) Tier − At this tier reside the application server and the programs that access the database. For a user, this application tier presents an abstracted view of the database. End-users are unaware of any existence of the database beyond the application. At the other end, the database tier is not aware of any other user beyond the application tier.

Addresses in the internet IP Address: The Internet Protocol Address (or IP Address) is a unique address that computing devices such as personal computers, tablets, and smartphones use to identify itself and communicate with other devices in the IP network. Any device connected to the IP network must have a unique IP address within the network. An IP address is analogous to a street address or telephone number in that it is used to uniquely identify an entity. There are two standards for IP addresses: IP Version 4 (IPv4) and IP Version 6 (IPv6). All computers with IP addresses have an IPv4 address, and many are starting to use the new IPv address system as well. Here's what these two address types mean:  IPv4 uses 32 binary bits to create a single unique address on the network. An IPv4 address is expressed by four numbers separated by dots. Each number is the decimal (base-10) representation for an eight-digit binary (base-2) number, also called an octet. For example: 216.27.61.  IPv6 uses 128 binary bits to create a single unique address on the network. An IPv6 address is expressed by eight groups of hexadecimal (base-16) numbers separated by colons, as in 2001:cdba:0000:0000:0000:0000:3257:9652. Groups of numbers that contain all zeros are often omitted to save space, leaving a colon separator to mark the gap (as in 2001:cdba::3257:9652). Domain Name: A domain name is an Internet resource name that is universally understood by Web servers and online organizations and provides all pertinent destination information. To access an organization’s Web-based services, website users must know the precise domain name. A domain name locates an organization or other entity on the Internet. For example, the domain name: www.totalbaseball.com Internet Services Internet Services allows us to access huge amount of information such as text, graphics, sound and software over the internet. Following diagram shows the four different categories of Internet Services. Communication Services: There are various Communication Services available that offer exchange of information with individuals or groups. The following table gives a brief introduction to these services:

S.N. Service Description 1 Electronic Mail Used to send electronic message over the internet. 2 Telnet Used to log on to a remote computer that is attached to internet. 3 Newsgroup Offers a forum for people to discuss topics of common interests. 4 Internet Relay Chat (IRC) Allows the people from all over the world to communicate in real time. 5 Mailing Lists Used to organize group of internet users to share common information through e-mail. 6 Internet Telephony (VoIP) Allows the internet users to talk across internet to any PC equipped to receive the call. 7 Instant Messaging Offers real time chat between individuals and group of people. Eg. Yahoo messenger, MSN messenger. Information Retrieval Services: There exist several Information retrieval services offering easy access to information present on the internet. The following table gives a brief introduction to these services: S.N. Service Description 1 File Transfer Protocol (FTP) Enable the users to transfer files. 2 Archie It’s updated database of public FTP sites and their content. It helps to search a file by its name. 3 Gopher Used to search, retrieve, and display documents on remote sites. 4 Very Easy Rodent Oriented Netwide Index to Computer Achieved (VERONICA) VERONICA is gopher based resource. It allows access to the information resource stored on gopher’s servers. Web Services: Web services allow exchange of information between applications on the web. Using web services, applications can easily interact with each other. The web services are offered using concept of Utility Computing. World Wide Web (WWW): WWW is also known as W3. It offers a way to access documents spread over the several servers over the internet. These documents may contain texts, graphics, audio, video, hyperlinks. The hyperlinks allow the users to navigate between the documents. Video Conferencing: Video conferencing or Video teleconferencing is a method of communicating by two-way video and audio transmission with help of telecommunication technologies.

A broader definition comes from the World Wide Web Consortium (W3C): "The World Wide Web is the universe of network-accessible information, an embodiment of human knowledge." The World Wide Web , also known as the WWW and the Web, is an information space where documents and other web resources are identified by Uniform Resource Locators (URLs), interlinked by hypertext links, and accessible via the Internet. Tim Berners-Lee is the inventor of the Web and the director of the W3C, the organization that oversees its development. Berners-Lee developed hypertext, the method of instant cross- referencing that supports communications on the Web, making it easy to link content on one web page to content located elsewhere. The introduction of hypertext revolutionized the way people used the internet. In 1989, Berners-Lee began work on the first World Wide Web server at CERN. He called the server "httpd” and dubbed the first client "WWW.” Originally, WWW was just a WYSIWYG hypertext browser/editor that ran in the NeXTStep environment. The World Wide Web has been widely available since 1991. The Internet & the World Wide Web (the Web), though used interchangeably, are not synonymous. Internet is the hardware part - it is a collection of computer networks connected through either copper wires, fiber-optic cables or wireless connections whereas, the World Wide Web can be termed as the software part – it is a collection of web pages connected through hyperlinks and URLs. In short, the World Wide Web is one of the services provided by the Internet. Other services over the Internet include e-mail, chat and file transfer services. All of these services can be provided to consumers for use by businesses or government or by individuals creating their own networks or platforms. Another method to differentiate between both is using the Protocol Suite – a collection of laws & regulations that govern the Internet. While internet is governed by the Internet Protocol – specifically dealing with data as whole and their transmission in packets, the World Wide Web is governed by the Hyper Text Transfer Protocol (HTTP) that deals with the linking of files, documents and other resources of the World Wide Web. Intranet An intranet is a private enterprise network, designed to support an organization’s employees to communicate, collaborate and perform their roles. It serves a broad range of purposes and uses, but at its core, an intranet is there to help employees. An intranet is a private network accessible only to an organization's staff. Often, a wide range of information and services are available on an organization's internal intranet that is unavailable to the public, unlike the Internet. What are intranets used for?Accessing information: with a content management system (CMS) and frequently integrated with an organization’s document management system (DMS), intranets can be used to

centrally host and access documents, policies and information employees require to perform their roles.  Connecting people: globalized organizations and those with employees working remotely or across a range of office locations face challenges connecting their staff. An intranet helps colleagues find one another, connect, and communicate.  Knowledge management: alongside formal information and documents, organizations typically hold vast levels of knowledge amongst their employees. Through forums, discussion areas, idea boards and team areas, employees can ask questions or tap into the knowledge of their peers via an intranet – and best of all, that knowledge is captured and retained by the business on a searchable platform, even after that individual leaves the organization.  Completing tasks or workflows: combining forms or transactional applications with hosted information, intranets enable employees to self-serve and complete common processes- such as booking a leave of absence, submitting expenses, or undertaking internal training, all through their intranet.  Internal communications: through social and communication tools such as blogs, wikis, forums and discussions, an intranet can be used to facilitate effective two-way internal communications between management and staff.  Supporting strategic business objectives: intranets can play an active role in support high- level business objectives such as building, embedding and communicating a common culture, improving employee engagement or improving staff retention rates. Difference between Internet and Intranet Internet Intranet What is Worldwide system of connected networks. Each network consist millions of devices like computers, servers, routers, printers and many other devices. A private network, within an Enterprise or Organization. Users Unlimited Limited Accessible to Everyone Authorized users Identified by Unique IP address among all the computers in the world. Also identified by IP address, this is unique among all the computers in that particular intranet. Safety Not safe as intranet because anyone can access it and share anything. More safe because only authorized users can share information. Owned by No one owns the internet Can be owned by a organization, company or enterprise. Network Type Public Private Traffic Large traffic Less traffic Connection provided by Collection of LAN, WAN, MAN LAN, WAN