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
How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction
What is multilevel inheritance?
What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?
What is polymorphism and why is it important?
What are the 4 pillars of oop?
2. Give the different notations for the class.\
What is the difference between a constructor and a destructor?
Which type does string inherit from?
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout< What does oop mean in snapchat? What is abstraction oop? Where You Can Use Interface in your Project What is encapsulation c#? Get me an image implementation program. What is static modifier?