code-rag-bench/online-tutorials huggingface dataset:
Legal and illegal declaration and initializations in C

Mention some of the legal and illegal declarations and initializations while doing C programming?
Before discussing the legal and illegal statements let’s see how to declare and initialize the variables in C.
Following is the syntax of variable declaration −
Datatype v1,v2,... vn;
Where v1, v2,...vn are names of the variables.
For example, int sum;
float a,b;
Variable can be declared in two ways −
local declaration
local declaration
global declaration
global declaration
The ‘local declaration’ is declaring a variable inside the main block and its value is available within that block.
The ‘global declaration’ is declaring a variable outside the main block and its value is available throughout the program.
For example,
int a, b; /* global declaration*/
main ( ){
   int c; /* local declaration*/
   - - -
}
Following is the syntax of variable initialization −
Datatype v1=number;
For example,
int sum=0;
float a=1,b=4.5;
Declare the variables by using data types, we can initialize the value at the time of declaration. So, while initializing and declaring the values we need to follow the rules
Let’s see some of the examples of legal and illegal declarations and initializations in C.
Char a=65;It is a legal statement because we can initialize a variable with a constant.
Char a=65;
It is a legal statement because we can initialize a variable with a constant.
Static int p=20, q=p*pIt is an illegal statement because static variable has to be initialized by a constant but here q is not initialized with a constant.
Static int p=20, q=p*p
It is an illegal statement because static variable has to be initialized by a constant but here q is not initialized with a constant.
Double x=30 *PIIt is a legal statement because here we initialized a variable with a constant expression.
Double x=30 *PI
It is a legal statement because here we initialized a variable with a constant expression.
Double diameter []={1,PI/2, PI, 2*PI/2}It is a legal statement, here we initialized array elements with constant.
Double diameter []={1,PI/2, PI, 2*PI/2}
It is a legal statement, here we initialized array elements with constant.
With legal declaration & initialization −
 Live Demo
#include<stdio.h>
void main ( ){
   int a,b;
   a= 10, b = 20;
   printf (" %d", a<b);
   printf (" %d", a<=b);
   printf (" %d", a>b);
   printf (" %d", a>=b);
   printf (" %d", a = =b);
   printf (" %d", a ! =b);
}
1 1 0 0 0 1
With illegal declaration & initialization −
#include <stdio.h>
int main(){
   static int p=20, q=p*p;//illegal initialization
   printf("%d%d",p,q);
   return 0;
}
error will be occurred
error: initializer element is not constant
   static int p=20, q=p*p;
Sync your fork with master in GitHub

12 Jun, 2020
GitHub is a major platform for open source contributions and also an amazing way to gain knowledge contributing to others projects. One learns about the latest modules used, different coding styles and also get in touch with various developers around the world and build the community.
While using GitHub and contributing to various apps, it is important we keep our fork repository updated with the master repository as there might be various changes done by various contributors and if we have that updated, it will help us in our future issues and contributions and also use the updated version of the project. Here is the official definition of syncing fork with master
“Getting the latest changes in the master repository after you have forked it without losing the current changes you have made in your local repository.”
So, how do we do it?! If you are a new developer and also new to open source, then this is an important command structure you got to learn which will make your path to open source contribution smooth. 
Following are the steps to Sync your fork with the master:
Step 1: Open your command line or terminal in git bash.
Step 2: Run the following command in your terminal to see the current configured remote repository in your fork:
git remote -v
 Step 3: Run the following command:
git remote add upstream https://github.com/(original_owner_or_organisation/(original_repository).git
This particular command will help you add the upstream which means the link to master repository from which you have forked.
 Step 4: Check your remote now by running the following command again:
git remote -v
It will show something like this, which indicates your own local repository and also your master repository.
 Step 5: Fetch the changes from the upstream with following command:
git fetch upstream
Now, that you’ve set the upstream, it’s time to fetch the changes from the upstream(master repository) that have been made since the time you forked. But make sure, you are in your master branch or any main branch before you run this command.
 Step 6: Merge the fetched changes:
git merge upstream/master
We’ve reached the milestone finally and now it’s all left to merge the changes that you’ve have fetched from your master to the local repository. This command will help you do that. 
After you have run all these commands in stepwise order correctly, you will have all the changes made in the master updated in your local repository successfully.
Git
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Finding Minimum of Two Numbers in Golang

