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
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout< Why multiple inheritance is not allowed? What is coupling in oops? What is class and object with example? What makes a language oop? What is difference between pop and oop? What is inheritance and how many types of inheritance? What is use of overloading? What is constructor overloading in oop? What is overloading in oop? What is purpose of inheritance? Following are the class specifications:
class {int a};
class {int b};
Using friend funtion,calculate the max of two objects and
display it.
What does I oop mean? What is object and example? This program numbers the lines found in a text file. Write a
program that reads text from a file and outputs each line
preceded by a line number. Print the line number
right-adjusted in a field of 3 spaces. Follow the line
number with a colon, then one space, then the text of the
line. You should get a character at a time and write code to
ignore leading blanks on each line. You may assume that the
lines are short enough to fit within a line on the screen.
Otherwise, allow default printer or screen output behavior
if the line is too long (i.e., wrap or truncate). A somewhat
harder version determines the number of spaces needed in the
field for the line numbers by counting lines before
processing the lines of the file. This version of the
program should insert a new line after the last complete
word that will fit within a 72-character line.