Showing posts with label Programming in C Notes Class9 Computer Engineering CDC. Show all posts
Showing posts with label Programming in C Notes Class9 Computer Engineering CDC. Show all posts

April 08, 2025

Programming in C Fundamentals


Unit-1 INTRODUCTION


Procedural programming:

A computer programming language that executes a set of commands in order is called procedural Language. It is written as a list of instructions, telling the computer, step-by-step, what to do .POP follows top down approach and is fine for small project.

Limitation of Procedural Language · 

  1. It focus on process rather than data.

  2. Data moves freely around the system hence no security to data .

  3. Maintaining and enhancing program code is difficult because global data.

  4. In large program it is difficult to identify which data is used for which function.

  5. Global variable overcome the local variable.

  6. Reusability and inheritance of code is not possible.


Introduction to OOP

OOPs stands Object Oriented Programming. It is a programming method in which focus is given on data rather than its process. It combined data and function into a single object/Unit and those object can communicate with each other by calling their member function. OOPs gives focus on “what” rather than “how”. For example C++, VB, JAVA….Etc.


Main features of OOPs

a. Object 

b. Class 

c. Data Abstraction 

d.  Data Encapsulation 

e. Inheritance 

f. Polymorphism


  1. Object Object is an entity, things or any name that exists on the real world. 

  2. Class Class is the collection of objects. It is also known as blue print of an object. 

  3. Data Abstraction Data abstraction refers to the conceptual boundaries of an object.

  4. Data Encapsulation Data Encapsulation is a method or way of organizing data into a single unit

  5. Inheritance Inheritance is the ability of a class to acquire the properties of another class.

  6. Polymorphism Polymorphism refers to the ability of an object to take different forms dependenting upon the situation.

Advantages of OOPs

1 It follows bottom-up approach hence it is very easy for managing complex problem. 

2 It takes less time for developing the software. 

3. It reduces the data redundancy or duplication. 

4. Reusability and inheritance are possible. 

5. It takes less time for testing and maintaining.

 6. It can solve real world problem


Disadvantages of OOPs 

1. It requires greater processing. 

2. It requires high skilled man-power. 







Differentiate between Procedural/Structure Programming Language (C) and Object Oriented Programming Language (C++) .




UNIT-2 C++ Basic Input/Output Library


I/O Library Header Files: 

There are following header files important to C++ programs

  1. <iostream>

This file defines the cin, cout, cerr and clog objects, which correspond to the standard input stream, the standard output stream, the un-buffered standard error stream and the buffered standard error stream, respectively.

  1. <iomanip>

This file declares services useful for performing formatted I/O with so-called parameterized stream manipulators, such as setw() and setprecision().

  1. <fstream>

This file declares services for user-controlled file processing. 


The Standard Output Stream (cout)

The predefined object cout is an instance of ostream class. The cout is used in conjunction with the stream insertion operator, which is written as << .

For example:

#include<iostream.h>

#include<conio.h>

 void  main() 

 { 

char str[] = "Hello C++"; 

cout << "Value of str is : " << str << endl; 

getch();

}

The Standard Input Stream (cin)

The predefined object cin is an instance of istream class. The cin is used in conjunction with the stream extraction operator, which is written as >>.

For example:

#include<iostream.h>

#include<conio.h>

void main()

{

char name[50]; 

cout << "Please enter your name: "; 

cin >> name; 

cout << "Your name is: " << name << endl;

getch();


}



C++ Error Handling Functions

Following table lists these error handling functions and their meaning:





UNIT-3 Objects and Classes

Classes:

In OOP, we can define class name to represent its individual objects. Defining a class in programming language means creating user defined data type and it behaves like the built-in data types. Once a class has been defined, we can create any number of objects of that class.

Objects:

An object is an instance of class. A class is a description of a group of objects with common behavior, properties and relationships

Difference between Structure and Classes

Structure 

