Friday 28 October 2022

Overloading in C++ Programming Language |What is Function Overloading in C++ |Difference Between Function Overloading and Operator Overloading in C++

  - :  Overloading in C ++  :-


जब दो या दो से अधिक members का एक ही नाम होता है लेकिन अलग-अलग parameter या DataType होते हैं तो उन्हें C++ में ओवरलोडिंग कहा जाता है।

C++ में दो तरह के ओवरलोडिंग होते हैं

 1) फंक्शन ओवरलोडिंग (Function Overloading) 

 2) ऑपरेटर ओवरलोडिंग (Operator Overloading) 

 [नोट: - हम METHODS, CONSTRUCTORS and INDEX को Overload कर सकते हैं।]

1) फंक्शन ओवरलोडिंग (Function Overloading) 

              जब दो या दो से अधिक फंक्शन एक ही FunctionName वाले लेकिन अलग-अलग संख्या या प्रकार के पैरामीटर वाले हों तो फंक्शन ओवरलोडिंग कहलाते हैं। एक ही नाम वाले फ़ंक्शन को या तो विभिन्न प्रकार (डेटाटाइप) के मापदंडों या अलग-अलग संख्या के मापदंडों द्वारा फिर से परिभाषित किया जा सकता है।

           पैरामीटर या डेटाटाइप में ये अंतर compiler के लिए फंक्शन के बीच अंतर करने के लिए बनाए गए हैं, भले ही उनके पास एक ही फंक्शननाम हो।

 आइए एक उदाहरण के माध्यम से फंक्शन ओवरलोडिंग को समझते हैं:-

_____________________________________________________________


A program for Function Overloading with different number of parameters 


#include<iostream>

using namespace std ;

void Add(int X, int Y) {

                cout<< X+Y <<endl ;  

            } 

void Add(int X, int Y, int Z) {

              cout<< X+Y+Z <<endl ;

           } 

int main() {

       Add(10,20) // call function, having 2 parameters. 

         Add(10,20,50) ; //call function, having 3 parameters. 

return 0 ;

}

_____________________________________________________________

Output :-

                     30

                     80

_____________________________________________________________


A program for Function Overloading with different types (DataType) of parameters


#include<iostream>

using namespace std ;

void Add(int X, int Y) {

                  cout<< X+Y <<endl;

            } 

void Add(double X, int Y) {

                 cout<< X+Y <<endl ;  ;

           } 

int main() {

        Add(10,20)

       Add(10.7,20)

return 0 ;

}

_____________________________________________________________

Output :-

                     30

                     30.7

_____________________________________________________________



MUST READ :-

😍Function Overloading in C++ (English Explanation) 


😍 What is Operator in C++ programming language (English Explanation) 

 

😍what is Function in C++ Programming language (English Explanation) 


😍What is Class & Object in C++ programming language (Hindi Explanation) 


😍What is Class & Object in C++ programming language (English Explanation) 


😍What is Function in C ++programming language (Hindi Explanation) 













Friday 21 October 2022

Function Overloading in C++|What is Function Overloading in Programming Language, C++Overloading in Programming Language |Overloading in C++ |Function Overloading vs Operator Overloading

     - : Overloading in C++ :-

     When two or more members having same name but different parameters or datatypes are called Overloading in C++.


There are two types of overloading in C++

1)  Function Overloading 

2) Operator Overloading

[Note :- We Can Overload METHODS, CONSTRUCTORS and INDEX PROPERTIES.] 


1) Function Overloading

             When Two or More Functions having same FunctionName but different numbers or types parameters is called Function Overloading. Function with same name can be redefined by either different types(DataType) of parameters or different number of parameters.

          These differences in parameters or datatypes are made for compiler to differentiate the function even they are having same FunctionName. 

Let's Understand the Function Overloading through an example :-

_____________________________________________________________

A program for Function Overloading  with different number of parameters 


#include<iostream>

using namespace std ;

