what is the main difference between c and c++?
Answer Posted / ravi kumar martha
1. C is a general programming language. C++ is an Object
Oriented variant of C.
2.C++ was based on C and retains a great deal of the
functionality.
C++ does not retain complete source-level compatability
with C.
3.
In C, there's only one major memory allocation function:
malloc. You use it to allocate both single elements and
arrays and you always release the memory in the same way.
In C++, however, memory allocation for arrays is somewhat
different than for single objects.
you use the new[] operator, and you must match calls to new
[] with calls to delete[] (rather than to delete).
4.Although most good C code will follow this convention, in
C++ it is strictly enforced that all functions must be
declared before they are used. This code is valid C, but it
is not valid C++.
5.You have to include the struct keyword before the name of
the struct type to declare a struct: In C++, you could do
this, and have a new instance of a_struct called
struct_instance. In C, however, we have to include the
struct keyword when declaring struct_instance
6.you must include the keyword enum; in C++, you don't have
to. As a side note, most C programmers get around this
issue by using typedefs.
7.C++ has a much larger library than C, and some things may
be automatically linked in by C++ when they are not with C.
For instance, if you're used to using g++ for math-heavy
computations, then it may come as a shock that when you are
using gcc to compile C, you need to explicitly include the
math library for things like sin or even sqrt.
8.C does not provide a native boolean type. You can
simulate it using an enum, though.
9.In C++, you are free to leave off the statement 'return
0;' at the end of main; it will be provided automatically.
| Is This Answer Correct ? | 15 Yes | 9 No |
Post New Answer View All Answers
Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.
Why do while loop is used?
What does and I oop and sksksk mean?
What is object and class in oops?
What is difference between pop and oop?
Why is polymorphism used?
What is constructor in oop?
Objective The objective of this problem is to test the understanding of Object-Oriented Programming (OOP) concepts, in particular, on encapsulation. Problem Description Create a program for managing customer’s bank accounts. A bank customer can do the following operations: 1. Create a new bank account with an initial balance. 2. Deposit money into his/her account. 3. Withdraw money from his/her account. For this operation, you need to output “Transaction successful” if the intended amount of money can be withdrawn, otherwise output “Transaction unsuccessful” and no money will be withdrawn from his/her account. Input The input contains several operations and is terminated by “0”. The operations will be “Create name amount”, “Deposit name amount”, or “Withdraw name amount”, where name is the customer’s name and amount is an integer indicating the amount of money. There will be at most 100 bank accounts and they are all created on the first month when the bank is opening. You may assume that all account holders have unique names and the names consist of only a single word. Output The output contains the transaction result of withdrawal operations and the final balance of all customers after some withdrawal and deposit operations (same order as the input). Sample Input Create Billy 2500 Create Charlie 1000 Create John 100 Withdraw Charlie 500 Deposit John 899 Withdraw Charlie 1000 0
class type to basic type conversion
What is super in oop?
Is react oop?
Why is destructor used?
How does polymorphism work?
write a programe to calculate the simple intrest and compund intrest using by function overlading
Why do we use inheritance?