void main()
{
clrsrc();
char ch1, ch2,sum;
ch1='A';
ch2='B';
cout<<''Characters are:''<<ch1<<ch2;
getch();
}
Also getting error on these code on compiling
(b) The above two codes are which one belongs to c and which one to C++?
Question no.2
(a)I want to know that this site is teaching c or C++ language?
(b)i am the beginner and can't understand the differentiation both of these two. what is difference among them?
You can use any C stuff in a C++ program, however if it is exclusively C stuff then it's a C program.
If it has cout in it, then it's definitely C++, because you can't do that in C.
and the way main() is written as
1 2 3 4
int main()
{
return EXIT_SUCCESS;
}
tells me the same thing too
well that looks exactly like C to me, why would you think it was C++ ?
as for code 2: You are probably right. I was looking at void main() and jumped to conclusion it was C
I am not sure but void main() would have probably been at least a warning in C, if not an error. Different in C++, apparently since C99, one has been allowed to do this sort of thing - no return statement at end of main either.
AFAIK C programs are like this:
1 2 3 4 5 6
int main(int argc, char *argv[])
{
printf ("This is a computer age.");
return 0;
}
edit: main returns an int
The argc and argv stuff is optional and you can do that in C++
too.
The EXIT_SUCCESS and similar stuff are just another way of returning a value to the OS.
I guess I am stuck in the mud a bit - I started C programming in 1987 so that's why I have this on the brain:
1 2 3 4 5 6
int main(int argc, char *argv[])
{
printf ("This is a computer age.");
return 0;
}
And still do it that way.
Apart from all that, what grabbed my attention was you were calling a program with cout in it a C program which is definitely wrong, and the other program was clearly C.