13 Apr, 2020
Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. You can find the smallest number among the given two numbers with the help of Min() function provided by the math package. So, you need to add a math package in your program with the help of the import keyword to access the Min() function.
Syntax:
func Min(a, b float64) float64
If you pass -Inf in this function like Min(-Inf, b) or Min(a, -Inf), then this function will return -Inf.
If you pass NaN in this function like Min(NaN, b) or Min(a, NaN), then this function will return NaN.
If you pass -0 or +0 in this function like Min(-0, -0) or Min(-0, +0) or Min(-0, -0) or Min(+0, -0), then this function will return -0.
Example 1:
// Golang program to illustrate how// to find the smallest number  package main  import (    "fmt"    "math")  // Main functionfunc main() {      // Finding smallest number     // among the given numbers    // Using Min() function    res_1 := math.Min(0, -0)    res_2 := math.Min(-100, 100)    res_3 := math.Min(45.6, 8.9)    res_4 := math.Min(math.NaN(), 67)      // Displaying the result    fmt.Printf("Result 1: %.1f", res_1)    fmt.Printf("\nResult 2: %.1f", res_2)    fmt.Printf("\nResult 3: %.1f", res_3)    fmt.Printf("\nResult 4: %.1f", res_4)  }
Output:
Result 1: 0.0
Result 2: -100.0
Result 3: 8.9
Result 4: NaN

Example 2:
// Golang program to illustrate how// to find the smallest number  package main  import (    "fmt"    "math")  // Main functionfunc main() {      // Finding smallest number    // among the given numbers    // Using Min() function    nvalue_1 := math.Min(34, 67)    nvalue_2 := math.Min(56.7, 90.8)      // Adding minimum numbers    res := nvalue_1 + nvalue_2    fmt.Printf("%.2f + %.2f = %.2f",            nvalue_1, nvalue_2, res)  }
Output:
34.00 + 56.70 = 90.70
Golang-Math
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Parse JSON in Golang?
Constants- Go Language
Go Variables
Loops in Go Language
Time Durations in Golang
Structures in Golang
Strings in Golang
How to iterate over an Array using for loop in Golang?
time.Parse() Function in Golang With Examples
Golang | Goroutine vs Thread
Python | Grouping dictionary keys by value

20 Aug, 2020
While performing computations over dictionary, we can come across a problem in which we might have to perform the task of grouping keys according to value, i.e create a list of keys, it is value of. This can other in cases of organising data in case of machine learning. Let’s discuss certain way in which this task can be performed.Method : Using sorted() + items() + defaultdict() This task can be performed by combining the tasks which can be done by above functions. The defaultdict() is used to create a dictionary initialized with lists, items() gets the key-value pair and grouping is helped by sorted(). 
Python3
# Python3 code to demonstrate working of# Grouping dictionary keys by value# Using sorted() + items() + defaultdict()from collections import defaultdict # Initialize dictionarytest_dict = {'gfg' : 1, 'is' : 2, 'best' : 1, 'for' : 3, 'CS' : 2} # printing original dictionaryprint("The original dictionary : " +  str(test_dict)) # Using sorted() + items() + defaultdict()# Grouping dictionary keys by valueres = defaultdict(list)for key, val in sorted(test_dict.items()):    res[val].append(key)     # printing resultprint("Grouped dictionary is : " + str(dict(res)))
Output:
The original dictionary : {'gfg': 1, 'is': 2, 'best': 1, 'for': 3, 'CS': 2}
Grouped dictionary is : {2: ['CS', 'is'], 1: ['best', 'gfg'], 3: ['for']}
Method 2:
Additionally, This task can also be performed without using any module. So the logic here is: We can check if the keys are present or not 1. No, then we can create key res[v] = [i] 2. Yes, we can append value on the key res[v] + [i]  
Python3
d_input = {'Input.txt': 'Randy', 'Code.py': 'Stan', 'Output.txt': 'Randy'}res = {}for i, v in d_input.items():    res[v] = [i] if v not in res.keys() else res[v] + [i]print(res)
Output:
{'Randy': ['Input.txt', 'Output.txt'], 'Stan': ['Code.py']}
mrathore05
Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
File mkdirs() method in Java with examples

28 Jan, 2019
The mkdirs() method is a part of File class. The mkdirs() function is used to create a new directory denoted by the abstract pathname and also all the non existent parent directories of the abstract pathname. If the mkdirs() function fails to create some directory it might have created some of its parent directories. The function returns true if directory is created else returns false.
Function Signature:
public boolean mkdirs()
Syntax:
file.mkdirs()
Parameters: This method do not accepts any parameter.
Return Value: The function returns boolean data type. The function returns true if directory is created else returns false.
Exception: This method throws SecurityException if the method does not allow directory to be created
Below programs will illustrate the use of mkdirs() function:
Example 1: Try to create a new directory named program in “f:” drive.
// Java program to demonstrate// the use of File.mkdirs() method  import java.io.*;  public class GFG {      public static void main(String args[])    {          // create an abstract pathname (File object)        File f = new File("F:\\program");          // check if the directory can be created        // using the abstract path name        if (f.mkdirs()) {              // display that the directory is created            // as the function returned true            System.out.println("Directory is created");        }        else {              // display that the directory cannot be created            // as the function returned false            System.out.println("Directory cannot be created");        }    }}
Output:
Directory is created
Example 2: Try to create a new directory named program1 in “f:\program” directory, but program directory is not created. We will test whether the function mkdirs() can create the parent directories of the abstract pathname if the directories are not present.
// Java program to demonstrate// the use of File.mkdirs() method  import java.io.*;  public class GFG {      public static void main(String args[])    {        // create an abstract pathname (File object)        File f = new File("F:\\program\\program1");          // check if the directory can be created        // using the abstract path name        if (f.mkdirs()) {              // display that the directory is created            // as the function returned true            System.out.println("Directory is created");        }        else {            // display that the directory cannot be created            // as the function returned false            System.out.println("Directory cannot be created");        }    }}
Output:
Directory is created
The programs might not run in an online IDE. please use an offline IDE and set the path of the file
Java-File Class
Java-Functions
Java-IO package
Java Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Handling TypeError Exception in Python

