You are not logged in. Please login at www.codechef.com to post your questions!

×

# C or C++ which is better ?

 0 Which is better to participate and solve more problems easily - C or C++, and why ? asked 25 Jan '13, 23:30 40●11●13●13 accept rate: 0%

 4 C++ is better because of STL and object oriented programming support and also you can use it like C(scanf and printf). answered 30 Mar '16, 18:46 3★sahil_g 298●1●4 accept rate: 16%
 3 Advantages of C++ over C - 1) Supports OOP(Object Oriented Programming) 2) Standard Template Library 3) Many other in-built templates answered 31 Mar '16, 10:24 5★hm_98 280●6 accept rate: 0%
 3 C is widely used for Operating Systems, Kernels, other system softwares etc but for competitive programming, C++ is better as it gives OOP support, STL and you can use fast I/O even while writing cin/cost using "ios:sync _ with _ stdio(false)" or other related statements. answered 31 Mar '16, 11:15 56●4 accept rate: 25%
 1 C++ because of STL. STL involves many inbuilt functionality which is otherwise time consuming if implemented in C. For example algorithms like Dijkstra's Algorithm can be easily implemented with the help of STL in C++. answered 25 Jan '13, 23:46 254●5●7●10 accept rate: 14% Thanks sir.....but I have seen many codes written in both C and C++....and the same code written in c++ are longer then C ?? (25 Jan '13, 23:55) The code you write depends on your algorithm and the length doesnt matter. Moreover I think the codes in C++ that you have seen might have included many libraries and macros thus making the code look bigger. (26 Jan '13, 00:09) Thanks sir.....what exactly is STL and macros are ?? (26 Jan '13, 00:13)
 1 STL stands for standard template library . It gives you in-built functions that you may use time and again.For example if you have a vector say vector vec (that's the syntax for a vector) and you want to sort it . In normal codes, you'll perform merge sort etc. , which is time consuming. But, if you are using STl , then your vector gets sorted by the function called sort() . And, syntax would be , sort(vec.begin(),vec.end()) . So, that's all you would have to type and you get a sorted vector. Plus, using vector's and standard containers you get lesser segmentation faults. Similarly, there are many inbuilt templates for functions like sort,count, for data structures like stack etc. Here are some links , that may prove helpful : 1.http://www.sgi.com/tech/stl/ 2.http://www.cplusplus.com/reference/stl/ I guess stl will help you code faster and it gives more focus on your problem , as you don't need to worry about algo's for functions like sort etc. Regarding macro's , it's another way to reduce your code , say you are using you want to find the maximum of two numbers again and again , you need not call a function , instead you can invoke the pre-processor directive #define MAX(a,b) (a > b) ? a : b , which will return maximum of two numbers. But, use of macro's is your own choice. So, I think c++ might be a better option considering the presence of stl. answered 26 Jan '13, 09:14 2★ani94 529●2●4●10 accept rate: 5% When dealing with macros, use proper parenthesis. Otherwise, you get unwanted results!!! #define MAX(a,b) ((a) > (b) ? (a) : (b)) (26 Jan '13, 13:33)
 0 I would say also c++ because of Standard Template Library. answered 24 Feb '16, 11:20 1 accept rate: 0%
 0 functionality vise C++ is better than . but to prepare for studies and to start programming i would recommend C.. Java can be used instead of C++, But C has no alternate. C is the obvious choice to many code starters and build programming skill and Mostly C is used. answered 29 Feb '16, 22:00 1●1 accept rate: 33%
 0 C++ is better than C because its support object oriented programming we create class and object of that class. there are many useful concept in C++ like friend function, Inheritance, polymorphism,Interface. also we can protect our data members answered 22 Mar '16, 22:20 0★abhi7709 1 accept rate: 0%
 0 There is no such thing like comparing C with C++. C stands for kernel, drivers and Operating Systems where C++ doesn't. Please stop comparing them....or saying that C++ is better than C. answered 31 Mar '16, 03:10 0★tara24 26●1 accept rate: 16%
 0 C++ was developed by Bjarne Stroustrup in 1983 at Bell Labs , as a "better C". C++ was an attempt to extend and to some extent change the C programming language to overcome some of the common problems with the language. i.e C++ is C incremented. Features of C++ C++ is an intermediate-level language C++ Supports principle of object oriented paradigm. C++ gives access to lower-level functionality than other language C++ have huge Function Library C++ joins three separate programming categories:  - the procedural language, represented by C. - the object-oriented language, represented by the class enhancements C++ adds to C. - generic programming, supported by C++ templates.  C++ is very easy to read and write. answered 12 Nov '16, 20:35 2★rashedcs 497●6●17●55 accept rate: 4%
 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,917
×1,664
×1,490
×148

question asked: 25 Jan '13, 23:30

question was seen: 3,993 times

last updated: 12 Nov '16, 20:35