SlideShare a Scribd company logo
1 of 16
Comparison of C++ and C#
Prepared by
Sudip Vora
Topics
• Difference between C# and C++.
• Which is better in performance?
• Explain with an algorithm, program and prove
it.
Contents
• Introduction
• Difference between C++ and C#
• Example of C++
• Example of C#
• Algorithm and Program of C++
• Algorithm and Program of C#
• Conclusion
Introduction
• C++ is an object – Oriented programming language. It was
developed by Bjarne Stroustrup at AT & T Bell
Laboratories in Murray Hill, New Jersey, USA, I the early
of 1980s. Stroustrup, an admirer of simula67 and strong
supporter of C, wanted to combine the best of both the
languages and create a more powerful language that could
support object-oriented programming features and still retain
the power and elegance of C. The result was C++.
• Therefore, C++ is an extension of C with a major addition of
the class construct feature of simula67. Since the class was a
major addition to the original C language Stroustrup initially
called the new language ‘C with classes’. However, later in
1983, the name was changed to C++. The idea of C++ comes
from the C Increment operator ++, thereby suggesting that
C++ is an augmented – incremented version of C.
Introduction(Contd.)
• C# (pronounced see sharp) is a multi-paradigm
programming language encompassing strong
typing, imperative, declarative, functional,
generic, object-oriented (class-based), and
component-oriented programming disciplines. It
was developed by Microsoft within its .NET
initiative.
• The name "C sharp" was inspired by musical
notation where a sharp indicates that the written
note should be made a semitone higher in pitch.
Principles of C++ development
• It should be "simple, object-oriented
and familiar"
• It should be "robust and secure"
• It should be "architecture-neutral and
portable"
• It should execute with "high
performance"
• It should be "interpreted and dynamic "
Principles of C# development
• It should be simple, modern, general-purpose, object-oriented
programming language.
• The language, and implementations should provide support for
software engineering principles
• The language is intended for use in developing software
components suitable for deployment in distributed
environments.
• C# is intended to be suitable for writing applications for both
hosted and embedded systems, ranging from the very large
that use sophisticated operating systems, down to the very
small having dedicated functions.
• Robustness, durability and programmer productivity are
important.
Difference between C++ & C#
C++ C#
C++ compiles down to machine code. C# 'compiles' down to CLR, which ASP.NET
interprets (roughly) Edit - As pointed out
in comments, it JIT compiles, not
interprets.
In C++, you must handle memory
manually.
Because C# runs in a virtual machine,
memory management is handled
automatically.
C++ support the multiple inheritance (of
implementation).
C# does not (although it does have
multiple inheritance of interface).
C++ includes a very powerful—and more
complex and difficult to master—
template meta language.
C# originally had nothing like it, with
many people believing that the common
type hierarchy obviated the need for
such techniques.
In C++ you have to do your own memory
management.
C# has a garbage collector.
Difference between C++ & C#(Contd.)
C++ C#
Pointers can be used anywhere in C++. In C# pointers are used only in unsafe
mode.
Default access Specifier is Public in C++. Default access Specifier is Private in
C#.net.
C++ is OOPS based. C# is Component & OOPS Based.
C++ is a language that runs on all sorts of
platforms, being extremely popular on
Unix and Unix-like systems.
C#, while standardized, is rarely seen
outside Windows.
C++ can create stand alone applications C# cannot.
C++ can create only console applications. C# can create console applications,
Windows applications, and ASP.NET
Websites,Mobile Applications,etc.
Example of C++
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"n HELLO WORLD";
getch();
}
Example of C#
using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello world!");
}
}
Algorithm to calculate Area of a Rectangle
Steps Description
1 Start
2 Ask the user for length and width of side
3 Store the value in box Length and Width
4 Calculate the area of the square (Length x Width)
5 Store the area in box Area
6 Print the value in box Area, appropriately labeled
7 Stop
Program of the above algorithm in C++
// Demonstration of variables
#include <iostream.h>
int main()
{
unsigned short int Width = 5, Length;
Length = 10;
// create an unsigned short and initialize with result
// of multiplying Width by Length
unsigned short int Area = Width * Length;
cout << "Width:" << Width << "n";
cout << "Length: " << Length << endl;
cout << "Area: " << Area << endl;
return 0;
}
Algorithm to calculate Area of a Rectangle
Steps Description
1 Start
2 Ask the user for length and width of side
3 Store the value in box Length and Width
4 Calculate the area of the square (Length x Width)
5 Store the area in box Area
6 Print the value in box Area, appropriately labeled
7 Stop
Program of the above algorithm in C#
using System;
class Program
{
static void Main(string[] args)
{
double Length;
double Area;
Console.WriteLine("Enter the length of a side of
Square :");
Length = Convert.ToDouble(Console.ReadLine());
Area = Length * Length;
Console.WriteLine("The area of Square is: " + Area);
Console.ReadLine();
}
}
Conclusion
• After going through various aspects of both, C++ and C#, we
came to a point that we claim that C# is better than C++. C#
has the features which C++ hadn’t.
• C# has many features that overcome the features of C++
which are not at all present in C++. Hence, we conclude with
C# is better than C++ in performance, usability and durability.

More Related Content

What's hot (20)

Constructor overloading & method overloading
Constructor overloading & method overloadingConstructor overloading & method overloading
Constructor overloading & method overloading
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
 
Modular programming
Modular programmingModular programming
Modular programming
 
C# basics
 C# basics C# basics
C# basics
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Constructors and Destructor in C++
Constructors and Destructor in C++Constructors and Destructor in C++
Constructors and Destructor in C++
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Java package
Java packageJava package
Java package
 
OOP java
OOP javaOOP java
OOP java
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
java token
java tokenjava token
java token
 

Viewers also liked

difference between c c++ c#
difference between c c++ c#difference between c c++ c#
difference between c c++ c#Sireesh K
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#Sagar Pednekar
 
C# for C++ Programmers
C# for C++ ProgrammersC# for C++ Programmers
C# for C++ Programmersrussellgmorley
 
Difference between C++ and Java
Difference between C++ and JavaDifference between C++ and Java
Difference between C++ and JavaAjmal Ak
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)jeffz
 
