code-rag-bench/online-tutorials huggingface dataset:
Gerrit - Configure Git

Once you have installed Git, you need to customize the configuration variables to add your personal information. You can get and set the configuration variables by using Git tool called git config along with the -l option (this option provides the current configuration).
git config -l

When you run the above command, you will get the configuration variables as shown in the following image
You can change the customized information any time by using the commands again. In the next chapter, you will learn how to configure the user name and user Email by using git config command.
 Print
 Add Notes
 Bookmark this page
How to use IF in stored procedure and select in MySQL?

You can use IF in stored procedure and IF() in select statement as well.
IF() in select statement mysql> select if(0=0,'Hello MySQL','condition is wrong');
This will produce the following output −
+------------------------------------------------------+
| if('test'='test','Hello MySQL','condition is wrong') |
+------------------------------------------------------+
| Hello MySQL                                          |
+------------------------------------------------------+
1 row in set (0.00 sec)
The second case if your condition becomes wrong −
mysql> select if(1=0,'Hello MySQL','condition is wrong');
This will produce the following output −
+--------------------------------------------+
| if(1=0,'Hello MySQL','condition is wrong') |
+--------------------------------------------+
| condition is wrong                         |
+--------------------------------------------+
1 row in set (0.00 sec)
The query to create a stored procedure is as follows. Here, we have used IF to set conditions −
mysql> DELIMITER //
mysql> CREATE PROCEDURE if_demo(value int)
   BEGIN
      IF 1=value
         THEN SELECT "Hello MySQL";
      ELSE
         SELECT "Wrong Condition";
      END IF;
   END
   //
Query OK, 0 rows affected (0.20 sec)
mysql> DELIMITER ;
Now you can call the stored procedure using call command.
mysql> call if_demo(1);
This will produce the following output −
+-------------+
| Hello MySQL |
+-------------+
| Hello MySQL |
+-------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
If your condition becomes false −
mysql> call if_demo(0);
This will produce the following output −
+-----------------+
| Wrong Condition |
+-----------------+
| Wrong Condition |
+-----------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
Find smallest permutation of given number in C++

In this problem, we are given a large number N. Our task is to find the
smallest permutation of a given number.
Let’s take an example to understand the problem,
N = 4529016
1024569
A simple solution to the problem is by storing the long integer value to a
string. Then we will sort the string which is our result. But if there are any
leading zeros, we will shift them after the first non zero value.
Program to illustrate the working of our solution,
 Live Demo
#include <bits/stdc++.h>
using namespace std;
string smallestNumPer(string s) {
   int len = s.length();
   sort(s.begin(), s.end());
   int i = 0;
   while (s[i] == '0')
      i++;
   swap(s[0], s[i]);
   return s;
}
int main() {
   string s = "4529016";
   cout<<"The number is "<<s<<endl;
   cout<<"The smallest permutation of the number is "<<smallestNumPer(s);
   return 0;
}
The number is 4529016
The smallest permutation of the number is 1024569
Python program to swap case of English word

Suppose we have a string with English letters. We have to swap the case of the letters. So uppercase will be converted to lower and lowercase converted to upper.
So, if the input is like s = "PrograMMinG", then the output will be pROGRAmmINg
To solve this, we will follow these steps −
ret := blank string
for each letter in s, doif letter is in uppercase, thenret := ret concatenate lower case equivalent of letterotherwise,ret := ret concatenate upper case equivalent of letter
if letter is in uppercase, thenret := ret concatenate lower case equivalent of letter
ret := ret concatenate lower case equivalent of letter
otherwise,ret := ret concatenate upper case equivalent of letter
ret := ret concatenate upper case equivalent of letter
return ret
Let us see the following implementation to get better understanding
def solve(s):
   ret = ''

   for letter in s:
      if letter.isupper():
         ret += letter.lower()
      else:
         ret += letter.upper()
   return ret

s = "PrograMMinG"
print(solve(s))
"PrograMMinG"
pROGRAmmINg
Program to find longest prefix that is also a suffix in C++