20 Aug, 2020
TypeError is one among the several standard Python exceptions. TypeError is raised whenever an operation is performed on an incorrect/unsupported object type. For example, using the + (addition) operator on a string and an integer value will raise TypeError.
The general causes for TypeError being raised are:
1. Unsupported operation between two types:
In the following example, the variable ‘geek’ is a string and the variable ‘num’ is an integer. The + (addition) operator cannot be used between these two types and hence TypeError is raised.
Python3
geek = "Geeks"num = 4print(geek + num + geek)
Output :
TypeError: must be str, not int

2. Calling a non-callable identifier:
In the below example code, the variable ‘geek’ is a string and is non-callable in this context. Since it is called in the print statement, TypeError is raised.
Python3
geek = "GeeksforGeeks"print(geek())
Output :
TypeError: 'str' object is not callable

3. Incorrect type of list index:
In Python, list indices must always be an integer value. Since the index value used in the following code is a string, it raises TypeError.
Python3
geeky_list = ["geek", "GeeksforGeeks", "geeky", "geekgod"]index = "1"print(geeky_list[index])
Output :
TypeError: list indices must be integers or slices, not str

4. Iterating through a non-iterative identifier:
In the following code, the value 1234.567890 is a floating-point number and hence it is non-iterative. Forcing Python to iterate on a non-iterative identifier will raise TypeError.
Python3
for geek in 1234.567890:    print(geek)
Output :
TypeError: 'float' object is not iterable

TypeErrors are raised mostly in situations where the programmer fails to check the type of object before performing an operation on them. They can be handled specifically by mentioning them in the except block. In the following example, when one of the indices is found to be an incorrect type, an exception is raised and handled by the program.
Python3
geeky_list = ["Geeky", "GeeksforGeeks", "SuperGeek", "Geek"]indices = [0, 1, "2", 3]for i in range(len(indices)):    try:        print(geeky_list[indices[i]])    except TypeError:        print("TypeError: Check list of indices")
Output :
Geeky
GeeksforGeeks
TypeError: Check list of indices
Geek

Python-exceptions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to extract the host name from URL using JavaScript ?

15 Apr, 2020
To extract the hostname portion from a URL, we can use the location object that represents information about the current URL. It is the element of the window object and a client-side object.
Syntax:
window.location.propertyname
Example 1: In this example, we will use the self URL, where the code will run to extract the hostname.
Program:<!DOCTYPE html><html>  <head>    <title>        Get domain from URL    </title></head>  <body>    <h1 style="color: green">         GeeksforGeeks     </h1>          <b>URL is:</b>           <script>        document.write(window.location.href);    </script>              <br>    <b>hostname is:</b>           <script>        document.write(window.location.hostname);    </script></body>  </html>
<!DOCTYPE html><html>  <head>    <title>        Get domain from URL    </title></head>  <body>    <h1 style="color: green">         GeeksforGeeks     </h1>          <b>URL is:</b>           <script>        document.write(window.location.href);    </script>              <br>    <b>hostname is:</b>           <script>        document.write(window.location.hostname);    </script></body>  </html>
Output: 
Example 2: In this example, we will ask for the URL to the user and then will perform the extraction of hostname on that URL.
Program:<!DOCTYPE html><html>  <head>    <title>Extracting URL</title></head>  <body>    <h1 style="color: green;">GeeksforGeeks</h1>    <b>Extracting URL</b>    <br><br>    <form name="f1">        <input type="text" name="txt"                placeholder="Paste URL"/>        <input type="button" value="click"                onclick="url2()" />    </form>    <script>        function url2() {              var url3 = document.f1.txt.value;              var j = url3.indexOf("://");              var host = "";              for (i = j + 3; i < url3.length; i++) {                if (url3.charAt(i) != '/') {                    host = host + "" + url3.charAt(i);                } else {                    break;                }            }            document.write(host);        }    </script></body>  </html>
<!DOCTYPE html><html>  <head>    <title>Extracting URL</title></head>  <body>    <h1 style="color: green;">GeeksforGeeks</h1>    <b>Extracting URL</b>    <br><br>    <form name="f1">        <input type="text" name="txt"                placeholder="Paste URL"/>        <input type="button" value="click"                onclick="url2()" />    </form>    <script>        function url2() {              var url3 = document.f1.txt.value;              var j = url3.indexOf("://");              var host = "";              for (i = j + 3; i < url3.length; i++) {                if (url3.charAt(i) != '/') {                    host = host + "" + url3.charAt(i);                } else {                    break;                }            }            document.write(host);        }    </script></body>  </html>
Output:
CSS-Misc
HTML-Misc
JavaScript-Misc
Picked
CSS
HTML
JavaScript
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Remove None values from list

