//program to add two numbers without namespace
#include <iostream>//header file
#include<stdlib.h>//header file for system("cls")
//no namespace here!
int main()
{
int number1,number2;
std::cout<<"enter two numbers"<<std::endl;//prints message to input numbers.we must use std.
std::cin>>number1>>number2; //gets inputs using chaining concept.we must use std.
system("cls"); //clears the screen
std::cout<<"number1="<<number1<<std::endl<<"number2="<<number2<<std::endl;//we must use std.
std::cout<<"their sum="<<number1+number2<<std::endl;//we must use std.
return 0;
}
//note: If we do not use namespace or if we donot use "using namespace std;" before int main() then we must useconds_t
// std before all standard characters/words. Otherwise, It will not work.
#include <iostream>//header file
#include<stdlib.h>//header file for system("cls")
//no namespace here!
int main()
{
int number1,number2;
std::cout<<"enter two numbers"<<std::endl;//prints message to input numbers.we must use std.
std::cin>>number1>>number2; //gets inputs using chaining concept.we must use std.
system("cls"); //clears the screen
std::cout<<"number1="<<number1<<std::endl<<"number2="<<number2<<std::endl;//we must use std.
std::cout<<"their sum="<<number1+number2<<std::endl;//we must use std.
return 0;
}
//note: If we do not use namespace or if we donot use "using namespace std;" before int main() then we must useconds_t
// std before all standard characters/words. Otherwise, It will not work.
No comments:
Post a Comment