Suppose we have a string s, we have to find the longest prefix of s, which is also a suffix (excluding itself). If there is no such prefix, then simply return blank string.
So, if the input is like "madam", then the output will be "m", it has 4 prefixes excluding itself. These are "m", "ma", "mad", "mada" and 4 suffixes like "m", "am", "dam", "adam". The largest prefix which is also suffix is given by "m".
To solve this, we will follow these steps −
Define a function lps(), this will take s,
Define a function lps(), this will take s,
n := size of s
n := size of s
Define an array ret of size n
Define an array ret of size n
j := 0, i := 1
j := 0, i := 1
while i < n, do −if s[i] is same as s[j], then −ret[i] := j + 1(increase i by 1)(increase j by 1)otherwise when s[i] is not equal to s[j], then −if j > 0, then −j := ret[j − 1]Otherwise(increase i by 1)
while i < n, do −
if s[i] is same as s[j], then −ret[i] := j + 1(increase i by 1)(increase j by 1)
if s[i] is same as s[j], then −
ret[i] := j + 1
ret[i] := j + 1
(increase i by 1)
(increase i by 1)
(increase j by 1)
(increase j by 1)
otherwise when s[i] is not equal to s[j], then −if j > 0, then −j := ret[j − 1]Otherwise(increase i by 1)
otherwise when s[i] is not equal to s[j], then −
if j > 0, then −j := ret[j − 1]
if j > 0, then −
j := ret[j − 1]
j := ret[j − 1]
Otherwise(increase i by 1)
Otherwise
(increase i by 1)
(increase i by 1)
return ret
return ret
From the main method do the following −
From the main method do the following −
n := size of s
n := size of s
if n is same as 1, then −return blank string
if n is same as 1, then −
return blank string
return blank string
Define an array v = lps(s)
Define an array v = lps(s)
x := v[n − 1]
x := v[n − 1]
ret := blank string
ret := blank string
for initialize i := 0, when i < x, update (increase i by 1), do −ret := ret + s[i]
for initialize i := 0, when i < x, update (increase i by 1), do −
ret := ret + s[i]
ret := ret + s[i]
return ret
return ret
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
   public:
   vector <int> lps(string s){
      int n = s.size();
      vector<int> ret(n);
      int j = 0;
      int i = 1;
      while (i < n) {
         if (s[i] == s[j]) {
            ret[i] = j + 1;
            i++;
            j++;
         }
         else if (s[i] != s[j]) {
            if (j > 0)
            j = ret[j - 1];
            else {
               i++;
            }
         }
      }
      return ret;
   }
   string longestPrefix(string s) {
      int n = s.size();
      if (n == 1)
      return "";
      vector<int> v = lps(s);
      int x = v[n - 1];
      string ret = "";
      for (int i = 0; i < x; i++) {
         ret += s[i];
      }
      return ret;
   }
};
main(){
   Solution ob;
   cout << (ob.longestPrefix("helloworldhello"));
}
"helloworldhello"
hello
How to Get the current language in Android device?

While doing internalization in android application, we should know what is the current language in android device. This example demonstrate
about how to Get the current language in Android device.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context=".MainActivity"
   android:background="#dde4dd"
   android:gravity="center"
   android:orientation="vertical">
   <TextView
      android:id="@+id/language"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
   <Button
      android:id="@+id/click"
      android:layout_marginTop="10dp"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="click"/>
</LinearLayout>
In the above code we have taken Button. When user click on button, it will take device country name and language and append to text view.
Step 3 − Add the following code to src/MainActivity.java
package com.example.andy.myapplication;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.Locale;

public class MainActivity extends AppCompatActivity {
   TextView language;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      language = findViewById(R.id.language);
      Button button = findViewById(R.id.click);
      button.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            String languagename = Locale.getDefault().getDisplayLanguage();
            String country = Locale.getDefault().getCountry();
            language.setText("Language " + languagename + " Country name " + country);
         }
      });
   }
}
In the above code, we have used Locale class to get Display language and country as shown below -
String languagename = Locale.getDefault().getDisplayLanguage();
String country = Locale.getDefault().getCountry();
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Runicon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
In the above result it shows initial screen when user click on button it will show country name and language as shown below -
Click here to download the project code
C/C++ program to make a simple calculator - GeeksforGeeks

22 Nov, 2018
Calculators are widely used device nowadays. It makes calculations easier and faster. Calculators are used to everyone in daily life. A simple calculator can be made using a C++ program which is able to add, subtract, multiply and divide, two operands entered by the user. The switch and break statement is used to create a calculator.
Program:
// C++ program to create calculator using// switch statement#include <iostream>using namespace std;  // Main programmain(){    char op;    float num1, num2;      // It allows user to enter operator i.e. +, -, *, /    cin >> op;      // It allow user to enter the operands    cin >> num1 >> num2;      // Switch statement begins    switch (op) {                  // If user enter +         case '+':            cout << num1 + num2;            break;                  // If user enter -         case '-':            cout << num1 - num2;            break;                  // If user enter *        case '*':            cout << num1 * num2;            break;                  // If user enter /        case '/':            cout << num1 / num2;            break;                  // If the operator is other than +, -, * or /,         // error message will display        default:            cout << "Error! operator is not correct";            break;    } // switch statement ends      return 0; }
Output:
Click on the run ide button, another tab will be open with web address“https://ide.geeksforgeeks.org/index.php”
Put the input in the input box
Enter the arithmetic operator (i.e.: either +, -, * or /) then, enter two operands on which need to perform the calculation
Click on the run button
Then output box will appear with output
Technical Scripter 2018
C++
C++ Programs
School Programming
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Operator Overloading in C++
Iterators in C++ STL
Friend class and function in C++
Polymorphism in C++
Sorting a vector in C++
Header files in C/C++ and its uses
C++ Program for QuickSort
How to return multiple values from a function in C or C++?
CSV file management using C++
Program to print ASCII Value of a character
How do I get the current time zone of MySQL?

The following is the syntax to get the current time zone of MySQL.
mysql> SELECT @@global.time_zone, @@session.time_zone;
The following is the output.
+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| SYSTEM             | SYSTEM              |
+--------------------+---------------------+
1 row in set (0.00 sec)

The above just returns “SYSTEM” because MySQL is set for system time zones.
Alternately, we can get the current time zone with the help of now() function. Let us first create a new table for our example.
mysql> create table CurrentTimeZone
   -> (
   -> currenttimeZone datetime
   -> )ENGINE=MYISAM;
