#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...
//code for factorial #include <iostream> using namespace std ; int factorial ( int y ) { if (y <= 1 ){ return 1 ; //ye nhi btaenge to infinitely chalta rahega } return y * factorial (y - 1 ); } int fib ( int y ) { if (y <= 2 ){ return 1 ; } return fib (y - 1 ) + fib (y - 2 ); } // fibonacci sequence int main (){ int x; // cout<<"enter the number whose factorial u wanna find "; // cin>>x; // cout<<"the factorial of "<<x<<" is "<<factorial(x)<<endl; cout << "enter the term u wanna find out in the fibonacci sequence" << endl; cin >> x; cout << "the term in fibonacci sequence at position " << x << " is " << fib (x); retur...
Comments
Post a Comment