Overload Operators Hacker Rank

 

//Operator Overloading

#include<iostream>

using namespace std;

class Complex
{
public:
    int a,b;
    void input(string s)
    {
        int v1=0;
        int i=0;
        while(s[i]!='+')
        {
            v1=v1*10+s[i]-'0';
            i++;
        }
        while(s[i]==' ' || s[i]=='+'||s[i]=='i')
        {
            i++;
        }
        int v2=0;
        while(i<s.length())
        {
            v2=v2*10+s[i]-'0';
            i++;
        }
        a=v1;
        b=v2;
    }
};
Complex operator +(Complex t1,Complex t2){
    Complex c;
    c.a=t1.a+t2.a;
    c.b=t1.b+t2.b;
    return c;
}

ostream &operator <<(ostream &out, Complex &c1){
    out<<c1.a<<"+i"<<c1.b;
    return out;
}
//Overload operators + and << for the class complex
//+ should add two complex numbers as (a+ib) + (c+id) = (a+c) + i(b+d)
//<< should print a complex number in the format "a+ib"

int main()
{
    Complex x,y;
    string s1,s2;
    cin>>s1;
    cin>>s2;
    x.input(s1);
    y.input(s2);
    Complex z=x+y;
    cout<<z<<endl;
}


How to transfer values to modal


Here is my field from where we want to send values to modal


<a  href="<?= '/permissions/edit/'.$permission['id']; ?>">
<button class="btn btn-info btn-icon  btn-icon-mini btn-round"><i class="zmdi zmdi-edit">
  </i></button></a>
</a>     

                                 

-------------------------------------It is our modal---------------------------------

<div class="modal fade" id="modal_popup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog modal-sm" role="document">
         <form action="<?php echo base_url(); ?>/permissions/status_changed" method="post">
            <div class="modal-content">
               <div class="modal-header" style="height: 150px;">
                  <h4 style="margin-top: 50px;text-align: center;">Are you sure, do you change status?</h4>
                  <input type="hidden" name="id" id="user_id">
                  <input type="hidden" name="status" id="user_status">
               </div>
               <div class="modal-footer">
                  <button type="button" class="btn btn-danger pull-left" data-dismiss="modal">No</button>
                  <button type="submit" name="submit" class="btn btn-success">Yes</button>
               </div>
            </div>
         </form>
      </div>
   </div> 

 //Our Jquery Code

<script type="text/javascript">
       $(function() {
   //For Status Update
    $(".user_status").on("click", function() {
        var firstValue = $(this).data('uid');
        //alert(firstValue);
        var secondValue = $(this).data('ustatus');
        $("#user_id").val(firstValue);
        $("#user_status").val(secondValue);
    });
   
});

    </script>

Javascript Code to take input and send input to other input field using getElementbyid

 Code to insert one value from one input to another

<script>
 function send_data(){                
 var data = document.getElementById('service_option').value;
 console.log(data);
document. getElementById('service_input'). value = data;
}
</script>

Best tool for web developer (insert whole data in single click in database)

INSERTING DATA IN DATABASE TABLE BECOMES TOO DIFFICULT WHEN WE HAVE LARGE AMOUNT OF DATA . TO KEEP AWAY THIS PROBLEM THERE IS VERY GOOD SOLUTION

GO TO THIS LINKCLICK HERE TO VISIT

GO TO THIS WEBSITE SIMPLY IMPORT WHOLE EXCEL DATA SHEET AND COPY ALL THE QUERIES AND PASTE IT TO CMD MYSQL CONSOLE OR DIRECT PHP MYADMIN QUERY BOX YOU TABLE WILL BE CREATED SIMPLY RENAME IT ACCORDING TO YOUR NEED.

Ajax dropdown city from selected state from database in php free source code

Using ajax to make dropdown when state and city is selected

  •  First create page where you have embed or add state and city option(example: state_city.php)
  • Then create an differente page from where we will receive response when state option is selected

There is three stages create select options for state and city then take data from server(state data)  and display as select option as state, when state option is selected then the value inside state dropdown will go to ajax function to send request to other page, where city date is getting then display this page data as html in state page below;

see the source code you will understand completly. 

This is ajax block whice receive data from state option 

This page is included in main page where we have to display data

<script type="text/javascript">
$(document).ready(function() {        
    $('#state_dropdown').on('change', function() {
    var state_id = this.value;
    $.ajax({
      url: "state_city.php",
      type: "POST",
      data: {
        state_id: state_id
        },
      cache: false,
      success: function(result){
        $("#city_dropdown").html(result);
        }
    });
});
});
</script>    
 

This is select option where we have to display state and then from state to city dropdown

 <div class="row">
    <div class="col-md-4">
         <label for="label-floating"> Working Location</label>
          </div>  
           <div class="col-md-3">
            <div class="form-group">
          <select  class="custom-select" id="state_dropdown" >
<option>Select state</option>
<?php
      $sql='select * from `state_name`';
      $select=execute_query($sql);
      while($row=mysqli_fetch_array($select))
       {
          echo "<option value='".$row['sno']."'>".$row['state_list']."</option>";
         }
     ?>
    </select>
        </div>
    </div>
    <!-- <div class="col-md-1"></div> -->
    <div class="col-md-3">
     <div class="form-group">
       <select name="" class="custom-select" id="city_dropdown">                           
       </select>
      </div>
       </div>                    
      </div>


This is city_state.php from where we will get date when user select state in main page


<?php
include("scripts/settings_dbase.php");
?>
<?php
//require_once "db.php";
$state_id = $_POST["state_id"];

echo $state_id;
$sql="SELECT * FROM city_name where parent_state = '".$state_id."'";
echo $sql;
$result=execute_query($sql);