Difference between java and c#
Difference between java and c#Difference between java and c#
Difference between java and c#TECOS
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaSteve Fort
 
Computer science presentation
Computer science presentationComputer science presentation
Computer science presentationdehrabf
 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegantalenttransform
 
Report on GPU complex type usage
Report on GPU complex type usageReport on GPU complex type usage
Report on GPU complex type usageCaner Candan
 
Corrosion control
Corrosion controlCorrosion control
Corrosion controlZTE Nepal
 
A Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkA Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkZachary Blair
 

Viewers also liked (20)

Differences between c and c++
Differences between c and c++Differences between c and c++
Differences between c and c++
 
difference between c c++ c#
difference between c c++ c#difference between c c++ c#
difference between c c++ c#
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#
 
C vs c++
C vs c++C vs c++
C vs c++
 
C# for C++ Programmers
C# for C++ ProgrammersC# for C++ Programmers
C# for C++ Programmers
 
C vs c++
C vs c++C vs c++
C vs c++
 
Difference between C++ and Java
Difference between C++ and JavaDifference between C++ and Java
Difference between C++ and Java
 
C++vs java
C++vs javaC++vs java
C++vs java
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)
 
Ppt of c vs c#
Ppt of c vs c#Ppt of c vs c#
Ppt of c vs c#
 
Difference between java and c#
Difference between java and c#Difference between java and c#
Difference between java and c#
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Computer science presentation
Computer science presentationComputer science presentation
Computer science presentation
 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegan
 
openFrameworks
openFrameworksopenFrameworks
openFrameworks
 
Report on GPU complex type usage
Report on GPU complex type usageReport on GPU complex type usage
Report on GPU complex type usage
 
Corrosion control
Corrosion controlCorrosion control
Corrosion control
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
A Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkA Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application Framework
 
Introduction à C++
Introduction à C++Introduction à C++
Introduction à C++
 

