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 Mathematics & Software · Entry J1216

Resources

Related projects

Closest projects by meaning, across every fair and year in the corpus.

Browse more like this

Source: California Science & Engineering Fair public projects

Save projects to your library

Sign in with Google to keep track of projects you find interesting, organized into folders. An account also raises your daily allowance for “Has this been done?”, and lets you create a key for the MCP server with a much higher limit than anonymous use. Browsing stays public.

Continue with Google