Macro Preprocessor C C++ Programming Languages Header Files Macro Conditional Compilation Program Compiler
Macro Preprocessor C C++ Programming Languages Header Files Macro Conditional Compilation Program Compiler
languages. The preprocessor provides the ability for the inclusion of header files, macro
expansions, conditional compilation, and line control.
In many C implementations, it is a separate program invoked by the compiler as the first part of
translation.
The language of preprocessor directives is only weakly related to the grammar of C, and so is
sometimes used to process other kinds of text files.
2.
#include <iostream>
#include<conio.h>
using namespace std;
// Class Declaration
class person
{
//Access - Specifier
public:
//Varibale Declaration
string name;
int number;
};
//Main Function
int main()
{
// Object Creation For Class
person obj;
//Get Input Values For Object Varibales
cout<<"Enter the Name :";
cin>>obj.name;
cout<<"Enter the Number :";
cin>>obj.number;
//Show the Output
cout << obj.name << ": " << obj.number << endl;
getch();
return 0;
2.
#include <iostream>
using namespace std;
int main ()
{
int i;
cout << "Please enter an integer value: ";
cin >> i;
cout << "The value you entered is " << i;
cout << " and its double is " << i*2 << ".\n";
return 0;
}
3.
// stringstreams
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main ()
{
string mystr;
float price=0;
int quantity=0;
cout << "Enter price: ";
getline (cin,mystr);
stringstream(mystr) >> price;
cout << "Enter quantity: ";
getline (cin,mystr);
stringstream(mystr) >> quantity;
cout << "Total price: " << price*quantity << endl;
return 0;
}