0% found this document useful (0 votes)
55 views

Introduction To Programming Fundamentals: Prepared By: Mehak Riaz

The document provides an introduction to programming fundamentals. It defines programming as telling a computer what to do through a series of instructions like input, output, math operations, conditional execution, and repetition. It presents a sample program in C# that gets input from the user, performs addition, and displays the output. It then discusses key concepts in object-oriented programming like objects, classes, inheritance, abstraction, encapsulation, and provides examples in C# code.

Uploaded by

Muneeb Shahab
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Introduction To Programming Fundamentals: Prepared By: Mehak Riaz

The document provides an introduction to programming fundamentals. It defines programming as telling a computer what to do through a series of instructions like input, output, math operations, conditional execution, and repetition. It presents a sample program in C# that gets input from the user, performs addition, and displays the output. It then discusses key concepts in object-oriented programming like objects, classes, inheritance, abstraction, encapsulation, and provides examples in C# code.

Uploaded by

Muneeb Shahab
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Introduction To Programming

Fundamentals

1-Lecture
Date:11/09/2017 Prepared By : Mehak Riaz
The essence of Programming

1 :What is programming anyway?!


• Programming means telling a computer what to do.
• "Do this, then do that, than take the two results, mix them up this way, and repeat until you
get a pizza out of it…"
• It's a bit like cooking.
• So, what are the basic operations that a computer can perform?
• Of course, a computer can do many things, but at a very basic level, programs consists of the
following types of instructions:

• input: get data from the keyboard or from some file or other device
• output: write
• math: perform some simple calculation, like addition and multiplication
• conditional execution: check some condition and execute one sequence of statements or
another
• repetition: repeat some sequence of operations, usually with some variation
Sample Program
class Program
{
static void Main(string[] args)
{ int x;
int y;
int result;
Console.Write(" Enter the first number to be added: ");
x=Convert.ToInt32(Console.ReadLine());
Console.Write("Enter the second number to be added: ");
y = Convert.ToInt32(Console.ReadLine());
result = x + y;
Console.Write("The sum of two numbers is: "+result);
Console.ReadLine();
}
}
Oo Concepts in c#
Object Oriented Programming:
• It is a type of programming in which programmers define not only
the data type of a data structure, but also the types of operations
(functions) that can be applied to the data structure. In this way, the
data structure becomes an object that includes both data and
functions. In addition, programmers can create relationships
between one object and another. For example, objects can inherit
characteristics from other objects.
• One of the principal advantages of object-oriented programming
techniques over procedural programming techniques is that they
enable programmers to create modules that do not need to be
changed when a new type of object is added. A programmer can
simply create a new object that inherits many of its features from
existing objects. This makes object-oriented programs easier to
modify.
Oo concepts
Object
• Objects are the basic run-time entities in an object-
oriented system. Programming problem is analyzed in
terms of objects and nature of communication
between them. When a program is executed, objects
interact with each other .Different objects can also
interact with each other without knowing the details of
their data or code.
• An object is an instance of a class. A class must be
instantiated into an object before it can be used in the
software. More than one instance of the same class
can be in existence at any one time.
Oo concepts in c#
Class
• A class is a collection of objects of a similar type. Once a class is defined,
any number of objects can be created which belong to that class. A class is
a blueprint, or prototype, that defines the variables and the methods
common to all objects of a certain kind.
Instance
• The instance is the actual object created at runtime. One can have an
instance of a class or a particular object.
State
• The set of values of the attributes of a particular object is called its state.
The object consists of state and the behaviour that's defined in the
object's class.
Method
• Method describes the object’s abilities. A Dog has the ability to bark.
So bark() is one of the methods of the Dog class.
Example Code
Public class PF
{
Console.WriteLine(“First Class Of PF”);
}
//calling Pf Class InMain

public static void Main()


{
PF pf = new PF ();
}
Oo concepts
Abstraction
• Abstraction is one of the principle of object oriented
programming. It is used to display only necessary and
essential features of an object to ouside the world.Means
displaying what is necessary and encapsulate the
unnecessary things to outside the world.Hiding can be
achieved by using "private" access modifiers.
Note - Outside the world means when we use reference of
object then it will show only necessary methods and
properties and hide methods which are not necessary.
Example Code
• Necessary things means compulsary to know before starting a car
1. Name of Car
2. Color of Car
3. Steering
4. Rear View Mirror
5. Brakes
6. Gear
Unnecessary things means not that compulsary to know for a Car rider
1. Internal Details of a Car
2. Car Engine
3. Diesal Engine
4. Exhaust System
5. Silence
//Necessary
public void Steering()

Console.WriteLine("Streering of Car");
}
//unnecessary
private void CarEngine()
{
Console.WriteLine("CarEngine of Car");
}
Oo concepts
Encapsulation
• It is the mechanism that binds together code and data in
manipulates, and keeps both safe from outside interference
and misuse. In short, it isolates a particular code and data
from all other codes and data. A well-defined interface
controls the access to that particular code and data.</p. />
The act of placing data and the operations that perform on
that data in the same class. The class then becomes the
'capsule' or container for the data and operations.
• Storing data and functions in a single unit (class) is
encapsulation. Data cannot be accessible to the outside
world and only those functions which are stored in the
class can access it.
Example Code
public class Account {
private string accoutName;
// get methods
public string GetAccount()
{
return accoutName; }
// Set method
public void SetAccount(string name)
{ accoutName = name; }
} static void Main()
{
string name ="SAVING_ACCOUNT";
Account account = new Account();
account.SetAccount(name);
name = string.Empty;
name = account.GetAccount();
}

You might also like