what is the main difference between c and c++?

Answer Posted / deepesh kumar prajapati

The main difference b/w c and c++ is that " in 'c' language
we declaration any variable after main () compulsory but in
c++ any variable declaration wherever "
for ex:-

in 'c' program eg.

#include<stdio.h>
void main()
{
int a,b;
printf("enter any no.=");
scanf("%d",&a);
b=a*a;
printf("square is=%d",b);
}


In c++ eg.


#include<iostream.h>
void main()
{
int a;
cout<<"enter any no";
cin>>a;
int b=a*a;
cout<<"square is="<<b;
}

note;-
both program is same (square any no.) only difference
is first program b is declare after main() an second program
b is declared after scan value.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.

2012


What is the difference between procedural programming and oops?

561


How Do you Code Composition and Aggregation in C++ ?

24214


Why is abstraction used?

612


What is polymorphism used for?

578






What is encapsulation in oops?

541


What is multilevel inheritance in oop?

559


Why do we use oops?

597


What type of loop is a for loop?

688


What do you mean by overloading?

586


Which type does string inherit from?

618


What is class and example?

571


What are the 4 main oop principles?

687


Why is abstraction needed?

571


What are the features of oop?

641