Similar to C++ vs C#

Object oriented programming 7 first steps in oop using c++
Object oriented programming 7 first steps in oop using  c++Object oriented programming 7 first steps in oop using  c++
Object oriented programming 7 first steps in oop using c++Vaibhav Khanna
 
Summer training PPT Manasv Singharia.pptx
Summer training PPT Manasv Singharia.pptxSummer training PPT Manasv Singharia.pptx
Summer training PPT Manasv Singharia.pptxshokeenk14
 
object oriented programming language fundamentals
object oriented programming language fundamentalsobject oriented programming language fundamentals
object oriented programming language fundamentalsChaithraCSHirematt
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++Ankur Pandey
 
Unit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionUnit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionAKR Education
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfAnassElHousni
 
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTREC & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTREjatin batra
 
C programming orientation
C programming orientationC programming orientation
C programming orientationnikshaikh786
 
C# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net FrameworkC# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net FrameworkDr.Neeraj Kumar Pandey
 
C++ language basic
C++ language basicC++ language basic
C++ language basicWaqar Younis
 
Comparison of c++ and c#
Comparison of c++ and c#Comparison of c++ and c#
Comparison of c++ and c#fahad javed
 
Event Driven Programming in C#.docx
Event Driven Programming in C#.docxEvent Driven Programming in C#.docx
Event Driven Programming in C#.docxLenchoMamudeBaro
 
Basics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxBasics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxCoolGamer16
 
Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++Manoj Kumar
 

Similar to C++ vs C# (20)

Object oriented programming 7 first steps in oop using c++
Object oriented programming 7 first steps in oop using  c++Object oriented programming 7 first steps in oop using  c++
Object oriented programming 7 first steps in oop using c++
 
Summer training PPT Manasv Singharia.pptx
Summer training PPT Manasv Singharia.pptxSummer training PPT Manasv Singharia.pptx
Summer training PPT Manasv Singharia.pptx
 
object oriented programming language fundamentals
object oriented programming language fundamentalsobject oriented programming language fundamentals
object oriented programming language fundamentals
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
Unit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionUnit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introduction
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 
C-sharping.docx
C-sharping.docxC-sharping.docx
C-sharping.docx
 
Oops index
Oops indexOops index
Oops index
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
 
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTREC & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
 
Introduction to c++ ppt 1
Introduction to c++ ppt 1Introduction to c++ ppt 1
Introduction to c++ ppt 1
 
C programming orientation
C programming orientationC programming orientation
C programming orientation
 
C# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net FrameworkC# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net Framework
 
C++ language basic
C++ language basicC++ language basic
C++ language basic
 
Comparison of c++ and c#
Comparison of c++ and c#Comparison of c++ and c#
Comparison of c++ and c#
 
Event Driven Programming in C#.docx
Event Driven Programming in C#.docxEvent Driven Programming in C#.docx
Event Driven Programming in C#.docx
 
Basics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxBasics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptx
 
Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 

Recently uploaded

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