void Add(int X, int Y) {

                cout<< X+Y <<endl ;  

            } 

void Add(int X, int Y, int Z) {

              cout<< X+Y+Z <<endl ;

           } 

int main() {

       Add(10,20)        // call function, having 2 parameters. 

         Add(10,20,50)  ;        //call function, having 3 parameters. 

return 0 ;

}

_____________________________________________________________

Output :-

                     30

                     80

_____________________________________________________________



Output:-


_____________________________________________________________


A program for Function Overloading with different types (DataType) of parameters


#include<iostream>

using namespace std ;

void Add(int X, int Y) {

                  cout<< X+Y <<endl;

            } 

void Add(double X, int Y) {

                 cout<< X+Y <<endl ;  ;

           } 

int main() {

        Add(10,20)

       Add(10.7,20)

return 0 ;

}

_____________________________________________________________

Output :-

                     30

                     30.7

_____________________________________________________________



Output:-



_____________________________________________________________




Sunday 16 October 2022

Special Operator in c++, C Language |SizeOf Operator in C, C++ |What is Operator in C, C++ |Type of Operators in C Language, C++ |Operators in Programming Language |What is ope in programming Language

   - : sizeof() operator :-

     Operators are those symbols which are used between operands to perform Mathematical and Logical operations.

    sizeOf() is a keyword which is used to determine the size of the variable or datatype in bytes.

Syntax:-

                   sizeof (DataType) 

_____________________________________________________________

A program for SizeOf() operator


#include<iostream>

using namespace std ;

int main () {

       int a;

      float b;

      char c;

      double d;


cout<<"size of integer = " <<sizeof(a) <<endl;

cout <<"size of float = " <<sizeof(b) <<endl;

cout<<"size of char = " <<sizeof(c) <<endl ;

cout<<"size of double = " <<sizeof(d)  <<endl;

return 0 ;

}

_____________________________________________________________


Output :-

          size of integer = 4

          size of float = 4

         size of char = 1

         size of double =  8

_____________________________________________________________

must read other operators :-


What is Operator in Programming Language 

What is Arithmetic Operator in Programming Language 

What is Relational Operator in C, C++ programming languages 

What is Logical Operators in C, C++ Programming Language (English Explanation) 

What is Logical Operator in C, C++ Language (Hindi Explanation) 

What is Bitwise Operator in C, C++

increment Decrement Operators in Programming Language 

Conditional Operators in Programming Language C++

Assignment Operators in Programming Language C++ 













Monday 10 October 2022

Conditional Operator in C++, C Language |Tarnary Operator in C, C++ |What is Conditional Operator in Programming Language |What is Operator. in programming language |What is Operator in C, C++ |Types of Operator. in Programming Language, C, C++

      - : CONDITIONAL or TARNARY OPERATOR :-


   Operators are those symbols which are used between operands to perform Mathematical and Logical operations. 

    Conditional Operator is similar to the if_else Statement. We Can say that conditional operator is the sorter manner of writing if_else Statement.

    Conditional Operator include 2 following symbols -

    [?, :]

    For Example, we take 2 variables X=5 and Y=7. Now creating a condition X>Y. Let's see how it works - 

X>Y ? X is Greater : Y is Greater 

 let's understand what happened, we gave a conditional X>Y, but we can see X is actually not equal to Y. So (?) symbol means it checks the given condition is true or not and if condition is true, performs operation which is given. if condition is not true(means False) then performs another operation whatever is given. 

    In short, (?) works as if and (:) works as else

   __________________________________________________________

 A program to understand the Conditional Operator 

#include<iostream>

using namespace std ;