Class

  • Object is create in the Stack memory.

  • Objects are created in the Heap memory.

  • Does not support Inheritance.

  • It supports the concept of Inheritance.

  • By default the members are public .

  • By default the members are private.

  • Keyword used is struct.

  • Keyword use class.

  • It occupies less space.

  • Syntax:

       struct structure_name

        {

              Data_member;

        };

  • It occupies much space.

  • Syntax:

       class  class_name

         {

                data_member;

                member_function;

         };








Accessing members of structures: 

A structure member can be accessed by using period or dot (i.e. ".") operator. The syntax for accessing member of a structure variable is as follows:

syntax:

Structure_variable.member 

Here, structure_variable refers to the name of a structure-type variable and member refers to the name of a member within the structure.

/* C++ Access Structure Member */  


#include<iostream.h> 

#include<conio.h>  

struct st {

 int a;    // structure member 

int b;    // structure member 

int sum;  // structure member

 }st_var;  // structure variable  

void main()

 {

 clrscr(); 

 cout<<"Enter any two number:\n"; 

// accessing structure member a and b  

cin>>st_var.a>>st_var.b; 

 // accessing structure member sum, a, and b 

st_var.sum = st_var.a + st_var.b;  

// accessing structure member sum 

cout<<"\nSum of the two number is "<<st_var.sum;  

getch(); 

}

Output:

Enter any two numbers.

2

3

Sum of the two number is 5


Simple class construction/ Declaration of Class 

A class is used to specify blue print of similar objects and it combines data and methods for manipulating that data. The data and functions within a class are called members of the class.

For example:

Class class_name 

{

  private:   Variable declaration;  

  Function declaration; 

  public:   Variable declaration;  

  Function declaration;  

  protected:  Variable declaration;   

  Function declaration; 

}; 

Here, class is a C++ keyword; class _name is name of class defined by user. The body of class is enclosed within braces and terminated by a semicolon. The class body contains the declaration of variables and functions. These function and variables are collectively called as members. The keyword private and public are known as visibility labels. Private members can be accessed by function defined within the class and public members can be accessed by any function even outside the class. By default the members of class are private.



Accessing data members and member functions of class:

1.  Accessing Data Members of Class 

Accessing a data member depends  on the access control of that data member. If its public, then the data member can be easily accessed using the direct member access (.) operator with the object of that class. If, the data member is defined as private or protected, then we cannot access the data variables directly.

Example:

class student{

public:

int roll;

string name;

};

void main{

student s;

s.roll=1;

s.name=“samira”;

cout<<“Name and roll no of s is :”<<s.name<<s.roll;

getch();

}


Member Functions in Classes 

Member functions are the functions, which have their declaration inside the class definition and works on the data members of the class. The definition of member functions can be inside or outside the definition of class. 

If the member function is defined inside the class definition it can be defined directly, but if its defined outside the class, then we have to use the scope resolution: operator along with class name along with function name. 

Example:

class Cube{

public: 

int side;

int getVolume();

};

If we define the function inside class then we don't not need to declare it first, we can directly define the function. 

class Cube 

{

  public: 

int side;  

int getVolume() 

{  

return side*side*side;       //returns volume of cube 

}

 }; 

But if we plan to define the member function outside the class definition then we must declare the function inside class definition and then define it outside. 

class Cube

 {

  public: 

int side;

int getVolume(); 

  };

int Cube :: getVolume()     // defined outside class definition 

