C vs C++
CSEF · 2002 Mathematics & Software
Overview
Objectives/Goals My project#s objective was to determine the speed of C compared to C++ (programming languages). I thought that C++ would be faster, because it was written more recently. Methods/Materials I used two books for reference, Herb Schildt's C++: The Complete Reference, and Teach Yourself C++, also by Schildt. I found these the most useful books while I was teaching myself programming. I used three compilers for the C language, and three compilers for the C++ language. I also used a computer. I wrote two programs (one that did math calculations, the other printed to the screen, both repeated the task 100,000 times) in the two languages. I compiled the C++ programs in the C++ compilers, and compiled the C programs in both the C compilers and the C++ compilers. I ran my programs ten times each, and recorded the time they took to run. I used Microsoft Excel to analyze my data using averages, medians, and graphs. Results The times varied with the different compilers, but the most significant evidence is the fact that the C programs compiled in the C++ compilers, were faster than the C++ programs I compiled in the C++ compiler. On a very basic level, C is faster than C++. Conclusions/Discussion At the basic level, in it's simple, basic functions, C is faster than C++. C is faster at math and printing, but C++ has plenty of advantages. If you look at the actual programs I wrote, the C++ code is a lot simpler. There are a lot of little things that I personally believe make the programmer's life easier. There are also a lot of bigger, more complicated things like classes, which can greatly simplify a large program. They didn't affect these programs, but in a real application or game, these features could make writing the program much easier. I think that when C was upgraded to C++, speed wasn't the only consideration. More important were power and ease of use.
Summary statement
My project was on the relative speed of programming languages.
Help received
My mother helped with the board layout.
Competition history
- CSEF 2002
Resources
Related projects
CSEF · 2003
The Need for Speed: Testing the Execution Speed of Today's Popular Computer Languages
CSEF · 2005
Which of Three Commonly Used Computer Programming Languages Performs the Fastest?
CSEF · 2009
Is the C or Assembly Programming Language Better for Programing PIC Microcontrollers?
CSEF · 2015
Combining Programming Languages to Improve Performance
CSEF · 2010
Turbo Charging Computer with Mathematical Algorithms
CSEF · 2002
The Double-Array Sort: A Study of C++ Sorting Methods
CSEF · 2008
Generating Random Numbers
CSEF · 2014
Cycle Speed: Testing Computer Processing Speed
Closest projects by meaning, across every fair and year in the corpus.
Browse more like this
Source: California Science & Engineering Fair public projects