SlideShare a Scribd company logo
PRESENTATION ON  BY: SHUBHRA CHAUHAN Vs
HISTORY OF C AND C SHARP C sharp was developed by Microsoft within its .NET initiative. C sharp is one of the programming language designed for the common language infrastructure. C  was developed by DENNIS RITCHIE at the Bell Telephone laboratories for use with the  unix operating system
FEATURES OF C Structured programming language. General purpose programming language. Widely used in the development of system software. Contains rich set of operators and data types. C allows the user to add functions to the library. C is highly portable. Most of the C programs can be processed on  many different computers with little or no alteration.
FEATURES OF  C SHARP It is simple, modern, object oriented language derived from C++ and JAVA . It aims to combine the high productivity of VISUAL BASIC and the raw power of C ++. It is a part of Microsoft Visual Studio 7.0. It  supports garbage collection, automatic memory management and a lot. In C# Microsoft has taken care of C++ problems such as Memory management, pointers etc.  In C# there is no usage of "::" or "->" operators. ,[object Object]
DATA TYPES IN C DATA TYPE PRIMITIVE AGGREGATE USER DEFINED INT FLOAT DOUBLE CHAR ARRAY STRUCTURE ENUM
DATA TYPES IN C SHARP DATA TYPES VALUE TYPES SIMPLE TYPE ENUM STRUCTURE REFERENCE TYPES CLASS ARRAYS DELEGATIONS INTERFACES POINTER TYPES
EXAMPLE OF C #include<stdio.h> #include<conio.h> void main() { printf(“welcome to C”); getch(); } Output: welcome to C
EXAMPLE OF C SHARP Using system; class hello { static void main() { console.writeline(“welcome to C sharp”); } } Output: welcome to C sharp
LOOPS IN C For loop syntax of for loop:- for(initialisation;test condition;increamen / decreament) { set of statements; } while loop syntax of while loop:- while(test condition) { set of statements; increament / decreament; } Do while loop syntax of do while loop:- do { set of statements: increament / decreament; }while(test condition);
LOOPS IN C SHARP For loop syntax of for loop for(initialisation:test condition;increament / decreament) { set of statements; } While loop syntax of while loop while(test condition) { set of statements; increament / decreament; } continue...
Do while loop syntax of do while loop do { set of statements; increament / decreament; }while(test condition); Foreach loop syntax of foreach loop foreach(DataType var in DataTypeCollection) { set of statements; }  continue...
CONDITIONAL STATEMENTS C and C# have following two types of conditional statements:- IF STATEMENT Syntax :- if(condition) { statement1; } else { statement 2' } SWITCH STATEMENT Syntax: switch(expression) {  case constant1 : statement sequence1; break;  case constant2 : statement sequence2;  break;  case constant (n-1) : statement sequence(n-1) ; break;  default : statement; }
FUNCTION IN  C A function in C language is a block of code that performs a specific task. It has a name and it is reusable i.e. it can be executed from as many different parts in a C Program as required. It also optionally returns a value to the calling program. Structure of a Function A general form of a C function looks like this: <return type> FunctionName (Argument1, Argument2, Argument3……) { Statement1; Statement2; Statement3; }
Example of a simple function to add two integers #include<stdio.h> #include<conio.h> void add(int x,int y) { int result; result = x+y; printf(&quot;Sum of %d and %d is %d.&quot;,x,y,result); } void main() { clrscr(); add(10,15); add(55,64); getch(); } Output: sum of 10 and 15 is 25 sum of 55 and 64 is 119
PASSING ARGUMENTS TO FUNCTION We can pass arguments to a function by following two ways: 1)Call by Value 2)Call by Reference 1) Call by Value: In Call by Value, only the values taken by the arguments are sent to the function. In call by value any changes made to the formal arguments do not cause any change to the actual arguments. 2) Call by Reference: In Call by Reference, only the addresses taken by the arguments are sent to the function. In call by reference any changes made to the formal arguments cause changes to the actual arguments.
FUNCTION IN C SHARP To define a C# function you must declare it outside the main() block. Structure  of function A function in C sharp look like this <visibility><return type><function name>(<parameter>) { statement1; statement2; statement3; }
C# Function Parameters C# methods can accept values when a variable calls it. using System; class Program { static int Multiply(int x)  //accepts only a int value { return x * 2; } static void Main() { int z = 3; Console.WriteLine(Multiply(z));  //Prints the returned value Console.Read(); } } Output: 6
C# CALL BY REFERENCE In c# , call by reference can  be done by using ref  and out modifier. The difference between ref and out modifier is that a value passed to ref modifier has to be initialised before calling the method whereas this is not true for out modifier.
By  ref  modifier using System; class Program { static void AddOne(ref int x) { x = x + 1; } static void Main() { int z = 8; AddOne(ref z);  // variable z will be changed in function Console.WriteLine(z);  Console.Read(); } } Output: 9
BY OUT MODIFIER using System ; class Program { static int AddOne(out int x)  { int y = 90; x = 19;  // out variable must be initialized x = x + 1; return y + 1; } static void Main() { int z;  // out variable must be unassigned be declared Console.WriteLine(AddOne(out z)); Console.WriteLine(z); Console.Read(); } } Output : 91 20
ARRAY IN C AND C SHARP Array is a collection of same type elements under the same variable identifier referenced by index number . Arrays are of two types single dimension array and multi-dimension array.  Each of these array type can be of either static array or dynamic array. Static arrays have their sizes declared from the start and the size cannot be changed after declaration.  Dynamic arrays that allow you to dynamically change their size at runtime. A single dimension array is represented be a single column, whereas a multiple dimensional array would span out n columns by n rows.
SINGLE DIMENSION ARRAYS Declaring Single Dimension Arrays Arrays can be declared using any of the data types available in C and C#.You can declare a single dimensional array as follows:  <data type> array_name[size_of_array]; Initializing Single Dimension Arrays Array can be initialized in two ways: initializing on declaration   <data type> array_name[size_of_array] = {element 1, element 2, ...}; Initialized by Assignment <data type>array_name[size_of_dimension1][size_of_dimension2]; array_name[0]=element1; array_name[1]=element2; . . array_name[size_of_array]=element n;
MULTIDIMENSION ARRAY Declaring Multidimensional Arrays To declare a multidimensional array:  <data type> array_name[size_of_first_dimension][size_of_second_dimension] ... Initializing Multidimensional Arrays   Initialisation on declaration <data type> array_name[size_of_dimension1][size_of_second_dimension2] ... = {element 1, element 2, element 3, …}, Initialization on assignment int marks[2][4]: marks[0][0]=1; marks[0][1]=2; marks[0][2]=3; marks[0][3]=4; marks[1][0]=6; marks[1][1]=7; marks[1][2]=8;marks[1][3]=9;
JAGGED  ARRAY A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an &quot;array of arrays.&quot; A special type of array is introduced in C#. A Jagged Array is an array of an array in which the length of each array index can differ. Example: int[][] jagArray = new int[5][ ]; In the above declaration the rows are fixed in size. But columns are not specified as they can vary.
DECLARING AND INITIALIZING JAGGED ARRAY DECLARATION int[][] jaggedArray = new int[5][];  jaggedArray[0] = new int[3];  jaggedArray[1] = new int[5];  jaggedArray[2] = new int[2];  jaggedArray[3] = new int[8];  jaggedArray[4] = new int[10];  INITIALISATION jaggedArray[0] = new int[] { 3, 5, 7, };  jaggedArray[1] = new int[] { 1, 0, 2, 4, 6 };  jaggedArray[2] = new int[] { 1, 6 };  jaggedArray[3] = new int[] { 1, 0, 2, 4, 6, 45, 67, 78 };  jaggedArray[4] = new int[] { 1, 0, 2, 4, 6, 34, 54, 67, 87, 78 };
POINTER IN C AND C SHARP C and C# both supports the pointer concept. But in C# pointer can only be declared to hold the memory address of value types and arrays pointers are not allowed to point to a reference type or even to a structure type which contains a reference type Declaring a Pointer type  The general form of declaring a pointer type is as shown below  type *variable_name;  Where * is known as the de-reference operator. For example the following statement int *x ;  Declares a pointer variable x, which can hold the address of an int type. The reference operator (&) can be used to get the memory address of a variable.  int x = 100; The &x gives the memory address of the variable x, which we can assign to a pointer variable int *ptr = & x;
OOPS CONCEPT IN C# Key Concepts of Object Orientation * Abstraction * Encapsulation * Polymorphism * Inheritance Abstraction  is the ability to generalize an object as a data type that has a specific set of characteristics and is able to perform a set of actions. Object-oriented languages provide abstraction via classes. Classes define the properties and methods of an object type. Classes are declared using the keyword class, as shown in the following example: public class Draw { // Class code. }
ACCESS MODIFIER ACCESS MODIFIER DESCRIPTION private Only members within the same type Protected Only derived types or members of the same type Internal Only code within the same assembly. Can also be code external to object as long as it is in the same assembly. Protected internal Either code from derived type or code in the same assembly. Combination of protected OR internal. public Any code. No inheritance, external type, or external assembly restrictions.
ENCAPSULATION Encapsulation is the procedure of covering up of data and functions into a single unit (called class). An encapsulated object is often called an abstract data type.Encapsulation provides a way to protect data from accidental corruption. POLYMORPHISM Polymorphism is the ability to use an operator or function in different ways. Polymorphism gives different meanings or functions to the operators or functions. Poly, referring to many, signifies the many uses of these operators and functions. A single function usage or an operator functioning in many ways can be called polymorphism. Polymorphism refers to codes, operations or objects that behave differently in different contexts.
INHERITANCE Inheritance is a mechanism of reusing and extending existing classes without modifying them, thus producing hierarchical relationships between them. Inheritance is almost like embedding an object into a class. Suppose that you declare an object x of class A in the class definition of B. As a result, class B will have access to all the public data members and member functions of class A. However, in class B, you have to access the data members and member functions of class A through object x.
ADVANTAGES OF C# OVER C Don't need to worry about header files &quot;.h&quot; Definition of classes and functions can be done in any order Pointers no longer needed (but optional) It is compiled to an intermediate language (CIL) indepently of the language it was developed or the target architecture and operating system Automatic garbage collection Classes can be defined within classes
CONCLUSION C# gives you access to a rich set of built-in types based on the common type system as well as the .NET Framework class library. As with all object-oriented languages, in C# you leverage built-in types and class libraries to build new types for your applications.C# shares many of the features of other object-oriented languages, such as C++.
REFERENCES www.msdnmicrosoft.com www.csharpstation.com www.wikipedia.org

More Related Content

What's hot

Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
Nilesh Dalvi
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial
Jm Ramos
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
Abhilash Nair
 
Interface in java
Interface in javaInterface in java
Interface in java
PhD Research Scholar
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
Venkata.Manish Reddy
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
Arun Prasad
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
Nilesh Dalvi
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
Hawkman Academy
 
C#.NET
C#.NETC#.NET
C#.NET
gurchet
 
Java Programming
Java ProgrammingJava Programming
Java Programming
Anjan Mahanta
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
sharqiyem
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
Abhilash Nair
 
C sharp
C sharpC sharp
C sharp
sanjay joshi
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
amitksaha
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
Jussi Pohjolainen
 
Introduction to C# Programming
Introduction to C# ProgrammingIntroduction to C# Programming
Introduction to C# Programming
Sherwin Banaag Sapin
 
Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For Syntax
PravinYalameli
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
Dr.Neeraj Kumar Pandey
 

What's hot (20)

Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
C#.NET
C#.NETC#.NET
C#.NET
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
C sharp
C sharpC sharp
C sharp
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 
Introduction to C# Programming
Introduction to C# ProgrammingIntroduction to C# Programming
Introduction to C# Programming
 
Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For Syntax
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 

Viewers also liked

Differences between c and c++
Differences between c and c++Differences between c and c++
Differences between c and c++
starlit electronics
 
Ppt of c++ vs c#
Ppt of c++ vs c#Ppt of c++ vs c#
Ppt of c++ vs c#
shubhra chauhan
 
Object oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharpObject oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharp
Abefo
 
C vs c++
C vs c++C vs c++
C vs c++
ZTE Nepal
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
Vishwa Mohan
 
Design in Tech Report 2017
Design in Tech Report 2017Design in Tech Report 2017
Design in Tech Report 2017
John Maeda
 
C++ vs C#
C++ vs C#C++ vs C#
C++ vs C#
sudipv
 
difference between c c++ c#
difference between c c++ c#difference between c c++ c#
difference between c c++ c#
Sireesh K
 
C vs c++
C vs c++C vs c++
C vs c++
Gaurav Badhan
 
Participatory diagnostics of animal health service delivery systems in Mali
Participatory diagnostics of animal health service delivery systems in MaliParticipatory diagnostics of animal health service delivery systems in Mali
Participatory diagnostics of animal health service delivery systems in Mali
ILRI
 
.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# Introduction
Siraj Memon
 
Meta edit calc execution v3
Meta edit calc execution v3Meta edit calc execution v3
Meta edit calc execution v3
Gordon Morrison
 
How CFOs Can Use Analytics to Drive the Business Forward - Sarah Adam-Gedge N...
How CFOs Can Use Analytics to Drive the Business Forward - Sarah Adam-Gedge N...How CFOs Can Use Analytics to Drive the Business Forward - Sarah Adam-Gedge N...
How CFOs Can Use Analytics to Drive the Business Forward - Sarah Adam-Gedge N...
Finance Network marcus evans
 
CDSS Service Offerings
CDSS Service OfferingsCDSS Service Offerings
CDSS Service Offerings
Robert Grande
 
Recent personal injury awards in the High Court and Court of Appeal
Recent personal injury awards in the High Court and Court of Appeal Recent personal injury awards in the High Court and Court of Appeal
Recent personal injury awards in the High Court and Court of Appeal
Gerard Nicholas Murphy
 
Saudi Arabia Vision 2030, an opportunity to Italian companies...
Saudi Arabia Vision 2030, an opportunity to Italian companies... Saudi Arabia Vision 2030, an opportunity to Italian companies...
Saudi Arabia Vision 2030, an opportunity to Italian companies...
Bashar Jabban, MBA
 
Magento 2 Advance Shop By Brand Extension, Display Logo Slider on Store
Magento 2 Advance Shop By Brand Extension, Display Logo Slider on StoreMagento 2 Advance Shop By Brand Extension, Display Logo Slider on Store
Magento 2 Advance Shop By Brand Extension, Display Logo Slider on Store
Biztech Store
 
Hacetesis enfoque
Hacetesis enfoqueHacetesis enfoque
Hacetesis enfoque
Hacetesis
 

Viewers also liked (18)

Differences between c and c++
Differences between c and c++Differences between c and c++
Differences between c and c++
 
Ppt of c++ vs c#
Ppt of c++ vs c#Ppt of c++ vs c#
Ppt of c++ vs c#
 
Object oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharpObject oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharp
 
C vs c++
C vs c++C vs c++
C vs c++
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
Design in Tech Report 2017
Design in Tech Report 2017Design in Tech Report 2017
Design in Tech Report 2017
 
C++ vs C#
C++ vs C#C++ vs C#
C++ vs C#
 
difference between c c++ c#
difference between c c++ c#difference between c c++ c#
difference between c c++ c#
 
C vs c++
C vs c++C vs c++
C vs c++
 
Participatory diagnostics of animal health service delivery systems in Mali
Participatory diagnostics of animal health service delivery systems in MaliParticipatory diagnostics of animal health service delivery systems in Mali
Participatory diagnostics of animal health service delivery systems in Mali
 
.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# Introduction
 
Meta edit calc execution v3
Meta edit calc execution v3Meta edit calc execution v3
Meta edit calc execution v3
 
How CFOs Can Use Analytics to Drive the Business Forward - Sarah Adam-Gedge N...
How CFOs Can Use Analytics to Drive the Business Forward - Sarah Adam-Gedge N...How CFOs Can Use Analytics to Drive the Business Forward - Sarah Adam-Gedge N...
How CFOs Can Use Analytics to Drive the Business Forward - Sarah Adam-Gedge N...
 
CDSS Service Offerings
CDSS Service OfferingsCDSS Service Offerings
CDSS Service Offerings
 
Recent personal injury awards in the High Court and Court of Appeal
Recent personal injury awards in the High Court and Court of Appeal Recent personal injury awards in the High Court and Court of Appeal
Recent personal injury awards in the High Court and Court of Appeal
 
Saudi Arabia Vision 2030, an opportunity to Italian companies...
Saudi Arabia Vision 2030, an opportunity to Italian companies... Saudi Arabia Vision 2030, an opportunity to Italian companies...
Saudi Arabia Vision 2030, an opportunity to Italian companies...
 
Magento 2 Advance Shop By Brand Extension, Display Logo Slider on Store
Magento 2 Advance Shop By Brand Extension, Display Logo Slider on StoreMagento 2 Advance Shop By Brand Extension, Display Logo Slider on Store
Magento 2 Advance Shop By Brand Extension, Display Logo Slider on Store
 
Hacetesis enfoque
Hacetesis enfoqueHacetesis enfoque
Hacetesis enfoque
 

Similar to Ppt of c vs c#

Chapter1.pptx
Chapter1.pptxChapter1.pptx
Chapter1.pptx
WondimuBantihun1
 
Notes(1).pptx
Notes(1).pptxNotes(1).pptx
Notes(1).pptx
InfinityWorld3
 
C++ tutorials
C++ tutorialsC++ tutorials
C++ tutorials
Divyanshu Dubey
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
RSathyaPriyaCSEKIOT
 
OOC MODULE1.pptx
OOC MODULE1.pptxOOC MODULE1.pptx
OOC MODULE1.pptx
1HK19CS090MOHAMMEDSA
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
 
cppt-170218053903 (1).pptx
cppt-170218053903 (1).pptxcppt-170218053903 (1).pptx
cppt-170218053903 (1).pptx
WatchDog13
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
Hattori Sidek
 
CPP-overviews notes variable data types notes
CPP-overviews notes variable data types notesCPP-overviews notes variable data types notes
CPP-overviews notes variable data types notes
SukhpreetSingh519414
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
PriyadarshiniS28
 
C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01
Zafor Iqbal
 
Functions.pptx, programming language in c
Functions.pptx, programming language in cFunctions.pptx, programming language in c
Functions.pptx, programming language in c
floraaluoch3
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
Vikram Nandini
 
C++ language
C++ languageC++ language
C++ language
Hamza Asif
 
Intake 38 3
Intake 38 3Intake 38 3
Intake 38 3
Mahmoud Ouf
 
Presentation 5th
Presentation 5thPresentation 5th
Presentation 5th
Connex
 
Csharp4 basics
Csharp4 basicsCsharp4 basics
Csharp4 basics
Abed Bukhari
 
C language updated
C language updatedC language updated
C language updated
Arafat Bin Reza
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
somu rajesh
 
Functions IN CPROGRAMMING OF ENGINEERING.pptx
Functions IN CPROGRAMMING OF ENGINEERING.pptxFunctions IN CPROGRAMMING OF ENGINEERING.pptx
Functions IN CPROGRAMMING OF ENGINEERING.pptx
vanshhans21102005
 

Similar to Ppt of c vs c# (20)

Chapter1.pptx
Chapter1.pptxChapter1.pptx
Chapter1.pptx
 
Notes(1).pptx
Notes(1).pptxNotes(1).pptx
Notes(1).pptx
 
C++ tutorials
C++ tutorialsC++ tutorials
C++ tutorials
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
 
OOC MODULE1.pptx
OOC MODULE1.pptxOOC MODULE1.pptx
OOC MODULE1.pptx
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
 
cppt-170218053903 (1).pptx
cppt-170218053903 (1).pptxcppt-170218053903 (1).pptx
cppt-170218053903 (1).pptx
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
CPP-overviews notes variable data types notes
CPP-overviews notes variable data types notesCPP-overviews notes variable data types notes
CPP-overviews notes variable data types notes
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
 
C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01
 
Functions.pptx, programming language in c
Functions.pptx, programming language in cFunctions.pptx, programming language in c
Functions.pptx, programming language in c
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
C++ language
C++ languageC++ language
C++ language
 
Intake 38 3
Intake 38 3Intake 38 3
Intake 38 3
 
Presentation 5th
Presentation 5thPresentation 5th
Presentation 5th
 
Csharp4 basics
Csharp4 basicsCsharp4 basics
Csharp4 basics
 
C language updated
C language updatedC language updated
C language updated
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Functions IN CPROGRAMMING OF ENGINEERING.pptx
Functions IN CPROGRAMMING OF ENGINEERING.pptxFunctions IN CPROGRAMMING OF ENGINEERING.pptx
Functions IN CPROGRAMMING OF ENGINEERING.pptx
 

Recently uploaded

DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
christianmathematics
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 

Recently uploaded (20)

DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 

Ppt of c vs c#

  • 1. PRESENTATION ON BY: SHUBHRA CHAUHAN Vs
  • 2. HISTORY OF C AND C SHARP C sharp was developed by Microsoft within its .NET initiative. C sharp is one of the programming language designed for the common language infrastructure. C was developed by DENNIS RITCHIE at the Bell Telephone laboratories for use with the unix operating system
  • 3. FEATURES OF C Structured programming language. General purpose programming language. Widely used in the development of system software. Contains rich set of operators and data types. C allows the user to add functions to the library. C is highly portable. Most of the C programs can be processed on many different computers with little or no alteration.
  • 4.
  • 5. DATA TYPES IN C DATA TYPE PRIMITIVE AGGREGATE USER DEFINED INT FLOAT DOUBLE CHAR ARRAY STRUCTURE ENUM
  • 6. DATA TYPES IN C SHARP DATA TYPES VALUE TYPES SIMPLE TYPE ENUM STRUCTURE REFERENCE TYPES CLASS ARRAYS DELEGATIONS INTERFACES POINTER TYPES
  • 7. EXAMPLE OF C #include<stdio.h> #include<conio.h> void main() { printf(“welcome to C”); getch(); } Output: welcome to C
  • 8. EXAMPLE OF C SHARP Using system; class hello { static void main() { console.writeline(“welcome to C sharp”); } } Output: welcome to C sharp
  • 9. LOOPS IN C For loop syntax of for loop:- for(initialisation;test condition;increamen / decreament) { set of statements; } while loop syntax of while loop:- while(test condition) { set of statements; increament / decreament; } Do while loop syntax of do while loop:- do { set of statements: increament / decreament; }while(test condition);
  • 10. LOOPS IN C SHARP For loop syntax of for loop for(initialisation:test condition;increament / decreament) { set of statements; } While loop syntax of while loop while(test condition) { set of statements; increament / decreament; } continue...
  • 11. Do while loop syntax of do while loop do { set of statements; increament / decreament; }while(test condition); Foreach loop syntax of foreach loop foreach(DataType var in DataTypeCollection) { set of statements; } continue...
  • 12. CONDITIONAL STATEMENTS C and C# have following two types of conditional statements:- IF STATEMENT Syntax :- if(condition) { statement1; } else { statement 2' } SWITCH STATEMENT Syntax: switch(expression) { case constant1 : statement sequence1; break; case constant2 : statement sequence2; break; case constant (n-1) : statement sequence(n-1) ; break; default : statement; }
  • 13. FUNCTION IN C A function in C language is a block of code that performs a specific task. It has a name and it is reusable i.e. it can be executed from as many different parts in a C Program as required. It also optionally returns a value to the calling program. Structure of a Function A general form of a C function looks like this: <return type> FunctionName (Argument1, Argument2, Argument3……) { Statement1; Statement2; Statement3; }
  • 14. Example of a simple function to add two integers #include<stdio.h> #include<conio.h> void add(int x,int y) { int result; result = x+y; printf(&quot;Sum of %d and %d is %d.&quot;,x,y,result); } void main() { clrscr(); add(10,15); add(55,64); getch(); } Output: sum of 10 and 15 is 25 sum of 55 and 64 is 119
  • 15. PASSING ARGUMENTS TO FUNCTION We can pass arguments to a function by following two ways: 1)Call by Value 2)Call by Reference 1) Call by Value: In Call by Value, only the values taken by the arguments are sent to the function. In call by value any changes made to the formal arguments do not cause any change to the actual arguments. 2) Call by Reference: In Call by Reference, only the addresses taken by the arguments are sent to the function. In call by reference any changes made to the formal arguments cause changes to the actual arguments.
  • 16. FUNCTION IN C SHARP To define a C# function you must declare it outside the main() block. Structure of function A function in C sharp look like this <visibility><return type><function name>(<parameter>) { statement1; statement2; statement3; }
  • 17. C# Function Parameters C# methods can accept values when a variable calls it. using System; class Program { static int Multiply(int x) //accepts only a int value { return x * 2; } static void Main() { int z = 3; Console.WriteLine(Multiply(z)); //Prints the returned value Console.Read(); } } Output: 6
  • 18. C# CALL BY REFERENCE In c# , call by reference can be done by using ref and out modifier. The difference between ref and out modifier is that a value passed to ref modifier has to be initialised before calling the method whereas this is not true for out modifier.
  • 19. By ref modifier using System; class Program { static void AddOne(ref int x) { x = x + 1; } static void Main() { int z = 8; AddOne(ref z); // variable z will be changed in function Console.WriteLine(z); Console.Read(); } } Output: 9
  • 20. BY OUT MODIFIER using System ; class Program { static int AddOne(out int x) { int y = 90; x = 19; // out variable must be initialized x = x + 1; return y + 1; } static void Main() { int z; // out variable must be unassigned be declared Console.WriteLine(AddOne(out z)); Console.WriteLine(z); Console.Read(); } } Output : 91 20
  • 21. ARRAY IN C AND C SHARP Array is a collection of same type elements under the same variable identifier referenced by index number . Arrays are of two types single dimension array and multi-dimension array. Each of these array type can be of either static array or dynamic array. Static arrays have their sizes declared from the start and the size cannot be changed after declaration. Dynamic arrays that allow you to dynamically change their size at runtime. A single dimension array is represented be a single column, whereas a multiple dimensional array would span out n columns by n rows.
  • 22. SINGLE DIMENSION ARRAYS Declaring Single Dimension Arrays Arrays can be declared using any of the data types available in C and C#.You can declare a single dimensional array as follows: <data type> array_name[size_of_array]; Initializing Single Dimension Arrays Array can be initialized in two ways: initializing on declaration <data type> array_name[size_of_array] = {element 1, element 2, ...}; Initialized by Assignment <data type>array_name[size_of_dimension1][size_of_dimension2]; array_name[0]=element1; array_name[1]=element2; . . array_name[size_of_array]=element n;
  • 23. MULTIDIMENSION ARRAY Declaring Multidimensional Arrays To declare a multidimensional array: <data type> array_name[size_of_first_dimension][size_of_second_dimension] ... Initializing Multidimensional Arrays Initialisation on declaration <data type> array_name[size_of_dimension1][size_of_second_dimension2] ... = {element 1, element 2, element 3, …}, Initialization on assignment int marks[2][4]: marks[0][0]=1; marks[0][1]=2; marks[0][2]=3; marks[0][3]=4; marks[1][0]=6; marks[1][1]=7; marks[1][2]=8;marks[1][3]=9;
  • 24. JAGGED ARRAY A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an &quot;array of arrays.&quot; A special type of array is introduced in C#. A Jagged Array is an array of an array in which the length of each array index can differ. Example: int[][] jagArray = new int[5][ ]; In the above declaration the rows are fixed in size. But columns are not specified as they can vary.
  • 25. DECLARING AND INITIALIZING JAGGED ARRAY DECLARATION int[][] jaggedArray = new int[5][]; jaggedArray[0] = new int[3]; jaggedArray[1] = new int[5]; jaggedArray[2] = new int[2]; jaggedArray[3] = new int[8]; jaggedArray[4] = new int[10]; INITIALISATION jaggedArray[0] = new int[] { 3, 5, 7, }; jaggedArray[1] = new int[] { 1, 0, 2, 4, 6 }; jaggedArray[2] = new int[] { 1, 6 }; jaggedArray[3] = new int[] { 1, 0, 2, 4, 6, 45, 67, 78 }; jaggedArray[4] = new int[] { 1, 0, 2, 4, 6, 34, 54, 67, 87, 78 };
  • 26. POINTER IN C AND C SHARP C and C# both supports the pointer concept. But in C# pointer can only be declared to hold the memory address of value types and arrays pointers are not allowed to point to a reference type or even to a structure type which contains a reference type Declaring a Pointer type The general form of declaring a pointer type is as shown below type *variable_name; Where * is known as the de-reference operator. For example the following statement int *x ; Declares a pointer variable x, which can hold the address of an int type. The reference operator (&) can be used to get the memory address of a variable. int x = 100; The &x gives the memory address of the variable x, which we can assign to a pointer variable int *ptr = & x;
  • 27. OOPS CONCEPT IN C# Key Concepts of Object Orientation * Abstraction * Encapsulation * Polymorphism * Inheritance Abstraction is the ability to generalize an object as a data type that has a specific set of characteristics and is able to perform a set of actions. Object-oriented languages provide abstraction via classes. Classes define the properties and methods of an object type. Classes are declared using the keyword class, as shown in the following example: public class Draw { // Class code. }
  • 28. ACCESS MODIFIER ACCESS MODIFIER DESCRIPTION private Only members within the same type Protected Only derived types or members of the same type Internal Only code within the same assembly. Can also be code external to object as long as it is in the same assembly. Protected internal Either code from derived type or code in the same assembly. Combination of protected OR internal. public Any code. No inheritance, external type, or external assembly restrictions.
  • 29. ENCAPSULATION Encapsulation is the procedure of covering up of data and functions into a single unit (called class). An encapsulated object is often called an abstract data type.Encapsulation provides a way to protect data from accidental corruption. POLYMORPHISM Polymorphism is the ability to use an operator or function in different ways. Polymorphism gives different meanings or functions to the operators or functions. Poly, referring to many, signifies the many uses of these operators and functions. A single function usage or an operator functioning in many ways can be called polymorphism. Polymorphism refers to codes, operations or objects that behave differently in different contexts.
  • 30. INHERITANCE Inheritance is a mechanism of reusing and extending existing classes without modifying them, thus producing hierarchical relationships between them. Inheritance is almost like embedding an object into a class. Suppose that you declare an object x of class A in the class definition of B. As a result, class B will have access to all the public data members and member functions of class A. However, in class B, you have to access the data members and member functions of class A through object x.
  • 31. ADVANTAGES OF C# OVER C Don't need to worry about header files &quot;.h&quot; Definition of classes and functions can be done in any order Pointers no longer needed (but optional) It is compiled to an intermediate language (CIL) indepently of the language it was developed or the target architecture and operating system Automatic garbage collection Classes can be defined within classes
  • 32. CONCLUSION C# gives you access to a rich set of built-in types based on the common type system as well as the .NET Framework class library. As with all object-oriented languages, in C# you leverage built-in types and class libraries to build new types for your applications.C# shares many of the features of other object-oriented languages, such as C++.