{  

return side*side*side; 

The main function for both the function definition will be same . Inside main() we will create object of class, and will call the member function using dot ( . ) operator. 

int main() 

{

  Cube C1;  

  C1.side=4;   // setting side value  

  cout<< "Volume of cube C1 ="<< C1.getVolume();

 } 


Access Specifiers :

C++ offers possibility to control access to class members and functions by using access specifiers. Access specifiers are used to protect data from misuse.

Types of access specifiers in C++ 

  • private 

  • protected 

  • public 

Private:

The member declared as “Private ” can be access within the same class only. ie. The private member of a class can not be accessed from outside of class.

Protected:

The member declared as “Protected” can can not  be accessed from outside of class but can be accessed from derived class . This is used when inheritance is applied to the member of class.

Public:

The member declared as “Public ” can be accessed within the class as well as from outside of the class.



UNIT-5 Operating System

Introduction

An operating system (OS) is software that allows a user to run other applications on a computing device. While it is possible for a software application to interface directly with hardware, the vast majority of applications are written for an OS, which allows them to take advantage of common libraries and not worry about specific hardware details.

 An operating system is a program that acts as an interface between the software and the computer hardware. It is an integrated set of specialized programs used to manage overall resources and operations of the computer.


The operating system manages a computer's hardware resources, including:

  • Input devices 

  • Output devices 

  • Network devices 

  • Storage devices 

The OS also provides services to facilitate the efficient execution and management of, and memory allocations for, any additional installed software application programs.


Operating System

Fig: Operating System for computer





Importance  of Operating System

  1. It make the computer system convenient to use in an efficient manner.

  2.  hides the details of the hardware resources from the users.

  3. provides users a convenient interface to use the computer system.

  4. act as an intermediary between the hardware and its users, making it easier for the users to access and use other resources.

  5. manages the resources of a computer system.

  6. keeps track of who is using which resource, granting resource requests, and mediating conflicting requests from different programs and users.

  7. provides efficient and fair sharing of resources among users and programs.


Functions of Operating System

  • Memory Management − Keeps track of the primary memory, i.e. what part of it is in use by whom, what part is not in use, etc. and allocates the memory when a process or program requests it.

  • Processor Management − Allocates the processor (CPU) to a process and deallocates the processor when it is no longer required.

  • Device Management − Keeps track of all the devices. This is also called I/O controller that decides which process gets the device, when, and for how much time.

  • File Management − Allocates and de-allocates the resources and decides who gets the resources.

  • Security − Prevents unauthorized access to programs and data by means of passwords and other similar techniques.

  • Job Accounting − Keeps track of time and resources used by various jobs and/or users.

  • Control Over System Performance − Records delays between the request for a service and from the system.

  • Interaction with the Operators − Interaction may take place via the console of the computer in the form of instructions. The Operating System acknowledges the same, does the corresponding action, and informs the operation by a display screen.

  • Error-detecting Aids − Production of dumps, traces, error messages, and other debugging and error-detecting methods.

  • Coordination Between Other Software and Users − Coordination and assignment of compilers, interpreters, assemblers, and other software to the various users of the computer systems.


Types of Operating System

  1. Batch operating system:

The users of batch operating operating system do not interact with computer directly.Each user perpares his job on an offline device like punch cards and submits it to the computer operator. To speedup processing job with similar needs are batched together and run as a group.The programmer leave their program with the operator and the operator sorts the program with similar requirement into batches.

  1. Single user operating system:

A single user operating system provides facilities to be used on one computer by onlyone user. Single user, single task: A single task is performed by one user at a time.Example- The Palm OS for Palm handheld computers.Single user, multi-task: Several programs are run at the same time by a single user. For example- Microsoft Windows.

Examples includes Windows 95, Windows NT Workstation and Windows 2000 professional.

  1. Multiuser operating system:

A multi-user operating system has been designed for more than one user to access the computer at the same or different time.

Time sharing systems: These systems are multi-user systems in which CPU time is divided among the users. The division is made on the basis of a schedule.Most batch processing systems for the mainframe computers can also be considered as ‘multi user.’Examples Unix, Linux and mainframes such as the IBM AS400.

  1. Multitasking operating system:

These are operating system that are able to execute more than one tasks simultaneously on a single processor machine.Though we say so but in reality no two tasks on a single process machine  can be executed at the same time. Actually CPU switches from one tasks to the next task so quickly that  it appears as if all the tasks are executing at the same time.The main motive of multitasking is to utilize the CPU efficiently and reduce the response time. 


  1. Real Time Operating system:

The system in which timing constraint or deadline is important is called real time system. Real Time Operating system must perform tasks in well-defined and fixed time constraints otherwise system will fail. Industrial control systems, weapon system,robots, home appliance controller ,air traffic control system etc are example of real time system.




Internal and External MS-DOS Commands

In MS-DOS, there are two ways commands are executed: internally and externally. An internal command is embedded into the command.com file, and an external command, which is not and requires a separate file to operate.

For example, if your computer does not have the fdisk.exe file and you try using the fdisk command, you will receive a "Bad command or file name" error message. Fdisk is an external command that only works if fdisk.exe, or in some cases, fdisk.com, is present.

However, as long as MS-DOS is running on your computer internal commands, such as the cd command, will always be available and does not require other files to run. Each of the commands listed on the MS-DOS help page denote what commands are external and internal.





Unit-6 Introduction  to Email and Internet


Introduction

Email is an acronym for Electronic-mail which means messages that are sent through electronic as medium from one computer to another via a network .Email messages are relayed through email servers, which are provided by all Internet service providers (ISP).

Emails are transmitted between two dedicated server folders: sender and recipient. A sender saves, sends or forwards email messages, whereas a recipient reads or downloads emails by accessing an email server.

Email messages are comprised of three components, as follows:

  • Message envelope: Describes the email’s electronic format

  • Message header: Includes sender/recipient information and email subject line

  • Message body: Includes text, image and file attachments

Uses of Email:

  1. Business and organizational use

Email has been widely accepted by business, governments and non-governmental organizations in the developed world

  1. Personal use

Many users access their personal email from friends and family members using a personal computer in their house or apartment.


Key benefits and feature of using email

  1. Emails are easy to use. You can organize your daily correspondence, send & receive electronic messages.

  2. Emails are fast, no other form of written communication is as fast as an email. They are delivered at once around the world.

  3. Simple & formal languages used in email.

  4. We can also transmit  multimedia files through  emails.


How to Use:

There various email clients like Gmail, Yahoo, Outlook, Rediff and few more through which you can create an email account by your name. Follow the steps below:

  • Create an email id account

  • Compose an email with recipient as the email id to which you want to send.

  • Give a subject(The purpose of writing this email. Like : Application for Sick Leave)

  • Compose the body of the email with reason why you writing this email

  • Give regards at the bottom with your name.

  • Finally, click on send.


Email Ethics

Email etiquette refers to the principles of behavior that one should use when writing or answering email messages. It is also known as the code of conduct for email communication. Email ethics depends upon to whom we are writing- Friends & Relatives, Partners, Customers, Superior or Subordinates.

Do have a clear subject line.

Don't forget your signature.

Do use a professional salutation

Do proofread your message.

Don't assume the recipient knows what you are talking about.

Don't shoot from the lip.

Don't! overuse exclamation points.


Advantages and Disadvantages of Using Email

Email is an important method of business communication that is fast, cheap, accessible and easily replicated. Using email can greatly benefit businesses as it provides efficient and effective ways to transmit all kinds of electronic data.




Advantages of using email

Email can increase efficiency, productivity and your business readiness. Using email in business is:

  • cheap - sending an email costs the same regardless of distance and the number of people you send it to

  • fast - an email should reach its recipient in minutes, or at the most within a few hours

  • convenient - your message will be stored until the recipient is ready to read it, and you can easily send the same message to a large number of people

  • permanent - you can keep a record of messages and replies, including details of when a message was received


Disadvantages of using email

Despite the lots of benefits, there are certain weaknesses of email that you should be aware of, such as:

  • Spam - unsolicited email can overwhelm your email system unless you install a firewall and anti-spam software. Other internet and email security issues may arise, especially if you're using the cloud or remote access.

  • Viruses - easily spread through email attachments. 

  • Sending emails by mistake - at a click of a button, an email can go to the wrong person accidentally, potentially leaking confidential data and sensitive business information. You should take care to minimise the likelihood of business data breach and theft.




Thank You....
nextgenacademyyy.blogspot.com



Recent Posts

Oracle 19c Installation guide (Linux/ Windows)

Most Viewed Posts