03 Jan, 2019
Due to the upcoming of Machine Learning, the focus has now moved on handling the None values than ever before, the reason behind this is that it is the essential step of data preprocessing before it is fed into further techniques to perform. Hence, removal of None values in essential and knowledge of it is a must. Let’s discuss certain ways in which this is achieved.
Method #1 : Naive MethodIn naive method, we iterate through the whole list and append all the filtered, non-None values into a new list, hence ready to be performed with subsequent operations.
# Python3 code to demonstrate # removing None values in list# using naive method   # initializing listtest_list = [1, None, 4, None, None, 5, 8, None]  # printing original list print ("The original list is : " + str(test_list))  # using naive method # to remove None values in listres = []for val in test_list:    if val != None :        res.append(val)  # printing resultprint ("List after removal of None values : " +  str(res))
The original list is : [1, None, 4, None, None, 5, 8, None]
List after removal of None values : [1, 4, 5, 8]

 Method #2 : Using list comprehensionThe longer task of using the naive method and increasing line of codes can be done in a compact way using this method. We just check for True values and construct the new filtered list.
# Python3 code to demonstrate # removing None values in list# using list comprehension  # initializing listtest_list = [1, None, 4, None, None, 5, 8, None]  # printing original list print ("The original list is : " + str(test_list))  # using list comprehension# to remove None values in listres = [i for i in test_list if i]  # printing resultprint ("List after removal of None values : " +  str(res))
The original list is : [1, None, 4, None, None, 5, 8, None]
List after removal of None values : [1, 4, 5, 8]

 Method #3 : Using filter()filter function is the most concise and readable way to perform this particular task. It checks for any None value in list and removes them and form a filtered list without the None values.
# Python3 code to demonstrate # removing None values in list# using filter()  # initializing listtest_list = [1, None, 4, None, None, 5, 8, None]  # printing original list print ("The original list is : " + str(test_list))  # using filter()# to remove None values in listres = list(filter(None, test_list))  # printing resultprint ("List after removal of None values : " +  str(res))
The original list is : [1, None, 4, None, None, 5, 8, None]
List after removal of None values : [1, 4, 5, 8]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
Python program to convert a list to string
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary
numpy.iscomplex() in Python - GeeksforGeeks

28 Mar, 2022
The numpy.iscomplex() function tests element-wise whether it is a complex number or not(not infinity or not Not a Number) and returns the result as a boolean array. Syntax : 
numpy.iscomplex(array)
Parameters : 
array : [array_like] Input array whose element we want to test
Return : 
boolean array containing the result
Code 1 : 
Python
# Python Program illustrating# numpy.iscomplex() method  import numpy as geek print("Is Complex : ", geek.iscomplex([1+1j, 1+0j]), "\n") print("Is Complex : ", geek.iscomplex([0+1j, 0]), "\n")
Output : 
Is Complex :  [ True False] 

Is Complex :  [ True False] 
Code 2 : 
Python
# Python Program illustrating# numpy.iscomplex() method   import numpy as geek  # Returns True/False value for each elementa = geek.arange(20).reshape(5, 4)print("Is complex : \n", geek.iscomplex(a))  # Returns True/False value as ans# because we have mentioned dtpe in the beginningb = geek.arange(20).reshape(5, 4).dtype = complex                print("\n",b)print("\nIs complex : ", geek.iscomplex(b))  b = [[1j],     [3]]print("\nIs complex : \n", geek.iscomplex(b))
Output : 
Is complex : 
 [[False False False False]
 [False False False False]
 [False False False False]
 [False False False False]
 [False False False False]]

Is complex :  False

Is complex : 
 [[ True]
 [False]]
References : https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.isfinite.html 
Note : These codes won’t run on online IDE’s. So please, run them on your systems to explore the working. 
This article is contributed by Mohit Gupta_OMG . If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Akanksha_Rai
vinayedula
Python numpy-Logic Functions
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Get unique values from a list
Python | Pandas dataframe.groupby()
Data Definition Commands in DBMS

Data definition commands are used to create, modify and remove database objects such as schemas, tables, views, indexes etc.
Common Data Definition commands −
The main use of create command is to create a new table in database. It has a predefined syntax in which we specify the columns and their respective data types.
CREATE TABLE <TABLE NAME>
( <COLUMN NAME>  <DATA TYPE>,
<COLUMN NAME>  <DATA TYPE>,
<COLUMN NAME>  <DATA TYPE>,
<COLUMN NAME>  <DATA TYPE>
);
Create a student table with columns student name and roll number.
CREATE TABLE STUDENT
(STUDENT_NAME VARCHAR(30),
ROLL_NUMBER INT
);
An existing database object can be modified using the alter command. Alter command can do following changes to any table-
Add new columns.
Add new columns.
Add new integrity constraints.
Add new integrity constraints.
Modify existing columns. 
Modify existing columns. 
Drop integrity constraints.
Drop integrity constraints.
General Syntax of the ALTER command is mentioned below −
For adding a new column
ALTER TABLE <table_name>  ADD  <column_name>
 For renaming a table