C++ vs C#

  • 1. Comparison of C++ and C# Prepared by Sudip Vora
  • 2. Topics • Difference between C# and C++. • Which is better in performance? • Explain with an algorithm, program and prove it.
  • 3. Contents • Introduction • Difference between C++ and C# • Example of C++ • Example of C# • Algorithm and Program of C++ • Algorithm and Program of C# • Conclusion
  • 4. Introduction • C++ is an object – Oriented programming language. It was developed by Bjarne Stroustrup at AT & T Bell Laboratories in Murray Hill, New Jersey, USA, I the early of 1980s. Stroustrup, an admirer of simula67 and strong supporter of C, wanted to combine the best of both the languages and create a more powerful language that could support object-oriented programming features and still retain the power and elegance of C. The result was C++. • Therefore, C++ is an extension of C with a major addition of the class construct feature of simula67. Since the class was a major addition to the original C language Stroustrup initially called the new language ‘C with classes’. However, later in 1983, the name was changed to C++. The idea of C++ comes from the C Increment operator ++, thereby suggesting that C++ is an augmented – incremented version of C.
  • 5. Introduction(Contd.) • C# (pronounced see sharp) is a multi-paradigm programming language encompassing strong typing, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines. It was developed by Microsoft within its .NET initiative. • The name "C sharp" was inspired by musical notation where a sharp indicates that the written note should be made a semitone higher in pitch.
  • 6. Principles of C++ development • It should be "simple, object-oriented and familiar" • It should be "robust and secure" • It should be "architecture-neutral and portable" • It should execute with "high performance" • It should be "interpreted and dynamic "
  • 7. Principles of C# development • It should be simple, modern, general-purpose, object-oriented programming language. • The language, and implementations should provide support for software engineering principles • The language is intended for use in developing software components suitable for deployment in distributed environments. • C# is intended to be suitable for writing applications for both hosted and embedded systems, ranging from the very large that use sophisticated operating systems, down to the very small having dedicated functions. • Robustness, durability and programmer productivity are important.
  • 8. Difference between C++ & C# C++ C# C++ compiles down to machine code. C# 'compiles' down to CLR, which ASP.NET interprets (roughly) Edit - As pointed out in comments, it JIT compiles, not interprets. In C++, you must handle memory manually. Because C# runs in a virtual machine, memory management is handled automatically. C++ support the multiple inheritance (of implementation). C# does not (although it does have multiple inheritance of interface). C++ includes a very powerful—and more complex and difficult to master— template meta language. C# originally had nothing like it, with many people believing that the common type hierarchy obviated the need for such techniques. In C++ you have to do your own memory management. C# has a garbage collector.
  • 9. Difference between C++ & C#(Contd.) C++ C# Pointers can be used anywhere in C++. In C# pointers are used only in unsafe mode. Default access Specifier is Public in C++. Default access Specifier is Private in C#.net. C++ is OOPS based. C# is Component & OOPS Based. C++ is a language that runs on all sorts of platforms, being extremely popular on Unix and Unix-like systems. C#, while standardized, is rarely seen outside Windows. C++ can create stand alone applications C# cannot. C++ can create only console applications. C# can create console applications, Windows applications, and ASP.NET Websites,Mobile Applications,etc.
  • 10. Example of C++ #include<iostream.h> #include<conio.h> void main() { clrscr(); cout<<"n HELLO WORLD"; getch(); }
  • 11. Example of C# using System; class Program { static void Main() { Console.WriteLine("Hello world!"); } }
  • 12. Algorithm to calculate Area of a Rectangle Steps Description 1 Start 2 Ask the user for length and width of side 3 Store the value in box Length and Width 4 Calculate the area of the square (Length x Width) 5 Store the area in box Area 6 Print the value in box Area, appropriately labeled 7 Stop
  • 13. Program of the above algorithm in C++ // Demonstration of variables #include <iostream.h> int main() { unsigned short int Width = 5, Length; Length = 10; // create an unsigned short and initialize with result // of multiplying Width by Length unsigned short int Area = Width * Length; cout << "Width:" << Width << "n"; cout << "Length: " << Length << endl; cout << "Area: " << Area << endl; return 0; }
  • 14. Algorithm to calculate Area of a Rectangle Steps Description 1 Start 2 Ask the user for length and width of side 3 Store the value in box Length and Width 4 Calculate the area of the square (Length x Width) 5 Store the area in box Area 6 Print the value in box Area, appropriately labeled 7 Stop
  • 15. Program of the above algorithm in C# using System; class Program { static void Main(string[] args) { double Length; double Area; Console.WriteLine("Enter the length of a side of Square :"); Length = Convert.ToDouble(Console.ReadLine()); Area = Length * Length; Console.WriteLine("The area of Square is: " + Area); Console.ReadLine(); } }
  • 16. Conclusion • After going through various aspects of both, C++ and C#, we came to a point that we claim that C# is better than C++. C# has the features which C++ hadn’t. • C# has many features that overcome the features of C++ which are not at all present in C++. Hence, we conclude with C# is better than C++ in performance, usability and durability.