A funny trick to use C++ in C language program

By: IncludeHelp, on 29 JAN 2017

This is not a logical trick, this is a funny trick. Here we will lean how we can use C++ in a C language program?

Follow the given steps:

Step 1: Declare an integer variable with named "C".

Step 2: Assign the variable with 0.

int C=0;

Step 3: Now increase the value of C by using post increment operator.

C++;

Hence, you we can use "C++" in C programming language.

Here is the program:

#include <stdio.h>

int main()
{
	int C=0;
	C++;
	printf("C++: %d\n",C++);
	return 0;
}

Output

    C++: 1

Again I would say, this is not a logical program, we cannot use C++ concepts in C compiler, but we can use C language concepts in C++ program (compiler). The given program is just an example of variable declaration and post increment.

In this program we are just declaring and assigning a variable C with 0 and later, post increment operation is performing.


Related Tutorials




Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.