ALTER TABLE <table_name>  RENAME To <new_table_name >
For modifying a column
ALTER TABLE <table_name> MODIFY <column_name > <data type >
For deleting a column
ALTER TABLE <table_name> DROP COLUMN <column_name>
This command can delete an index, table or view. Basically, any component from a relational database management system can be removed using the  Drop command. Once the object is dropped, it cannot be reused.The general syntax of drop command is as follows −
DROP TABLE <table_name>;
DROP DATABASE <database_name>;
DROP TABLE <index_name>;
Using the truncate command, all the records in a database are deleted, but the database structure is maintained.
TRUNCATE TABLE <table name>
This command is used to add comments to the data dictionary.
Single line comments:  use ‘ --‘ before any text. 
Multiline comments:  /* comments in between   */
The rename command renames an object
Rename <old name> to <new name>
When to use @JsonManagedReference and @JsonBackReference annotations using Jackson in Java?

The @JsonManagedReference and @JsonBackReference annotations can be used to create a JSON structure in a bidirectional way. The @JsonManagedReference annotation is a forward reference that includes during the serialization process whereas @JsonBackReference annotation is a backreference that omits during the serialization process.
In the below example, we can implement @JsonManagedReference and @JsonBackReference annotations.
import java.util.*;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.JsonProcessingException;
public class ManagedReferenceBackReferenceTest {
   public static void main(String args[]) throws JsonProcessingException {
      BackReferenceBeanTest testBean = new BackReferenceBeanTest(110, "Sai Chaitanya");
      ManagedReferenceBeanTest bean = new ManagedReferenceBeanTest(135, "Adithya Ram", testBean);
      testBean.addEmployees(bean);
      ObjectMapper mapper = new ObjectMapper();
      String jsonString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(bean);
      System.out.println(jsonString);
   }
}
class ManagedReferenceBeanTest {
   public int empId = 115;
   public String empName = "Raja Ramesh";
   @JsonManagedReference
   public BackReferenceBeanTest manager;
   public ManagedReferenceBeanTest(int empId, String empName, BackReferenceBeanTest manager) {
      this.empId = empId;
      this.empName = empName;
      this.manager = manager;
   }
}
class BackReferenceBeanTest {
   public int empId = 125;
   public String empName = "Jai Dev";
   @JsonBackReference
   public List<ManagedReferenceBeanTest> list;
   public BackReferenceBeanTest(int empId, String empName) {
      this.empId = empId;
      this.empName = empName;
      list = new ArrayList<ManagedReferenceBeanTest>();
   }
   public void addEmployees(ManagedReferenceBeanTest managedReferenceBeanTest) {
      list.add(managedReferenceBeanTest);
   }
}
{
   "empId" : 135,
   "empName" : "Adithya Ram",
   "manager" : {
      "empId" : 110,
      "empName" : "Sai Chaitanya"
   }
}
PHP | hash_pbkdf2() Function - GeeksforGeeks

29 Oct, 2018
The hash_pbkdf2() function is an inbuilt function in PHP which is used to generate a PBKDF2 key derivation of a supplied password.
Syntax:
string hash_pbkdf2( $algo, $pass, $salt, $itr, $len, $raw_opt )
Parameters: This function accept six parameters as mention above and describe below.
$algo: It is the required parameter which specifies the selected hashing algorithm (like- “md5”, “sha256”, “sha1”).
$pass: This parameter is used to specify the password to use for the derivation.
$salt: This parameter is used for the derivation and the value should be generated randomly.
$itr: This parameter count the number of internal iterations.
$len: This parameter is used to hold the length of the output string.
$raw_opt: If this parameter set to True then its output will be raw binary data and if this parameter set to false then output will be lowercase hexits.
Return Value: This function returns the string containing the calculated message digest as lowercase hexits.
Below programs illustrate the hash_pbkdf2() function in PHP:Program 1:
<?php$gfg = "GeeksforGeeks";$iterations = 142;  // Generate a random IV using // openssl_random_pseudo_bytes()// random_bytes() or another // suitable source of randomness.$salt = openssl_random_pseudo_bytes(16);  // Using hash_pbkdf2 function$hash = hash_pbkdf2("md5",    $gfg, $salt, $iterations, 30);  // Display resultecho $hash;?>
f0ebbbf59869d76f946c4b15340761

Program 2:
<?php$gfg = "Contribute1234";$iterations = 100;  // Generate a random IV using // openssl_random_pseudo_bytes()// random_bytes() or another // suitable source of randomness.$salt = openssl_random_pseudo_bytes(8);  // Using hash_pbkdf2 function$hash = hash_pbkdf2("md5",    $gfg, $salt, $iterations, 20, false);  // Display resultecho $hash;?>
715b385158045923923c

