#include <iostream> using namespace std ; class Employee { int id; static int count; public: void setdata ( void ) { cout << "enter the id of the employee " ; cin >> id; count ++ ; } void getdata ( void ) { cout << "the id of the employee is " << id << " and the employee number is " << count << endl; } static void getcount ( void ){ // cout<<id; this will through and error because id is not a static varibale cout << "the value of count is " << count << endl; } //ye ek static member function hai jo dusre static varibales ya members ...
#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...
//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