This is a simple program and my question is to know why is it compulsory to use using namespace std ? why program is not complied without using this ?
#include
using namespace std;
int main(){
int a , b , c , d;
cout << "Enter First Value" < cin >> a;
cout << "Enter Second Value" < cin >> b;
cout << "Enter 1 to add values" << endl << "Enter 2 to subtract values" < cin >> c;
if (c == 1){
d = a + b;
cout << "After Adding your answer is " << d << endl;
}
else if (c == 2){
d = a - b;
cout << "After Subtracting your answer is " << d << endl;
}
else if (c == 3){
d = a * b;
cout << "After Multiplication your answer is " << d << endl;
}
else{
cout << "You Enter Invalid operation to perform";
}
system("pause"); //buitin function to stop the comand screen.
return 0;
}
No comments:
Post a Comment