Reference: http://php.net/manual/en/function.hash-pbkdf2.php
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to fetch data from localserver database and display on HTML table using PHP ?
How to pass form variables from one page to other page in PHP ?
Create a drop-down list that options fetched from a MySQL database in PHP
How to create admin login page using PHP?
Different ways for passing data to view in Laravel
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Java - FileReader Class

This class inherits from the InputStreamReader class. FileReader is used for reading streams of characters.
This class has several constructors to create required objects. Following is the list of constructors provided by the FileReader class.
FileReader(File file)
This constructor creates a new FileReader, given the File to read from.
FileReader(FileDescriptor fd)
This constructor creates a new FileReader, given the FileDescriptor to read from.
FileReader(String fileName)
This constructor creates a new FileReader, given the name of the file to read from.
Once you have FileReader object in hand then there is a list of helper methods which can be used to manipulate the files.
public int read() throws IOException
Reads a single character. Returns an int, which represents the character read.
public int read(char [] c, int offset, int len)
Reads characters into an array. Returns the number of characters read.
Following is an example to demonstrate class −
import java.io.*;
public class FileRead {

   public static void main(String args[])throws IOException {
      File file = new File("Hello1.txt");
      
      // creates the file
      file.createNewFile();
      
      // creates a FileWriter Object
      FileWriter writer = new FileWriter(file); 
      
      // Writes the content to the file
      writer.write("This\n is\n an\n example\n"); 
      writer.flush();
      writer.close();

      // Creates a FileReader Object
      FileReader fr = new FileReader(file); 
      char [] a = new char[50];
      fr.read(a);   // reads the content to the array
      
      for(char c : a)
         System.out.print(c);   // prints the characters one by one
      fr.close();
   }
}
This will produce the following result −
This
is
an
example


    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
How to return a Pointer from a Function in C - GeeksforGeeks

19 Aug, 2020
Pointers in C programming language is a variable which is used to store the memory address of another variable. We can pass pointers to the function as well as return pointer from a function. But it is not recommended to return the address of a local variable outside the function as it goes out of scope after function returns.
Program 1:
The below program will give segmentation fault since ‘A’ was local to the function:
C
// C program to illustrate the concept of// returning pointer from a function#include <stdio.h>  // Function returning pointerint* fun(){    int A = 10;    return (&A);}  // Driver Codeint main(){    // Declare a pointer    int* p;      // Function call    p = fun();      printf("%p\n", p);    printf("%d\n", *p);    return 0;}
The main reason behind this scenario is that compiler always make a stack for a function call. As soon as the function exits the function stack also gets removed which causes the local variables of functions goes out of scope.
Static Variables have a property of preserving their value even after they are out of their scope. So to execute the concept of returning a pointer from function in C you must define the local variable as a static variable.
Program 2:
C
// C program to illustrate the concept of// returning pointer from a function#include <stdio.h>  // Function that returns pointerint* fun(){    // Declare a static integer    static int A = 10;    return (&A);}  // Driver Codeint main(){    // Declare a pointer    int* p;      // Function call    p = fun();      // Print Address    printf("%p\n", p);      // Print value at the above address    printf("%d\n", *p);    return 0;}
0x601038
10

C-Functions
C-Pointers
C Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C Program to read contents of Whole File
Producer Consumer Problem in C
C program to find the length of a string
Exit codes in C/C++ with Examples
Difference between break and continue statement in C
Regular expressions in C
How to store words in an array in C?
Handling multiple clients on server with multithreading using Socket Programming in C/C++
Conditional wait and signal in multi-threading
C / C++ Program for Dijkstra's shortest path algorithm | Greedy Algo-7
How to use the front camera in Swift?

To use the front camera in swift we first need to get a list of cameras available in the device we are using. In this article we’ll see how to get the list of devices and then check if the front camera is available or not. We’ll do it in a series of steps.
Import AVFoundation
Check if the list of cameras exists
Filter out the front camera if exists.
guard let frontCamera = AVCaptureDevice.devices().filter({ $0.position == .front })
.first as? AVCaptureDevice else {
   fatalError("Front camera not found")
}
The devices() method of AVCapture returns the list of cameras available. From that list of the camera, we’ll use the filter function in which we’ll check if the position is a camera in front or not. We can convert this to a function and use the front camera.
func checkCamera() {
   guard let frontCamera = AVCaptureDevice.devices().filter({ $0.position == .front })
   .first as? AVCaptureDevice else {
      fatalError("Front camera not found")
   }
}
Note − This cannot be run on a simulator as a simulator does not have any camera.
Program to convert given Matrix to a Diagonal Matrix in C++