int main() {

      int X=5, Y=7;

(X>Y)?cout<<"X is greater than Y" :cout<<"Y is greater than X" ;

    return 0 ;

__________________________________________________________

Output :-

Y is greater than X

__________________________________________________________


MUST READ :-


What is Operator in Programming Language 

What is Arithmetic Operator in Programming Language 

What is Relational Operator in C, C++ programming languages 

What is Logical Operators in C, C++ Programming Language (English Explanation

What is Logical Operator in C, C++ Language (Hindi Explanation) 

What is Bitwise Operator in C, C++0

increment Decrement Operators in Programming Language 

___________________________________________________

What is Function in programming language 


What is Function in programming language (Hindi Explanation

___________________________________________________

What is Class in Programming language 


What is Class in Programming language (Hindi Explanation









Saturday 8 October 2022

Assignment Operators in Programming Language |Assignment Operators in c++, C Language |What is Assignment Operator in C language, C++ |What is Assignment operator in Computer Language |Types of Operators in Programming Language |What is Operator in C language, C++

 - : Assignment Operators :-

    Operators are those symbols which are used between operands to perform Mathematical and Logical operations.

    Assignment Operators are used to assign the values to the variable. Assignment Operator Includes Following Symbols giver below -

  • (+=)
  • (-=) 
  • (*=)
  • ( /=)
  • (%=)
  • (=) 
Keypoint 1:- 
        Data type of variable should be same as the value to be assigned.
For Example, 
             X += 10;
here X containing an integer type data, so it is mandatory to specify the Data type of the variable. so now it will be written as - 
      int X += 10;
 
Keypoint 2:- 
          In the assignment operator, variable performs operation on current value and then the result assigned to that variable which becomes original value of the variable. 
For Example, 
        suppose X = 10;
              now we want to perform X += 5 using (+=) operator. 
So here meaning of X+=5 is that 
                  X = X+5;
                 X = 10 + 5;            //we took X = 10 for example 
                 X = 15;                 //now further operation we be performed by                                                      assuming the value of X as 15. 

_____________________________________________________________
A program to understand Assignment Operators 

#include<iostream>
using namespace std ;
int main(){
       int X = 10;
       cout<<"now value of X after performing (X+=5) Will be = " <<X+=5 <<endl ;                    //X = X+5,
       cout<<"now value of X after performing (X-=3) Will be = " <<X-=3  <<endl ;                    //X = X-3,
       cout<<"now value of X after performing (X*=4) Will be = " <<X*=4 <<endl ;                   //X = X*4,

       cout<<"now value of X after performing (X/=2) Will be = " <<X/=2 <<endl ;                    //X = X/2,
       cout<<"now value of X after performing (X%=8) Will be = " <<X%=8 <<endl ;                   //X = X%8,

      return 0 ;
_____________________________________________________________
Output :-
now value of X after performing (X+=5) Will be = 15
now value of X after performing (X-=3) Will be = 12
now value of X after performing (X*=4) Will be = 48
now value of X after performing (X/=2) Will be = 24
now value of X after performing (X%=8) Will be = 0

_____________________________________________________________

























Wednesday 5 October 2022

Increment Decrement Operators in C, C++ |Increment Decrement Operators in Programming Language |What is Increment Decrement Operators in Programming Language |Increment Decrement Operators in Computer Language |Types of Operators in Programming Language |Operators in C, C ++

    - : Increment - Decrement Operators :-

    These are Unary Operators (For single Operands) used to increase or decrease the value of operand by adding or subtracting 1 respectively. 

increment Operator - 

     increment Operator is used to increase the value of operand. Symbol of increment operator is double plus (++).

      There are 2 types of increment operator -

      (1) Pre-increment

      (2) Post-increment

   Pre-increment operator is used to increase operand value by 1, before assigning it to the expression. In pre-increment (++) used before operand.   Ex:-  (++a) 


value                      actual value                    visible value in output

++10                             11                                        11


   Post-increment operator is used to increase operand value by 1, after assigning it to the expression. In post-increment (+ +) used before operand.   Ex:-  (a++) 


 value                       actual value                     visible value in output

10++                               11                                         10


___________________________________________________________

A program for Increment operator 


#include <iostream>

using namespace std ;

int main () 

{  

     // declare integer variables  

int a = 10;

 cout<< "visible value of a after using Pre-increment = " << ++a <<endl;                       //Pre-increment 

cout<< "visible value of a after using Post-increment = " << a++ ;                                  //Post-increment 

return 0;  

}  

______________________________

Output -

visible value of a after using Pre-increment = 11

visible value of a after using Post-increment = 10

___________________________________________________________

Decrement Operator - 

     Decrement Operator is used to decrease the value of operand by 1. Symbol of decrement operator is double minus (- -).

      There are 2 types of increment operator -

      (1) Pre-decrement

      (2) Post-decrement

   Pre-decrement operator is used to decrease operand value by 1, before assigning it to the expression. In pre-decrement (- -) used before operand.   Ex:-  (- - a) 


value                       actual value                     visible value in output

- -10                               9                                          9


   Post-decrement operator is used to decrease operand value by 1, after assigning it to the expression.In post-decrement (- -) used after operand. Ex:- (a- -) 



 value                        actual value                      visible value in output

10- -                                 9                                          10


___________________________________________________________

A program for Decrement operator 

#include <iostream>

using namespace std ;

int main () 

{  

     // declare integer variable 

int a = 10;

 cout<< "visible value of a after using Pre-decrement = " << ++a <<endl;                        //Pre-decrement 

cout<< "visible value of a after using Post-decrement = " << a++ ;                                    //Post-decrement 

return 0;  

}  

______________________________

Output -

visible value of a after using Pre-decrement = 9

visible value of a after using Post-decrement = 10

___________________________________________________________






Must Read :-

What is Operator in Programming Language 


What is Arithmetic Operator in Programming Language 


What is Relational Operator in C, C++ programming languages 


What is Logical Operators in C, C++ Programming Language (English Explanation


What is Logical Operator in C, C++ Language (Hindi Explanation


What is Bitwise Operator in C, C++






Sunday 2 October 2022

What is Bitwise Operator in C++, C Language|BITWISE OPERATOR in C++ |Bitwise Operator in Programming Language |Bitwise Operator in Computer Language |Bitwise Operator in C language, C++ |What is Operator in programming Language |Types of Operators in Programming Language |Types of Operators in C Language, C++

 - :  Bitwise Operator :-


    Operators are those symbols which are used between operands to perform Mathematical and Logical operations. 


    Bitwise Operators are those operators which are used to perform operations on integer values at the bit-level. This Operator includes Following Symbols - 

  • Bitwise And  [&] 
  • Bitwise Or  [|] 
  • Bitwise XOR  [^] 
  • Bitwise Complement Operator [~] 
  • Bitwise Left Shift Operator [<<] 
  • Bitwise Right Shift Operator [>>] 

    When we execute a program using Bitwise Operators. in this case first of all, the given Decimal Variables get converted into binary format and operation takes place between those converted binary numbers according to the symbol used. After performing operation whatever result comes in binary format, simply converted into decimal format and displayed on the screen. 

  1. Bitwise And (&) operator :- 
           if Both operands are "1", the output will be "1".if anyone of them is "0",the output will be "0".

  A                 B                      Output 
1                       1                           1      
    1                       0                           0          
0                       1                           0      
0                       0                           0      
For Example
let  A    = 10 (in Decimal)    =   1010 (in Binary) 
      B    = 14 (in Decimal)    =  1110 (in Binary)
                                             __________________
                                    1000 (in Binary)  = 8 (in Decimal) 

2. Bitwise Or ( | ) Operator :-

          if atleast one operand is "1", the output will be "1". if both operands are "0",the output will be "0".

                                    A         |            B                       Output 

 1                        1                            1      

    1                        0                            1          

0                        1                            1      

0                        0                            0      

For Example

       let A = 10 (in Decimal) = 1010 (in Binary) 

             B = 14 (in Decimal) = 1110 (in Binary)

                                            ___________________

                                                1110 (in Binary) = 14 (in Decimal) 


3. Bitwise XOR (^) Operator :-

           when both operators are "1 - 1" or "0 - 0", it return "0" in the Output. If both operators are not same then the output will be "1".

                                       A           ^              B                        Output 

 1                         1                             0      

    1                         0                             1          

0                         1                             1      

0                         0                             0      

For Example - 

       let A = 10 (in Decimal) = 1010 (in Binary) 

             B = 14 (in Decimal) = 1110 (in Binary)

                                            ___________________

                                              0100 (in Binary) = 4 (in Decimal) 


4. Bitwise Complement (~) Operator :- 

         it is a unary operator (works only on single operand). it converts "1" into "0" where "0" into 1.

          A                     ~A

           1                      0

           0                      1


5. Bitwise Right Shift (>>) Operator :-

        This Operator Shifts all the bits towards right hand side by the specified number of positions in bits. (eg. >>1means 1 bits, >>2 means 2 bits, >>3 means 3 bits and so on  towards right hand side.) 

       On shifting specified bits right hand side, Left bits will be vacant. These Vacant place will be filled by "0" automatically. 


6. Bitwise Left Shift (<<) Operator :-

         This Operator Shifts all the bits towards left hand side by the specified number of positions in bits. (eg. >>1means 1 bits, >>2 means 2 bits, >>3 means 3 bits and so on toward left hand side.) 

        On shifting specified bits left hand side, right bits will be vacant. These Vacant place will be filled by "0" automatically. 


__________________________________________________________

Must Read :- 

What is Operator in Programming Language 


What is Arithmetic Operator in Programming Language 


What is Relational Operator in C, C++ programming languages 


What is Logical Operators in C, C++ Programming  Language (English Explanation) 


What is Logical Operator in C, C++ Language (Hindi Explanation) 







Saturday 1 October 2022

What is Logical Operator in C, C++ Hindi Explain |What is Operators in C Language, C++, Python, JavaScript |What is Logical Operator in Programming Language Explain in hindi, Logical Operators |Types Of Operators in Programming Language |What is Logical Operator in Computer

      - :   Logical Operator   :-


   Operators वे प्रतीक(symbols) हैं जिनका उपयोग Operands के बीच गणितीय(mathematical) और तार्किक(Logical) संक्रियाओं(operations) को perform करने के लिए किया जाता है।


    Logical Operators वे ऑपरेटर होते हैं जिनका उपयोग दो या दो से अधिक दिए गए कथनों या शर्तों(conditions) के बीच तार्किक(Logical) संचालन करने के लिए किया जाता है ताकि यह समझ में आ सके कि दी गई शर्तें सही हैं या नहीं।  

   ये Operators हमें आउटपुट के रूप में Boolean Value(True या False)  देते हैं। यदि दी गई condition सत्य है, तो प्रदर्शित आउटपुट 1 होगा जहां यदि दी गई condition सत्य नहीं है (मतलब गलत है), तो आउटपुट 0 होगा।

          जहां, 1 का अर्थ है True

                  0 का अर्थ है False 

Logical Operators में निम्नलिखित प्रतीक शामिल हैं -

[&&(logical And) , ||(logical Or) , !(logical Not)] 


   &&(logical and) operator में , यदि दी गई सभी शर्तें true हैं, तो आउटपुट "1" होगा और यदि दी गई शर्तों में कोई भी गलत हो जाता है, तो आउटपुट "0" होगा।

Condition1     & &      Condition2             Output 

true          true            true

true           false         false

false           true         false

false         false          false


ll (Logical or) ऑपरेटर में, या तो कोई भी या सभी दी गई शर्तें सत्य(true) हैं, तो Output "1" होगा। यदि शर्तों में कुछ भी सत्य नहीं है तो Output "0" होगा।

Condition.        ll       Condition.               Output 

true            true          true

true            false         true

false           true           true

false           false         false


 !(Logical not) में, यदि दी गई शर्तें "True" हैं, तो प्रदर्शित आउटपुट "0" होगा। यदि दी गई शर्तें "False" हैं, तो आउटपुट "1" होगा।

                    !(Condition)                       Output          

                       true              false

         false              true       


_________________________________________________________

Logical Operators को समझने के लिए एक program - 


#include<iostream>

using namespace std ;

int main() {

      int a=5, b=4, c=7, d=9;

      cout<<(a>b)&&(c>d) <<endl;

      cout<<(a>b)||(c>d) <<endl;

      cout<<!(a>b) ;

return 0;

}


_________________________________________________________


Output :-

      0  

      1

      0

_________________________________________________________


आइए समझते हैं कि ऊपर क्या हुआ - 


         शुरू में हमने दो शर्तों(conditions) को पारित किया, जहां शर्त -1 (a>b) है जो "True" है और शर्त -2 (c>d) है, जो कि गलत है।


(1)LOGICAL AND ऑपरेटर का उपयोग करने पर,

            true & & false = false


(2)LOGICAL OR ऑपरेटर का उपयोग करने पर,

            true || false = true 


(3)LOGICAL NOT ऑपरेटर का उपयोग करने पर,

             !(true) = false


     where, true = 1 

       false = 0


_________________________________________________________

इसे अवश्य पढ़ें(Click on the link below ) :-


What is Operator in Programming Language 

What is Arithmetic Operator in Programming Language 

What is Relational Operator in C, C++ programming languages 

What is Logical Operators in C, C++ Programming Language (English Explanation) 

What is Bitwise Operator in C, C++


What is Function in programming language 

What is Function in programming language (Hindi Explanation) 








Logical Operations in C++ |What is Logical Operator in C Language, C++ |What is Operator in C Language |What is Operator in programming Language |What is Operator in Computer |What is Logical Operator

 - :  Logical Operator  :-


  Operators are those symbols which are used between operands to perform Mathematical and Logical operations. 


   Logical Operators are those operators which are used to perform logical operations between two or more given statements or conditions to make sense that the given conditions are true or not.

   these operators gives us boolean (true or false) value as Output. if given condition is true, the displayed output will be 1 where if given condition is not true (means false), so the output will be 0.

     where,  1 means True

                    0 means False.

  Logical Operators includes following Symbols - 

[&&(logical And) , ||(logical Or) , !(logical Not)] 


in &&(logical and) operator, if given all the condition are true, then output will be true And if anyone in given conditions becomes false, then output will be false. 

Condition1.      & &     Condition2.             Output 

true         true           true

true          false        false

false          true        false

false        false         false



in ll(logical or) operator, either anyone or all the given conditions are true, then output will be true. if anything in the conditions is not true then output will be false. 

Condition1.       ll      Condition2.              Output 

true           true         true

true           false        true

false          true          true

false          false        false


in !(logical not)if given conditions are "true" , the displayed output will be "false". if given conditions are "false" , the output will be "true".

                    !(Condition)                      Output          

                       true             false

         false             true       

_________________________________________________________

A Program to understand logical operators


#include<iostream>

using namespace std ;

int main() {

      int a=5, b=4, c=7, d=9;

      cout<<(a>b)&&(c>d) <<endl;

      cout<<(a>b)||(c>d)  <<endl;

      cout<<!(a>b) ;

return 0;

}

_________________________________________________________

Output :-

      0  

      1

      0

_________________________________________________________

let's understand what happened above

        initially we passed two conditions, where condition-1 is (a>b) which is "true" and condition-2 is (c>b), which is false. 

(1)using LOGICAL AND operator,    

           true   & &   false  =    false

(2)using LOGICAL OR operator, 

          true   ||      false  =     true 

(3)using LOGICAL NOT operator, 

         !(true)    =    false

   

     where,   true = 1 

                   false = 0

_________________________________________________________

Must Read(click on the link below) :-


What is Operator in Programming Language 

What is Arithmetic Operator in Programming Language 

What is Relational Operator in C, C++ programming languages 

What is Logical Operator in C, C++ Language (Hindi Explanation) 

what is Bitwise Operator in C, C++