
Comparison and an example of variable declaration in C and C ++?

variable declaration in c syntax
#include <stdio.h>
int main(void)
{
int money;
money = 10000;
printf("My salary is %d.", money);
return 0;
}
variable declaration in c++ syntax
// operating with variables
#include <iostream>
using namespace std;
int main ()
{
// declaring variables:
int a, b;
int result;
// process:
a = 5;
b = 2;
a = a + 1;
result = a - b;
// print out the result:
cout << result;
// terminate the program:
return 0;
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.