Given with the matrix of size nxn the task it to convert any type of given matrix to a diagonal matrix.
Diagonal matrix is the nxn matrix whose all the non-diagonal elements are zero and diagonal elements can be any value.
Given below is the diagram of converting non-diagonal elements to 0.
[123456789]→[103050709]
The approach is to start one loop for all non-diagonal elements and another loop for diagonal elements and replace the value of non-diagonals with zero and leave diagonals elements unchanged.
Input-: matrix[3][3] = {{ 1, 2, 3 },
   { 4, 5, 6 },
   { 7, 8, 9 }}
Output-: {{ 1, 0, 3},
   { 0, 5, 0},
   { 7, 0, 9}}
Input-: matrix[3][3] = {{ 91, 32, 23 },
   { 40, 51, 26 },
   { 72, 81, 93 }}
Output-: {{ 91, 0, 23},
   { 0, 51, 0},
   { 72, 0, 93}}
Start
Step 1-> define macro for matrix size as const int n = 10
Step 2-> Declare function for converting to diagonal matrix
   void diagonal(int arr[][n], int a, int m)
      Loop For int i = 0 i < a i++
         Loop For int j = 0 j < m j++
            IF i != j & i + j + 1 != a
               Set arr[i][j] = 0
            End
         End
      End
      Loop For int i = 0 i < a i++
         Loop For int j = 0 j < m j++
            Print arr[i][j]
         End
         Print \n
      End
Step 2-> In main()
   Declare matrix as int arr[][n] = { { 1, 2, 3 },
      { 4, 5, 6 },
      { 7, 8, 9 } }
   Call function as diagonal(arr, 3, 3)
Stop
 Live Demo
#include <iostream>
using namespace std;
const int n = 10;
//print 0 at diagonals in matrix of nxn
void diagonal(int arr[][n], int a, int m) {
   for (int i = 0; i < a; i++) {
      for (int j = 0; j < m; j++) {
         if (i != j && i + j + 1 != a)
         arr[i][j] = 0;
      }
   }
   for (int i = 0; i < a; i++) {
      for (int j = 0; j < m; j++) {
         cout << arr[i][j] << " ";
      }
      cout << endl;
   }
}
int main() {
   int arr[][n] = { { 1, 2, 3 },
      { 4, 5, 6 },
      { 7, 8, 9 } };
   diagonal(arr, 3, 3);
   return 0;
}
IF WE RUN THE ABOVE CODE IT WILL GENERATE FOLLOWING OUTPUT
0 2 0
4 0 6
0 8 0
Tk - Button Widget

Tk button widget is a clickable widget that triggers an action. The syntax for button widget is shown below −
button buttonName options

The options available for the button widget are listed below in table −
-font fontDescriptor
Used to set font for widget.
-height number
Used to set height for widget.
-command action
Sets the command action for button.
-text text
Sets the text for the widget.
-width number
Sets the width for widget.
A simple button widget is shown below −
#!/usr/bin/wish

grid [label .myLabel  -text "Click the buttons" -textvariable labelText]
grid [button .myButton1  -text "Button 1" -font {Helvetica -18 bold} -height 5 -width 10
   -command "set labelText clicked_top_btn"]
grid [button .myButton2 -text "Button 2" -font {Helvetica -18 bold} -height 5 -width 10
   -command "set labelText clicked_bottom_btn"]
When we run the above program, we will get the following output −
When we click the Button1, we will get the following output −
When we click the Button2, we will get the following output −
 Print
 Add Notes
 Bookmark this page
Get the index of maximum value in DataFrame column - GeeksforGeeks

01 Nov, 2021
Pandas DataFrame is two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Let’s see how can we get the index of maximum value in DataFrame column.Observe this dataset first. We’ll use ‘Weight’ and ‘Salary’ columns of this data in order to get the index of maximum values from a particular column in Pandas DataFrame. 
Python3
# importing pandas moduleimport pandas as pd   # making data framedf = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv") df.head(10)
Code #1: Check the index at which maximum weight value is present.  
Python3
# importing pandas moduleimport pandas as pd   # making data framedf = pd.read_csv("nba.csv") # Returns index of maximum weightdf[['Weight']].idxmax()
Output:  
We can verify whether the maximum value is present in index or not.  
Python3
# importing pandas moduleimport pandas as pd    # making data framedf = pd.read_csv("nba.csv")  # from index 400 to 409df.iloc[400:410]
Output:  
  Code #2: Let’s insert a new row at index 0, having maximum salary and then verify.  
Python3
# importing pandas moduleimport pandas as pd    # making data framedf = pd.read_csv("nba.csv") new_row = pd.DataFrame({'Name':'Geeks', 'Team':'Boston', 'Number':3,                        'Position':'PG', 'Age':33, 'Height':'6-2',                        'Weight':189, 'College':'MIT', 'Salary':999999999}                         , index=[0])  df = pd.concat([new_row, df]).reset_index(drop=True)df.head(5)
Output:  
Now, let’s check if the maximum salary is present at index 0 or not.  
Python3
# Returns index of minimum salarydf[['Salary']].idxmax()
Output:  
 