Query OK, 0 rows affected (0.19 sec)
Inserting records into table.
mysql> INSERT INTO CurrentTimeZone values(now());
Query OK, 1 row affected (0.10 sec)
Displaying current time zone.
mysql> select *from CurrentTimeZone;
The following is the output.
+---------------------+
| currenttimeZone     |
+---------------------+
| 2018-10-29 17:20:12 |
+---------------------+
1 row in set (0.00 sec)
Create a padded grey box with rounded corners in Bootstrap

Use the .jumbotron class to create a padded grey box with rounded corners.
You can try to run the following code to implement .jumbotron class in Bootstrap.
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container">
         <div class = "jumbotron">
            <h1>Welcome to my website.</h1>
            <p>This is demo text.</p>
            <p>
               <a class = "btn btn-default btn-sm" role = "button">More</a>
            </p>
         </div>
      </div>
   </body>
</html>
How to remove the boxes around legend of a plot created by ggplot2 in R?

When we create a plot with legend using ggplot2, the legend values are covered with a box and that makes an impact on the smoothness of the plot. These boxes around the legend values can be removed so that complete the chart becomes more appealing to the viewer and it can be done with the help of theme function by setting the legend.key element to blank.
Consider the below data frame −
set.seed(1)
x<-rnorm(20)
y<-rpois(20,2)
Group<-rep(c("A","B","C","D"),times=5)
df<-data.frame(x,y,Group)
df
  x    y    Group
1   -0.62645381 3 A
2   0.18364332 2 B
3  -0.83562861 3 C
4   1.59528080 2 D
5   0.32950777 2 A
6  -0.82046838 3 B
7   0.48742905 0 C
8   0.73832471 2 D
9   0.57578135 3 A
10 -0.30538839 3 B
11  1.51178117 2 C
12  0.38984324 4 D
13 -0.62124058 2 A
14 -2.21469989 1 B
15  1.12493092 0 C
16 -0.04493361 0 D
17 -0.01619026 1 A
18  0.94383621 2 B
19  0.82122120 2 C
20  0.59390132 2 D
> library(ggplot2)
Creating the scatter plot with different colors of groups −
ggplot(df,aes(x,y,color=Group))+geom_point()
Here, we are getting legend colors in boxes. If we want to get rid of these boxes then we can use theme function as shown below −
ggplot(df,aes(x,y,color=Group))+geom_point()+theme(legend.key=element_blank())
Java Collections emptyMap() Method with Examples - GeeksforGeeks

03 Jan, 2022
The emptyMap() method of Java Collections is a method that is used to return an empty map such that we can not change the data in map IE it is immutable.
Syntax:
public static final <Key,Value> Map<Key,Value> emptyMap()   
where, 
key is the key element
value is the value element
Parameters: This will not accept any parameters,
Return Type: This will return an empty map that is immutable.
Exceptions: It will not arise any exception.
Example 1:
Java
// Java program to create an empty mapimport java.util.*;  public class GFG {    // main method      public static void main(String[] args)    {              // create an empty map        Map<String, String> data = Collections.emptyMap();                     System.out.println(data);    }}
{}
Example 2: 
Java
// Java program to create an// empty map and add elements// We will get an error because // the method will work on only // an empty mapimport java.util.*;  public class GFG {     // main method    public static void main(String[] args)    {              // create an empty map        Map<String, String> data = Collections.emptyMap();                      // add element        data.put("1", "python/R");                    System.out.println(data);    }}
Output:
Exception in thread "main" java.lang.UnsupportedOperationException
    at java.util.AbstractMap.put(AbstractMap.java:209)
    at GFG.main(GFG.java:8)
Java-Collections-Class
Java-Functions
Picked
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Different ways of Reading a text file in Java
Exceptions in Java
Functional Interfaces in Java
Generics in Java
Comparator Interface in Java with Examples
Introduction to Java
HashMap get() Method in Java
Strings in Java
Google Charts - Stacked bar chart

Following is an example of a stacked bar chart. We've already seen the configuration used to draw this chart in Google Charts Configuration Syntax chapter. So, let's see the complete example.
We've used isStacked configuration to show stacked chart.
// Set chart options
var options = {
   isStacked: true
};
googlecharts_bar_stacked.htm
<html>
   <head>
      <title>Google Charts Tutorial</title>
      <script type = "text/javascript" src = "https://www.gstatic.com/charts/loader.js">
      </script>
      <script type = "text/javascript">
         google.charts.load('current', {packages: ['corechart']});     
      </script>
   </head>
   
   <body>
      <div id = "container" style = "width: 550px; height: 400px; margin: 0 auto">
      </div>
      <script language = "JavaScript">
         function drawChart() {
            // Define the chart to be drawn.
            var data = google.visualization.arrayToDataTable([
               ['Year', 'Asia', 'Europe'],
               ['2012',  900,      390],
               ['2013',  1000,      400],
               ['2014',  1170,      440],
               ['2015',  1250,       480],
               ['2016',  1530,      540]
            ]);

            var options = {title: 'Population (in millions)', isStacked:true};  

            // Instantiate and draw the chart.
            var chart = new google.visualization.BarChart(document.getElementById('container'));
            chart.draw(data, options);
         }
         google.charts.setOnLoadCallback(drawChart);
      </script>
   </body>
</html>
Verify the result.
 Print
 Add Notes
 Bookmark this page
