#include <iostream> using namespace std ; int sum ( int a , int b ){ cout << "by function1 is " ; return a + b; } int sum ( int a , int b , int c ){ cout << "by function2 is " ; return a + b + c; } int volume ( int a ){ return a * a * a; } int volume ( int r , int h ){ return 3.14 * r * r * h; } int volume ( int l , int b , int h ){ return l * b * h; } int main (){ cout << "the sum of 5 and 7 " << sum ( 5 , 7 ) << endl; cout << "the sum of 5, 7 and 57 " << sum ( 5 , 7 , 57 ) << endl; cout << "the volume of cube of side length 5 is " << volume ( 5 ) << endl; cout << "the volume of cylinder of radius 5 and height 7 is " << volume ( 5 , 7 ) << endl; cout << "the volume of cuboid of length 5, bredth 7...
#include <iostream> using namespace std ; // int product(int a, int b) // { // int c = a*b; // return c; // } /***********INLINE FUNCTION********* */ /*C++ provides inline functions to reduce the function call overhead. An inline function is a function that is expanded in line when it is called. When the inline function is called whole code of the inline function gets inserted or substituted at the point of the inline function call. This substitution is performed by the C++ compiler at compile time. An inline function may increase efficiency if it is small.*/ //bade functions m inline function use nhi krna as vo pura replace hojaega //call ki jagah so zyada memory khaega //incline function ek request hoti hai to the compiler, compiler decide krta hai vo requst accept krni ya nahi inline int product ( int a , int b ) { int c = a * b; //use of static variables is n...
#include <iostream> using namespace std ; int c = 15 ; //global variable int main (){ int a , b ; //local variables (preference is given to local variables) cout << "enter the value of a: " << endl ; cin >> a ; cout << "enter the value of b: " << endl ; cin >> b ; int c = a + b ; cout << "the sum is " << a + b << endl ; cout << "the value of c is " << :: c << endl ; //this (::) is scope resolution operator, it is used to print a global variable inside the function //LITERALS IN C++ //float x=5.7; //long double y=5.7; //now 5.7 is a double by default by the compiler, we can use specific keywords to make a variable float double or long double //cout<<"the value of x is "<<x<<endl<<"the value of y is "<...
Comments
Post a Comment