prachisoda1234
pandas-dataframe-program
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
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
Convert integer to string in Python
Finding Login Counts and Creation Dates in SQL Server - GeeksforGeeks

11 Jun, 2021
A SQL login is another credential that allows you to access SQL Server. When you log on to Windows or even your e-mail account, for example, you enter your username and password. The logins are made up of such a username and password. As a result, SQL logins are just a username and password.
A SQL login is a security principal that applies to the whole SQL Server instance, which can contain many databases. Windows authenticated login and SQL Server authenticated login are the two basic forms of login.
We usually require access to a specific database once we have joined SQL Server. This login must be mapped to a database user in order to gain access to the database. A login is mapped and identified to a user using a security identifier within SQL Server (SID).
There are four different types of logins available in SQL Server:
Windows credentials are used to log in.
A SQL Server-specific login.
A login that is associated with a certificate.
A symmetric key is mapped to a logon.
Refer Create Login in SQL Server to find out how to create a login. 
How can I find out how many logins and when they were built in a SQL Server database?Several SQL Server queries that return information about logins are mentioned below. You may use the following question to determine the number of logins on your SQL Server:
SELECT COUNT(*)
  FROM master..syslogins
GO
Running the above query in SQL Server Management Studio : 
To get a list of logins on your server as well as the date they were created, run the following query:
SELECT name, createdate
  FROM master..syslogins
GO
Running the above query in SQL Server Management Studio : 
Similarly, you can use the following SQL queries to get the number of users in a database, a list of user names, and the dates the users were created:
USE <database_name>
GO
SELECT COUNT(*)
  FROM sysusers
GO
SELECT name, createdate
  FROM sysusers
GO
The above-mentioned queries should provide you with the required username and user details.
Example – 
USE SQL_DBA
GO
SELECT COUNT(*)
FROM sysusers
SELECT name, createdate
FROM sysusers
Running the above query in SQL Server Management Studio : 
DBMS-SQL
SQL-Server
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?
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL | Subquery
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
Check if the objects or variables are defined in Julia - isdefined() and @isdefined() Methods - GeeksforGeeks

01 Apr, 2020
The isdefined() is an inbuilt function in julia which is used to test whether the specified global variable or object field is defined or not. The passed parameters can be a module and a symbol or a composite object and field name (as a symbol) or index.
Syntax:isdefined(m::Module, s::Symbol)orisdefined(object, s::Symbol)orisdefined(object, index::Int)
Parameters:
m::Module: Specified module.
s::Symbol: Specified symbol.
object: Specified composite object.
index::Int: Specified index.
Returns: It returns true for the defined specified global variable or object field else returns false.
Example:
# Julia program to illustrate # the use of isdefined() method   # Getting true for the defined # specified global variable or # object field else returns false.println(isdefined(Base, :sum))println(isdefined(Base, :num))println(isdefined(Base, :NonExistentMethod))  # Initialising a composite type value with # Floor division operatora = 2//3;println(isdefined(a, 1))println(isdefined(a, 2))println(isdefined(a, :num))println(isdefined(a, :numerator))
Output:
true
true
false
true
true
true
false
The @isdefined() is an inbuilt function in julia which is used to tests whether the specified variable s is defined in the current scope or not.
Syntax:@isdefined s
Parameters:
s: Specified variable.
Returns: It returns true if the specified variable s is defined in the current scope else returns false.
Example:
# Julia program to illustrate # the use of @isdefined() method   # Getting true if the specified variable# s is defined in the current scope# else returns false.function f()    println(@isdefined x)    x = 10    println(@isdefined x)    endf (generic function with 1 method)println(f())
Output:
Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Vectors in Julia
Getting rounded value of a number in Julia - round() Method
Decision Making in Julia (if, if-else, Nested-if, if-elseif-else ladder)
Storing Output on a File in Julia
Formatting of Strings in Julia
Manipulating matrices in Julia
Creating array with repeated elements in Julia - repeat() Method
Reshaping array dimensions in Julia | Array reshape() Method
while loop in Julia
Get array dimensions and size of a dimension in Julia - size() Method
HTML <button> value Attribute - GeeksforGeeks

16 Feb, 2019
The value attribute for <button> element in HTML is used to specify the initial value of the button element.
Syntax:
<button value = "value">
Example:
<!DOCTYPE html><html>    <head>        <title>HTML button value Attribute</title>    </head>    <body style = "text-align:center">        <h1 style = "color:green;">            GeeksforGeeks        </h1>                  <h2>            HTML button value Attribute        </h2>                  <button id="btn" value="GeeksforGeeks" onclick="geek()">         Click me!</button>                  <p id="g"></p>                  <script>            function geek() {              var x = document.getElementById("btn").value;              document.getElementById("g").innerHTML =  x;            }        </script>    </body></html>
Output:Before clicking the button:After clicking the button:Supported Browsers: The browser supported by value attribute in button element are listed below:
Apple Safari
Google Chrome
Firefox
Opera
Internet Explorer
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?