C++ Arrays (Sum of array) | Set 1 | Practice | GeeksforGeeks

Given an array of N integers. Your task is to print the sum of all of the integers.
 
Example 1:
Input:
4
1 2 3 4
Output:
10
 
Example 2:
Input:
6
5 8 3 10 22 45
Output:
93
 
Your Task:  
You don't need to read input or print anything. Your task is to complete the function getSum() which takes the array A[] and its size N as inputs and returns the sum of array in a new line.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
 
Constraints:
1 ≤ N ≤ 106
0 ≤ Arr[i] ≤ 200
0
laveshgoyal63in 20 minutes
class Solution{   public:   int getSum(int a[], int n) {       // Your code goes here       int sum=0;       for(int i=0;i<n;i++)       {           sum=sum+a[i];       }       return sum;   }   }; 
0
visionsameer392 days ago
1) using for loopsclass Solution:   def getSum(self, arr, n):       s=0       for i in range(n):           s+=arr[i]       return s
 
2) using inbuilt function of sum.      return sum(arr)           
0
tanmeetsinghreel1 week ago
//Python3
def getSum(self, arr, n):       count=0       for i in range(n):           count+=arr[i]       return(count)
0
rsbly7300952 weeks ago
class Solution {      public long getSum(long a[], long n)   {       long sum = 0;       for(int i = 0 ;i<n;i++){           sum = a[i] + sum;       }       return sum;   }}
0
sauarbh1472
This comment was deleted.
0
vinuthah1270
This comment was deleted.
-2
vikasarya18893 weeks ago
class Solution{   public:   int getSum(int a[], int n) {       // Your code goes here       int sum =0;       for(int i =0;i<n;i++){           sum =sum +a[i];       }       return sum;   }   };
0
kmg9tpqt8rvlpr74o0f2r8la5fgj004mmp0hsy7a1 month ago
class solution{   public:   int getSum(int a[], int n) {       int sum =0;       for(int i = 0; i<n; i++)       {           sum = sum +a[i];       }       return sum ;
}       // Your code goes 
0
shashwatchaurasia831 month ago
class Solution{   public:   int getSum(int a[], int n) {       int sum=0;       for(int i=0;i<n;i++)       {           sum=sum+a[i];       }       return sum;   }   }; 
0
rishiyvofficial1 month ago
int getSum(int a[], int n) {       // Your code goes here       int sum=0;       for(int i=0; i<n; i++) sum+=a[i];       return sum;   } 
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.
Create database view in SAP ABAP

In ABAP, you can make use of Function modules - DDIF_VIEW_PUT and DDIF_VIEW_ACTIVATE for view activation. All table parameters should be defined correctly otherwise it can result in an error in the creation process.
DDIF_VIEW_PUT − Interface for writing a view in the ABAP Dictionary.
You can refer to below link for more details −
http://www.se80.co.uk/sapfms/d/ddif/ddif_view_put.htmCALL FUNCTION 'DDIF_VIEW_PUT' "DD: Interface for writing a view in the ABAP DictionaryEXPORTING
name = " ddname Name of the view to be written
* dd25v_wa = ' ' " dd25v View header
* dd09l_wa = ' ' " dd09v Technical settings of the view
* TABLES
* dd26v_tab = " dd26v Basis tables of the view
* dd27p_tab = " dd27p View fields
* dd28j_tab = " dd28j Join conditions of the view
* dd28v_tab = " dd28v Selection conditions of the view

EXCEPTIONS
VIEW_NOT_FOUND = 1 " Header of the view could not be found
NAME_INCONSISTENT = 2 " Name in Sources Inconsistent with NAME
VIEW_INCONSISTENT = 3 " Inconsistent Sources
PUT_FAILURE = 4 " Write Error (ROLLBACK Recommended)
PUT_REFUSED = 5 " Write not Allowed

. " DDIF_VIEW_PUT
DDIF_VIEW_ACTIVATE: Interface for activating a view
EXPORTING

name = " ddname Name of view to be activated
* auth_chk = 'X' " ddbool_d 'X': Perform authorization check for DB operations
* prid = -1 " sy-tabix ID for Log Writer
IMPORTING
rc = " sy-subrc Result of Activation
EXCEPTIONS

NOT_FOUND = 1 "View not found
PUT_FAILURE = 2 "View could not be written
. " DDIF_VIEW_ACTIVATE
Both of these views can be used in T-code: SE80 or SE37. You can use both the transactions to display SAP function module documentation available within your SAP system.
You can also create a view of Transaction code SE11 in SAP ABAP as below:
You have to maintain and activate the view. Once activated, you can view the contents of standard transactions code SE16 as shown below −
Rexx - DataType

This method returns the value of ‘NUM’ if the input is a valid number else it will return the value of ‘CHAR’. You can also specify if you want to compare the input value to a NUM or CHAR value. In each case, the value returned will be either 1 or 0 depending on the result.
DATATYPE(String,type) 

String − The string value for which the datatype needs to be determined.
String − The string value for which the datatype needs to be determined.
Type − Optional type against which the datatype need to be compared to.
Type − Optional type against which the datatype need to be compared to.
This method returns the value of ‘NUM’ if the input is a valid number else it will return the value of ‘CHAR’. You can also specify if you want to compare the input value to a NUM or CHAR value. In each case, the value returned will be either 1 or 0 depending on the result.
/* Main program */ 
say DATATYPE(" 12345 ") 
say DATATYPE("") 
say DATATYPE("12345*") 
say DATATYPE("123.4","N") 
say DATATYPE("123.4","W")
When we run the above program we will get the following result.
NUM 
CHAR 
CHAR 
1 
0

 Print
 Add Notes
 Bookmark this page
Java - String startsWith() Method

This method has two variants and tests if a string starts with the specified prefix beginning a specified index or by default at the beginning.
Here is the syntax of this method −
public boolean startsWith(String prefix)

Here is the detail of parameters −
prefix − the prefix to be matched.
prefix − the prefix to be matched.
It returns true if the character sequence represented by the argument is a prefix of the character sequence represented by this string; false otherwise.
It returns true if the character sequence represented by the argument is a prefix of the character sequence represented by this string; false otherwise.
import java.io.*;
public class Test {

   public static void main(String args[]) {
      String Str = new String("Welcome to Tutorialspoint.com");

      System.out.print("Return Value :" );
      System.out.println(Str.startsWith("Welcome") );

      System.out.print("Return Value :" );
      System.out.println(Str.startsWith("Tutorials") );
   }
}
This will produce the following result −
Return Value :true
Return Value :false


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
HEX() function in MySQL - GeeksforGeeks

04 Dec, 2020
HEX() :
This function in MySQL is used to return an equivalent hexadecimal string value of a string or numeric Input. If the input is a string then each byte of each character in the string is converted to two hexadecimal digits. This function also returns a hexadecimal string representation of the numeric argument N treated as a longlong (BIGINT) number.  
Syntax :
HEX(string)
OR
HEX(N)
Parameter : 
This method accepts only one parameter.
string – Input string who’s each character is to be converted to two hexadecimal digits.
N – Input number which is to be converted to hexadecimal.
Returns : 
It returns an equivalent hexadecimal string representation of a string or numeric Input.
Example-1 :
Hexadecimal representation of the decimal number 0 using HEX Function as follows.
SELECT HEX(0) AS Hex_number ;
Output :
Example-2 :
Hexadecimal representation of the decimal number 2020 using HEX Function as follows.
SELECT HEX( 2020 ) AS Hex_number ;
Output :
Example -3 :
Hexadecimal representation of the string ‘geeksforgeeks’ using HEX Function as follows.
SELECT HEX( 'geeksforgeeks') AS Hex_string ;
Output :
Example-4 :
Using HEX Function to find a hexadecimal representation of all decimal numbers present in a column as follows. 
Creating a Player table :
CREATE TABLE Player(

Player_id INT AUTO_INCREMENT,  
Player_name VARCHAR(100) NOT NULL,
Playing_team VARCHAR(20) NOT NULL,
Highest_Run_Scored INT NOT NULL,
PRIMARY KEY(Player_id )

);
Inserting data into the Table :
INSERT INTO  
Player(Player_name, Playing_team, Highest_Run_Scored)
VALUES
('Virat Kohli', 'RCB', 60 ),
('Rohit Sharma', 'MI', 45),
('Dinesh Karthik', 'KKR', 26 ),
('Shreyash Iyer', 'DC', 40 ),
('David Warner', 'SRH', 65),
('Steve Smith', 'RR', 52 ),
('Andre Russell', 'KKR', 70),
('Jasprit Bumrah', 'MI', 10),
('Risabh Panth', 'DC', 34 ) ;
To verify use the following command as follows.
SELECT * FROM Player;
Output :
Now, we will find the highest run scored by each player in hexadecimal using the HEX Function.
SELECT  
Player_id, Player_name,
Playing_team, HEX(HIGHEST_RUN_SCORED) AS HighestRunInHexaDecimal
FROM Player ;
Output :
DBMS-SQL
mysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Subquery
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL using Python
How to Write a SQL Query For a Specific Date Range and Date Time?
How to Select Data Between Two Dates and Times in SQL Server?
SQL Query to Compare Two Dates
Difference between Procedural and Declarative Knowledge - GeeksforGeeks

28 Jun, 2020
Procedural Knowledge:Procedural Knowledge also known as Interpretive knowledge, is the type of knowledge in which it clarifies how a particular thing can be accomplished. It is not so popular because it is generally not used.It emphasize how to do something to solve a given problem.Let’s see it with an example:
var a=[1, 2, 3, 4, 5];
var b=[];
for(var i=0;i<a.length;i++)
{
  b.push(a[i]);
}
console.log(b); 
Output is:
[1, 2, 3, 4, 5]
Declarative Knowledge:Declarative Knowledge also known as Descriptive knowledge, is the type of knowledge which tells the basic knowledge about something and it is more popular than Procedural Knowledge.It emphasize what to do something to solve a given problem.Let’s see it with an example:
var a=[1, 2, 3, 4, 5];
var b=a.map(function(number)
{
 return number*1});
console.log(b);
Output is:
[1, 2, 3, 4, 5]
In both example we can see that the output of a given problem is same because the only difference in that two methods to achieve the output or solution of problem.
Difference the Procedural and Declarative Knowledge:
pp_pankaj
Difference Between
Misc
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between IPv4 and IPv6
Difference Between Method Overloading and Method Overriding in Java
Stack vs Heap Memory Allocation
Differences between JDK, JRE and JVM
vector::push_back() and vector::pop_back() in C++ STL
Top 10 algorithms in Interview Questions
Overview of Data Structures | Set 1 (Linear Data Structures)
How to write Regular Expressions?
Minimax Algorithm in Game Theory | Set 3 (Tic-Tac-Toe AI - Finding optimal move)
Multiply matrices of complex numbers using NumPy in Python - GeeksforGeeks

05 Sep, 2020
In this article, we will discuss how to multiply two matrices containing complex numbers using NumPy but first, let’s know what is a complex number. A Complex Number is any number that can be represented in the form of x+yj where x is the real part and y is the imaginary part. Multiplication of two complex numbers can be done using the below formula – 
NumPy provides the vdot() method that returns the dot product of vectors a and b. This function handles complex numbers differently than dot(a, b).
Syntax:
numpy.vdot(vector_a, vector_b)
Example 1:
Python3
# importing numpy as libraryimport numpy as np    # creating matrix of complex numberx = np.array([2+3j, 4+5j])print("Printing First matrix:")print(x)  y = np.array([8+7j, 5+6j])print("Printing Second matrix:")print(y)  # vector dot product of two matricesz = np.vdot(x, y)print("Product of first and second matrices are:")print(z)
Output:
Printing First matrix:
[2.+3.j 4.+5.j]
Printing Second matrix:
[8.+7.j 5.+6.j]
Product of first and second matrices are:
(87-11j)

Example 2: Now suppose we have 2D matrix: 
Python3
# importing numpy as libraryimport numpy as np    # creating matrix of complex numberx = np.array([[2+3j, 4+5j], [4+5j, 6+7j]])print("Printing First matrix:")print(x)  y = np.array([[8+7j, 5+6j], [9+10j, 1+2j]])print("Printing Second matrix:")print(y)  # vector dot product of two matricesz = np.vdot(x, y)print("Product of first and second matrices are:")print(z)
Output:
Printing First matrix:
[[2.+3.j 4.+5.j]
 [4.+5.j 6.+7.j]]
Printing Second matrix:
[[8. +7.j 5. +6.j]
 [9.+10.j 1. +2.j]]
Product of first and second matrices are:
(193-11j)

Python numpy-Matrix Function
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Python | Miscellaneous | Question 1 - GeeksforGeeks

28 Jun, 2021
What is the output of the following program :
print "Hello World"[::-1]
(A) dlroW olleH(B) Hello Worl(C) d(D) ErrorAnswer: (A)Explanation: [::] depicts extended slicing in Python and [::-1] returns the reverse of the string.Quiz of this Question
amartyaghoshgfg
Miscellaneous
Python-Quizzes
Python-Quizzes-Miscellaneous
Python-Quizzes
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python-Quizzes | Python List Quiz | Question 4
Python-Quizzes | Python Dictionary Quiz | Question 25
Python-Quizzes | Python List Quiz | Question 5
Python-Quizzes | Python Dictionary Quiz | Question 23
Python | Animated Banner showing 'GeeksForGeeks'
Why do people prefer Selenium with Python?
Output of Python Program - Dictionary (set 25)
Python-Quizzes | Miscellaneous | Question 10
Python-Quizzes | Output Type | Question 10
Python-Quizzes | Data Type | Question 3
Java | Class and Object | Question 7 - GeeksforGeeks

28 Jun, 2021
Predict the output of the following program.
class Test{    int a = 1;    int b = 2;      Test func(Test obj)    {        Test obj3 = new Test();        obj3 = obj;        obj3.a = obj.a++ + ++obj.b;        obj.b = obj.b;        return obj3;    }      public static void main(String[] args)    {        Test obj1 = new Test();        Test obj2 = obj1.func(obj1);          System.out.println("obj1.a = " + obj1.a + "  obj1.b = " + obj1.b);        System.out.println("obj2.a = " + obj2.a + "  obj1.b = " + obj2.b);      }}
(A)
obj1.a = 1  obj1.b = 2
obj2.a = 4  obj2.b = 3
(B)
obj1.a = 4  obj1.b = 3
obj2.a = 4  obj2.b = 3
(C) Compilation errorAnswer: (B)Explanation:obj1 and obj2 refer to same memory address.Quiz of this QuestionPlease comment below if you find anything wrong in the above post
Class and Object
Java-Class and Object
Java Quiz
Java-Class and Object
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java | Constructors | Question 5
Java | Functions | Question 1
Java | final keyword | Question 1
Java | Abstract Class and Interface | Question 2
Java | Exception Handling | Question 4
Java | Exception Handling | Question 3
Java | Exception Handling | Question 8
Java | Exception Handling | Question 7
Java | Inheritance | Question 8
Java | Exception Handling | Question 6
Python IMDbPY - Getting list of movies performed by the actor - GeeksforGeeks

08 May, 2020
In this article we will see how we can get the list of movies in which actor has performed i.e an actor performs in various movies. IMDb has a database of almst every movie performed by verified actors.
In order to get the list of all the movies performed by the actor we have to get the details of filmography of the actor
Syntax : results = ia.get_person_filmography(ID)Here ia is the IMDb object
Argument : It takes Id as argument
Return : It returns dictionary
This method returns the complicated dictionary which is hard to read in order to get the titles of the movie we use results['data']['filmography'][0]['actor'][index]
Below is the implementation
# importing the moduleimport imdb  # creating instance of IMDbia = imdb.IMDb()  # person idcode = "1372788"  # printing person nameprint(ia.get_person(code))  # getting informationactor_results = ia.get_person_filmography(code)  # printing movie namefor index in range(5):    movie_name = actor_results['data']['filmography'][0]['actor'][index]    print(movie_name)
Output :
Shahid Kapoor
Jersey Hindi Remake
Sachet Tandon: Bekhayali
Kabir Singh
The Insider's Watchlist
Akhil Sachdeva & Tulsi Kumar: Tera Ban Jaunga
Another example
# importing the moduleimport imdb  # creating instance of IMDbia = imdb.IMDb()  # person idcode = "0001098"  # printing person nameprint(ia.get_person(code))  # getting informationactor_results = ia.get_person_filmography(code)  # printing movie namefor index in range(5):    movie_name = actor_results['data']['filmography'][0]['actor'][index]    print(movie_name)
Output :
Rodney Dangerfield
Angels with Angles
Still Standing
Back by Midnight
Phil of the Future
The Electric Piper
Python IMDbPY-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Aptitude | Algebra | Question 1 - GeeksforGeeks

28 Jun, 2021
If x3 + y3 = 9 and x + y = 3, then the value of x4+y4 is,(A) 21(B) 0(C) 17(D) 25Answer: (C)Explanation:
x3+y3 = (x + y) × (x2 − xy + y2)

Putting given values of x3+y3 and (x + y)
9 = 3 × ((x+y)2 − 3xy)
  = 3 × (9 − 3xy) 
  = 27 − 9xy

9xy = 18
xy = 2

x4 + y4 = (x2 + y2)2 - 2x2y2
   = (x2 + y2)2 - 2*4 
                                  [Putting value of xy]
   = ((x + y)2 - 2xy)2 - 2*4 
                            [Putting values of (x+y) and xy]
   = (9 - 4)2 - 2*4 
   = 17
Quiz of this Question
Algebra
QA - Placement Quizzes
QA - Placement Quizzes-Algebra
QA - Placement Quizzes
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
QA - Placement Quizzes | Work and Wages | Question 8
QA - Placement Quizzes | Permutation and Combination | Question 5
Count Distinct Rectangles in N*N Chessboard
QA - Placement Quizzes | Permutation and Combination | Question 2
QA - Placement Quizzes | Permutation and Combination | Question 4
QA - Placement Quizzes | Work and Wages | Question 5
QA - Placement Quizzes | SP Contest 2 | Question 1
QA - Placement Quizzes | Numbers, LCM and HCF | Question 11
QA - Placement Quizzes | Profit and Loss | Question 14
QA - Placement Quizzes | Permutation and Combination | Question 10
How to sort a Vector in descending order using STL in C++? - GeeksforGeeks

18 Apr, 2022
Given a vector, sort this vector in descending order using STL in C++.
Example: 
Input: vec = {1, 45, 54, 71, 76, 12}
Output: {76, 71, 54, 45, 12, 1}

Input: vec = {1, 7, 5, 4, 6, 12}
Output: {12, 7, 6, 5, 4, 1}
Approach: Sorting can be done with the help of sort() function provided in STL.
Syntax:  
sort(arr, arr + n, greater<T>()); 
C++
// C++ program to sort Vector// in descending order// using sort() in STL #include <bits/stdc++.h>using namespace std; int main(){    // Get the vector    vector<int> a = { 1, 45, 54, 71, 76, 12 };     // Print the vector    cout << "Vector: ";    for (int i = 0; i < a.size(); i++)        cout << a[i] << " ";    cout << endl;     // Sort the vector in descending order    sort(a.begin(), a.end(), greater<int>());     // Print the reversed vector    cout << "Sorted Vector in descending order:\n";    for (int i = 0; i < a.size(); i++)        cout << a[i] << " ";    cout << endl;     return 0;}
Output:
Vector: 1 45 54 71 76 12 
Sorted Vector in descending order:
76 71 54 45 12 1 
surindertarika1234
43e81c364f
cpp-vector
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in C++
C++ Classes and Objects
Bitwise Operators in C/C++
Virtual Function in C++
Constructors in C++
Templates in C++ with Examples
Operator Overloading in C++
Socket Programming in C/C++
vector erase() and clear() in C++
Object Oriented Programming in C++
jQuery :first-child Selector

The :first-child selector in jQuery is used to select all elements, which are the first child of their parent.
The syntax is as follows −
$(":first-child")
Let us now see an example to implement the :first-child() selector −
<!DOCTYPE html>
<html>
<head>
<style>
   .demo {
      background-color: red;
      color: white;
      font-size: 16px;
      border: 2px blue dashed;
   }
</style>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script>
   $(document).ready(function(){
      $("p:first-child").addClass("demo");
   });
</script>
</head>
<body>
<p>This is the first line!</p>
<p>This is the second line!</p>
<p>This is the third line!</p>
<hr>
<div>
<p>One</p>
<p>Two</p>
<p>Three</p>
<p>Four</p>
</div>
<hr>
<p>This is the last line.</p>
</body>
</html>
This will produce the following output −
alignof operator in C++ - GeeksforGeeks

08 Jun, 2018
In C++11 the alignof operator used to returns the alignment, in bytes of the specified type.Syntax:
alignof(type)
Syntax Explanation:
alignof: operator returns the alignment in byte, required for instances of type, which type is either complete type, array type or a reference type.
array type: alignment requirement of the element type is returned.
reference type: the operator returns the alignment of referenced type.
Return Value: The alignof operator typically used to returns a value of type std::size_t.
Program:
// C++ program to demonstrate alignof operator#include <iostream>using namespace std;  struct Geeks {    int i;    float f;    char s;};  struct Empty {};  // driver codeint main(){    cout << "Alignment of char: " << alignof(char) << endl;    cout << "Alignment of pointer: " << alignof(int*) << endl;    cout << "Alignment of float: " << alignof(float) << endl;    cout << "Alignment of class Geeks: " << alignof(Geeks) << endl;    cout << "Alignment of Empty class: " << alignof(Empty) << endl;      return 0;}
Alignment of char: 1
Alignment of pointer: 8
Alignment of float: 4
Alignment of class Geeks: 4
Alignment of Empty class: 1

alignof vs sizeof:The alignof value is the same as the value for sizeof for basic types. Consider, this example:
typedef struct { int a; double b; } S;  
// alignof(S) == 8  

Above case, the alignof value is the alignment requirement of the largest element in the structure.Example program to demonstrate the difference between alignof and sizeof:
// C++ program to demonstrate// alignof vs sizeof operator#include <iostream>using namespace std;  struct Geeks {    int i;    float f;    char s;};  int main(){      cout << "alignment of Geeks : " << alignof(Geeks) << '\n';    cout << "sizeof of Geeks : " << sizeof(Geeks) << '\n';    cout << "alignment of int : " << alignof(int) << '\n';    cout << "sizeof of int     : " << sizeof(int) << '\n';}
alignment of Geeks : 4
sizeof of Geeks : 12
alignment of int : 4
sizeof of int     : 4

cpp-structure
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Sorting a vector in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
Convert string to char array in C++
Iterators in C++ STL
Inline Functions in C++
List in C++ Standard Template Library (STL)
Multithreading in C++
Compute the value of F Cumulative Distribution Function in R Programming - pf() Function - GeeksforGeeks

25 Jun, 2020
pf() function in R Language is used to compute the density of F Cumulative Distribution Function over a sequence of numeric values. It also plots a density graph for F Cumulative Distribution.
Syntax: pf(x, df1, df2)
Parameters:x: Numeric Vectordf: Degree of Freedom
Example 1:
# R Program to compute # Cumulative F Density  # Creating a sequence of x-valuesx <- seq(1, 30, by = 2)  # Calling pf() Functiony <- pf(x, df1 = 2, df2 = 3)y
Output:
 [1] 0.5352420 0.8075499 0.8891420 0.9258675 0.9460051 0.9584308 0.9667275
 [8] 0.9725899 0.9769124 0.9802073 0.9827867 0.9848509 0.9865331 0.9879255
[15] 0.9890935

Example 2:
# R Program to compute # Cumulative F Density  # Creating a sequence of x-valuesx <- seq(1, 30, by = 0.2)  # Calling pf() Functiony <- pf(x, df1 = 3, df2 = 7)  # Plot a graphplot(y)
Output:
R Statistics-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Replace specific values in column in R DataFrame ?
Filter data by multiple conditions in R using Dplyr
Loops in R (for, while, repeat)
Change Color of Bars in Barchart using ggplot2 in R
How to change Row Names of DataFrame in R ?
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
Remove rows with NA in one column of R DataFrame
K-Means Clustering in R Programming
How to Split Column Into Multiple Columns in R DataFrame?
C++ Stack Library - stack() Function

The C++ constructor std::stack::stack() creates stack container and assigns copy of the ctnr argument to stack elements. If ctnr argument is not provided it constructs empty stack with zero element.
Following is the declaration for std::stack::stack() constructor form std::stack header.
explicit stack (const container_type& ctnr = container_type());

explicit stack (const container_type& ctnr);

ctnr − Container type which is second parameter of class template.
Constructor never returns value.
This member function never throws exception.
Linear i.e. O(n)
The following example shows the usage of std::stack::stack() constructor.
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

int main(void) {   
   stack<int> s1;
   vector<int> v = {1, 2, 3, 4, 5};
   stack<int, vector<int>> s2(v);

   cout << "Size of stack s1 = " << s1.size() << endl;

   cout << "Contents of stack s2" << endl;
   while (!s2.empty()) {
      cout << s2.top() << endl;
      s2.pop();
   }

   return 0;
}
Let us compile and run the above program, this will produce the following result −
Size of stack s1 = 0
Contents of stack s2
5
4
3
2
1

 Print
 Add Notes
 Bookmark this page
return command in Linux with examples

24 May, 2019
return command is used to exit from a shell function. It takes a parameter [N], if N is mentioned then it returns [N] and if N is not mentioned then it returns the status of the last command executed within the function or script. N can only be a numeric value.
Syntax:
return [N]
Example:
Note: echo $? is used to display the last return status.
Option:
return –help : It displays help information.
linux-command
Linux-Shell-Commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.