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
Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.
What is the difference between procedural programming and oops?
How Do you Code Composition and Aggregation in C++ ?
Why is abstraction used?
What is polymorphism used for?
What is encapsulation in oops?
What is multilevel inheritance in oop?
Why do we use oops?
What type of loop is a for loop?
What do you mean by overloading?
Which type does string inherit from?
What is class and example?
What are the 4 main oop principles?
Why is abstraction needed?
What are the features of oop?