If we add a string literal before any other datatype such as integer or float etc then the compiler will treat all other datatypes as a string and the output that will be printed is
102030
The compiler will simply concatenate the string and will print the output.
But on the other side, If we add the integer values before and the string literal later on then the compiler will add both of the integer values and concatenate the string literal. In this case, the output that will be printed by the compiler is 5010.
#include<iostream> using namespace std; int main() { cout<<" enter any number"; cin>>num; if(num>0) { cout<<"The absolute value of number is:"<< num; } else { cout<<"The absolute value of number is :"<< -(num); } return 0; } OUTPUT Enter Any number: 2 The absolute value of number is 2
Comments
Post a Comment