?>
<option value="">Select City</option>
<?php
while($row = mysqli_fetch_array($result)) {
?>
<option value="<?php echo $row["sno"];?>"><?php echo $row["city_name"];?></option>
<?php
}
?>




DISABLE WINDOWS 10 NEWS SECTION POP UP FROM TASKBAR

 HOW TO DISABLE NEWS POPUP WHEN CURSOR GOES THERE BY SOME MISTAKE

  • simply right click with mouse on news icon in taskbar
  • then there is a option news and interest  
  • simply go inside menu 
  • select turn off 
  • now you news and interest is disables

 

MAKE OPTIONS IN FORM WITH ALREADY SELECTED DATA

 CREAT SELECT OPTION, AND ALSO SHOWING PREVIOUSLY SELECTED OPTION BY USER FROM DATABASE.

<td>
 NEWSPAPER NAME
<select id="newspaper_name" name="newspaper_name" class="form-control" required>
    <?php
    $sql = 'select * from newspapers';
    $result = execute_query($sql);
    while ($row = mysqli_fetch_assoc($result)) {    echo '<option value="'.$row['sno'].'" ';
    if(isset($_GET['id'])){
        if($row1['newspaper_name']==$row['sno']){
            echo ' selected="selected" ';
        }
    }

    echo '>' . $row['newspaper_name'] . '</option>';
    }


    ?>
</select>

 </td>

SQL: A Realtional Database Language

 Sql is the query langugae used with relational databases.Sql is not a DBMS itselflkbut ut us a medum of communication with DBMS.SQL is muvh easiet to understand and lwatn as compared to other language.SQL was initially called SEQUEL was later names as SQL during 1970's. Sql is a set based , declarative set based declarative query language and not imperative language such as c or BASIC. Declarative means that user only need to state" what " needs to be done and not how to be done.DBMS determines tand performs internally the steps needed to accomplis the job. It is also known to be non-procedural language

Features of Sql

  sql statements are not case senstive(but data is case sensitive) 

⦁ sql can be written one or more lines

 ⦁ clauses are usually placed on separate lines

 ⦁ Keywords cannot be split across lines

 ⦁ Tabs and spaces are allowed to enhance readability

 ⦁ Each SQL statement (not line) wnds with a semicolon(;)

 ⦁ sql is declarative and non-procedural language.

 ⦁ Sql statement start with verbs(actions) .Example create command.

 ⦁ Identifier always start with alphabet ⦁ single line comment are prefixed by - symbol and multiline comments are enclosed between /* and */

MOST USED PHP FUNCTIONS FOR DEVELOPEMENT

USING STRTOTIME() AND DATE() FUNCTION IN PHP

FETCHING DATE YEAR AND TIME SEPARATELY FROM USER INPUT

if (isset$_POST'submit' ] ) ) {
    
    $date = $_POST['date_current'];
    $time = strtotime($date);
    $month = date("m",$time);
    $year = date("Y",$time);
    if($month>=1 && $month<=3){
        $year = $year-1;
    }
 
HERE FIRST WE HAVE TO UNDERSTAND THIS IS SIMPLE LOGIC TO RECEIVE SEPARATE DATE , MONTH , YEAR,  AND TIME ALSO.

SUPPOSE WE HAVE TO GET DATA AS MONTH YEAR AND TIME AS SEPARATELY FOR SOME CALCULATION OR TO STORE IN SOME VARIABLES .  IN SIMPLE YOU HAVE TO GET YEAR FROM USER ENTERED INPUT TAG BECAUSE IF YOU SELECT INPUT TYPE AS DATE THEN YOU WILL GET DATA MONTH AND DAY TOGETHER BUT FOR SOME REASON YOU NEED MONTH AND YEAR ONLY TO PERFORM CALCULATION 
 
IN THIS LOGIC WE ARE RECEIVING DATE FROM FORM WHERE WE HAVE CREATED A INPUT TAG OF DATE TYPE FOR USER TO ENTER THE DATE, WHEN THE SUBMIT BUTTON IS PRESSED THEN
  • WE HAVE STORED DATE IN A VARIABLE NAME $date FROM INPUT BY POST METHOD
  • IN SECOND LINE $time IS USED TO STORED CONVERTED DATA WHICH IS CONVERTED INTO STRING BY USING strtotime() FUNCTION THIS FUNCTION CONVERTS DAY, MONTH, YEAR IN TO STRING AND THEN FROM STRING WE CAN FETCH DAY MONTH AND YEAR SEPARATELY 
  • HERE AN ANOTHER FUNCTION IS USED WHICH IS DATE("SPECIFIER","VARIABLE") IT EXTRACT DATE MONTHS AND YEAR SEPARATELY
  • THEN WE STORE MONTH AND YEAR BY USING DATA FUNCTION , HERE 'M' 'Y' DENOTES SHORT FORM OF MONTHS AND YEAR
  • STORE THE DATA IN VARIABLE AND THEN PERFORM THE DESIRED OPERATIONS  
 

HOW GET 4000 WATCH TIME IN YOUTUBE FOR MONETIZATION

TRICK FOR 4000 WATCH TIME ON YOUTUBE

    • first make 20 or more videos and stream atleast 2 hours
    • then simply upload it,
    • get any other device like smartphone or laptop or pc which have good internet connection then simply start your stream on other device
    • decrese its speed from setting option
    • then left it for a time 
    • repeate this process for few days and hours you will get enough watch time by this trick
    • but dont apply this trick to complete the whole watch time
    • apply this trick only to complete 60% or some more
    • otherwise there is a risk that youtub will decrease your watch time