code-rag-bench/online-tutorials huggingface dataset:
Difference between 1's Complement representation and 2's Complement representation Technique - GeeksforGeeks

26 Apr, 2021
Prerequisite – Representation of Negative Binary Numbers
1’s complement of a binary number is another binary number obtained by toggling all bits in it, i.e., transforming the 0 bit to 1 and the 1 bit to 0.
Examples:
Let numbers be stored using 4 bits

1's complement of 7 (0111) is 8 (1000)
1's complement of 12 (1100) is 3 (0011)

2’s complement of a binary number is 1 added to the 1’s complement of the binary number.Examples:
Let numbers be stored using 4 bits

2's complement of 7 (0111) is 9 (1001)
2's complement of 12 (1100) is 4 (0100)

 
These representations are used for signed numbers.
The main difference between 1′ s complement and 2′ s complement is that 1′ s complement has two representations of 0 (zero) – 00000000, which is positive zero (+0) and 11111111, which is negative zero (-0); whereas in 2′ s complement, there is only one representation for zero – 00000000 (+0) because if we add 1 to 11111111 (-1), we get 00000000 (+0) which is the same as positive zero. This is the reason why 2′ s complement is generally used.
Another difference is that while adding numbers using 1′ s complement, we first do binary addition, then add in an end-around carry value. But, 2′ s complement has only one value for zero, and doesn’t require carry values.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
base-conversion
complement
Computer Organization & Architecture
Difference Between
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Cache Memory in Computer Organization
Addressing Modes
Architecture of 8086
Logical and Physical Address in Operating System
Random Access Memory (RAM) and Read Only Memory (ROM)
Difference between BFS and DFS
Class method vs Static method in Python
Differences between TCP and UDP
Difference between var, let and const keywords in JavaScript
Difference between Process and Thread
SAP ABAP - Object Events

An event is a set of outcomes that are defined in a class to trigger the event handlers in other classes. When an event is triggered, we can call any number of event handler methods. The link between a trigger and its handler method is actually decided dynamically at run-time.
In a normal method call, a calling program determines which method of an object or a class needs to be called. As fixed handler method is not registered for every event, in case of event handling, the handler method determines the event that needs to be triggered.
An event of a class can trigger an event handler method of the same class by using the RAISE EVENT statement. For an event, the event handler method can be defined in the same or different class by using the FOR EVENT clause, as shown in the following syntax −
FOR EVENT <event_name> OF <class_name>.

Similar to the methods of a class, an event can have parameter interface but it has only output parameters. The output parameters are passed to the event handler method by the RAISE EVENT statement that receives them as input parameters. An event is linked to its handler method dynamically in a program by using the SET HANDLER statement.
When an event is triggered, appropriate event handler methods are supposed to be executed in all the handling classes.
REPORT ZEVENT1. 
CLASS CL_main DEFINITION. 
PUBLIC SECTION. 
DATA: num1 TYPE I. 
METHODS: PRO IMPORTING num2 TYPE I. 
EVENTS: CUTOFF. 
ENDCLASS. 

CLASS CL_eventhandler DEFINITION. 
PUBLIC SECTION. 
METHODS: handling_CUTOFF FOR EVENT CUTOFF OF CL_main. 
ENDCLASS. 

START-OF-SELECTION. 
DATA: main1 TYPE REF TO CL_main. 
DATA: eventhandler1 TYPE REF TO CL_eventhandler. 

CREATE OBJECT main1. 
CREATE OBJECT eventhandler1. 

SET HANDLER eventhandler1→handling_CUTOFF FOR main1. 
main1→PRO( 4 ).
CLASS CL_main IMPLEMENTATION.
METHOD PRO.
num1 = num2.
IF num2 ≥ 2. 
RAISE EVENT CUTOFF.
ENDIF. 
ENDMETHOD.
ENDCLASS.

CLASS CL_eventhandler IMPLEMENTATION.
METHOD handling_CUTOFF.
WRITE: 'Handling the CutOff'. 
WRITE: / 'Event has been processed'. 
ENDMETHOD. ENDCLASS.
The above code produces the following output −
Handling the CutOff 
Event has been processed


    25 Lectures 
     6 hours 

 Sanjo Thomas

    26 Lectures 
     2 hours 

 Neha Gupta

    30 Lectures 
     2.5 hours 

 Sumit Agarwal

    30 Lectures 
     4 hours 

 Sumit Agarwal

    14 Lectures 
     1.5 hours 

 Neha Malik

    13 Lectures 
     1.5 hours 

 Neha Malik
 Print
 Add Notes
 Bookmark this page
How to deal with security certificates using Selenium?

We can deal with security certificates using Selenium webdriver. We can have certificates like the SSL certificate and insecure certificate. All these can be handled with the help of the DesiredCapabilities and ChromeOptions class.
We shall create an object of the DesiredCapabilities class and apply setCapability method on it. Then pass the CapabilityType and value as parameters to that method.
These general browser chrome profiles shall be fed to the object of the ChromeOptions class for the local browser with the help of the merge method. Finally, this information needs to be passed to the webdriver object.
DesiredCapabilities c=DesiredCapabilities.chrome();
c.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
c.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
ChromeOptions opt= new ChromeOptions();
opt.merge(c);
Example of a SSL certificate is shown below. We need to click on the Proceed anyway button to accept this certificate.
Example of Insecure certificate is shown below −
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
public class SecurityCertAccepts{
   public static void main(String[] args) {
      //DesiredCapabilities object
      DesiredCapabilities c=DesiredCapabilities.chrome();
      //accept insecure certificates
      c.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
      //accept SSL certificates
      c.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
      //ChromeOptions object
      ChromeOptions opt= new ChromeOptions();
      //merging browser profiles
      opt.merge(c);
      System.setProperty("webdriver.chrome.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      // configure options parameter to Chrome driver
      WebDriver driver = new ChromeDriver(opt);
   }
}
Java Examples - Find min & max from a List

How to find min & max of a List ?
Following example uses min & max Methods to find minimum & maximum of the List.
import java.util.*;

public class Main {
   public static void main(String[] args) {
      List list = Arrays.asList("one Two three Four five six one three Four".split(" "));
      System.out.println(list);
      System.out.println("max: " + Collections.max(list));
      System.out.println("min: " + Collections.min(list));
   }
}
The above code sample will produce the following result.
[one, Two, three, Four, five, six, one, three, Four]
max: three
min: Four

 Print
 Add Notes
 Bookmark this page
Hashtable get() Method in Java - GeeksforGeeks

28 Jun, 2018
The java.util.Hashtable.get() method of Hashtable class is used to retrieve or fetch the value mapped by a particular key mentioned in the parameter. It returns NULL when the table contains no such mapping for the key.
Syntax:
Hash_Table.get(Object key_element)
Parameter: The method takes one parameter key_element of object type and refers to the key whose associated value is supposed to be fetched.
Return Value: The method returns the value associated with the key_element in the parameter.
Below programs illustrates the working of java.util.Hashtable.get() method:Program 1:
// Java code to illustrate the get() methodimport java.util.*;  public class Hash_Table_Demo {    public static void main(String[] args)    {          // Creating an empty Hashtable        Hashtable<Integer, String> hash_table =                            new Hashtable<Integer, String>();          // Inserting the values into table        hash_table.put(10, "Geeks");        hash_table.put(15, "4");        hash_table.put(20, "Geeks");        hash_table.put(25, "Welcomes");        hash_table.put(30, "You");          // Displaying the Hashtable        System.out.println("Initial Table is: " + hash_table);          // Getting the value of 25        System.out.println("The Value is: " + hash_table.get(25));          // Getting the value of 10        System.out.println("The Value is: " + hash_table.get(10));    }}
Initial Table is: {10=Geeks, 20=Geeks, 30=You, 15=4, 25=Welcomes}
The Value is: Welcomes
The Value is: Geeks

Program 2:
// Java code to illustrate the get() methodimport java.util.*;  public class Hash_Table_Demo {    public static void main(String[] args)    {          // Creating an empty Hashtable        Hashtable<String, Integer> hash_table =                             new Hashtable<String, Integer>();          // Inserting the values into table        hash_table.put("Geeks", 10);        hash_table.put("4", 15);        hash_table.put("Geeks", 20);        hash_table.put("Welcomes", 25);        hash_table.put("You", 30);          // Displaying the Hashtable        System.out.println("Initial table is: " + hash_table);          // Getting the value of "Geeks"        System.out.println("The Value is: " + hash_table.get("Geeks"));          // Getting the value of "You"        System.out.println("The Value is: " + hash_table.get("You"));    }}
Initial table is: {You=30, Welcomes=25, 4=15, Geeks=20}
The Value is: 20
The Value is: 30

Note: The same operation can be performed with any type of variation and combination of different data types.
Java-Collections
Java-HashTable
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Arrays.sort() in Java with examples
Reverse a string in Java
Initialize an ArrayList in Java
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
Typecasting in C

20 Jan, 2021
Typecasting: It is a data type is converted into another data type by the programmer using the casting operator during the program design. In typecasting, the destination data type may be smaller than the source data type when converting the data type to another data type, that’s why it is also called narrowing conversion.
There are some cases where if the datatype remains unchanged, it can give incorrect output. In such cases, typecasting can help to get correct output and reduce the time of compilation.
Program 1:
Below is the C program to illustrate the need for typecasting:
C
// C program to illustrate the use of// typecasting#include <stdio.h>  // Function to divide a and bvoid division(int a, int b){    float div;      // Division of a and b    div = a / b;      printf("The result is %f\n", div);}  // Driver Codeint main(){    // Given a & b    int a = 15, b = 2;      // Function Call    division(a, b);      return 0;}
The result is 7.000000

Explanation: Here, the actual output needed is 7.500000, but the result is 7.000000. So to get the correct output one way is to change the data type of a given variable. But correct output can also be done by typecasting. This consists of putting a pair of parentheses around the name of the data type like division = (float) a/b.
Program 2:
Below is the C program to showcase the use of typecasting:
C
// C program to showcase the use of// typecasting#include <stdio.h>  // Function to divide a and bvoid division(int a, int b){    float div;      // Typecasting in float    div = (float)a / b;      printf("The result is %f\n", div);}  // Driver Codeint main(){    // Given a & b    int a = 15, b = 2;      // Function Call    division(a, b);      return 0;}
The result is 7.500000

Explanation: In the above C program, the expression (float) converts variable a from type int to type float before the operation.
C Basics
Data Type
C Language
C Programs
Programming Language
Technical Scripter
Data Type
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Unordered Sets in C++ Standard Template Library
Operators in C / C++
Exception Handling in C++
What is the purpose of a function prototype?
TCP Server-Client implementation in C
Strings in C
Arrow operator -> in C/C++ with Examples
Basics of File Handling in C
Header files in C/C++ and its uses
UDP Server-Client implementation in C
PHP | is_numeric() Function

05 Feb, 2021
The is_numeric() function is an inbuilt function in PHP which is used to check whether a variable passed in function as a parameter is a number or a numeric string or not. The function returns a boolean value.
Syntax: 
bool is_numeric ( $var )
Parameters: The function accepts a single parameter which is mandatory and described below: 
$var: This input parameter is the variable which the function checks for whether it is a number or a numeric string. Based on this verification, the function returns a boolean value.
Return Value: The function returns TRUE if $var is a number or a numeric string and returns FALSE otherwise.
Examples:  
Input : $var = 12
Output : True

Input : $var = "Geeks for Geeks"
Output : False
Below programs illustrate the is_numeric() function:
Program 1: In this program, a number is passed as input.  
PHP
<?php $num = 12;if (is_numeric($num)) {        echo $num . " is numeric";    }    else {        echo $num . " is not numeric";    } ?>
12 is numeric
 
Program 2: In this program, a string is passed as input. 
PHP
<?php $element = "Geeks for Geeks";if (is_numeric($element)) {        echo $element . " is numeric";    }    else {        echo $element . " is not numeric";    } ?>
Geeks for Geeks is not numeric
 
Program 3: In this program, a numeric string is passed as input. 
PHP
<?php $num = "467291";if (is_numeric($num)) {        echo $num . " is numeric";    }    else {        echo $num . " is not numeric";    } ?>
467291 is numeric
 
Program 4:
PHP
<?php$array = array(    "21/06/2018",    4743,    0x381,    01641,   0b1010010011,    "Geek Classes"); foreach ($array as $i) {    if (is_numeric($i)) {        echo $i . " is numeric"."\n";    } else {        echo $i . " is NOT numeric"."\n";    }}?>
21/06/2018 is NOT numeric
4743 is numeric
897 is numeric
929 is numeric
659 is numeric
Geek Classes is NOT numeric
 
Reference: http://php.net/manual/en/function.is-numeric.php 
arorakashish0911
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to fetch data from localserver database and display on HTML table using PHP ?
Difference between HTTP GET and POST Methods
Different ways for passing data to view in Laravel
PHP | file_exists( ) Function
PHP | Ternary Operator
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Lodash _.assignIn() Method

09 Sep, 2020
The Lodash _.assignIn() Method is like the _.assign() method except that it iterates over its own and inherited source properties. Subsequent source objects overwrite property assignments of previous sources. This method mutates the object.
Syntax:
_.assignIn( dest_object, [src_obj])

Parameters: This method accepts two parameters as mentioned above and described below:
dest_object: This is the destination object.
src_obj: These are the source objects.
Return Value: This method returns an object.
Example 1:
Javascript
// Defining Lodash variable const _ = require('lodash');   function Gfg1() {  this.a = 1;}   function Gfg2() {  this.c = 3;}   Gfg1.prototype.b = 10;Gfg2.prototype.d = 40;   console.log(_.assignIn( { a: 4 },     new Gfg1, new Gfg2));
Output:
{ a: 1, b: 10, c: 3, d: 40 }
Example 2:
Javascript
// Defining Lodash variable const _ = require('lodash');   function Gfg1() {  this.a = 1;}   function Gfg2() {  this.c = 3;}   console.log(_.assignIn( { a: 4 },     new Gfg1, new Gfg2));
Output:
{ a: 1, c: 3 }
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker – COPY Instruction

29 Oct, 2020
In Docker, there are two ways to copy a file, namely, ADD and COPY. Though there is a slight difference between them in regard to the scope of the functions, they more or less perform the same task. In this article, we will primarily focus on the COPY instruction of Docker. If you want to copy files and directories inside a Docker Container from your Local machine, you can use the COPY instruction inside your Dockerfile. The general form of a COPY instruction is:
Syntax: COPY <src-path> <destination-path>


In this article, we will discuss how to use the COPY Instruction to copy files and directories inside a Docker Container. To do so follow the below steps:
In this example, we will create a directory and a file which we will copy using the COPY command. Create a folder and inside it create a file called “dockerfile” which we will edit in the next step. Create another folder in the same directory where you have created the Dockerfile and a file inside it. We will copy this folder to our Docker Container. The final directory structure will be –
After you have created the directory structure, edit the Dockerfile that we created in the previous step.
FROM ubuntu:latest
RUN apt-get -y update
COPY to-be-copied .

In the above Dockerfile, we have tried to pull the Ubuntu base image OS with the latest tag and run an update inside the Container. We have then included the COPY instruction to copy the directory created previously.
After creating the Dockerfile, we can now build the Docker Image using the Docker Build command.
sudo docker build -t sample-image .


After you have built the Docker Image, you can verify it by using the Docker Images command to list all the images in your system.
sudo docker images

After you have built the Docker Image with the COPY Instruction, you can now run the Docker container using the Docker RUN command.
sudo docker run -it sample-image bash


You can now verify whether the directory has been copied or not by listing the directories inside the Container.
Docker Container
linux
Advanced Computer Subject
Articles
Linux-Unix
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
System Design Tutorial
ML | Linear Regression
Reinforcement learning
Supervised and Unsupervised learning
Decision Tree Introduction with example
Tree Traversals (Inorder, Preorder and Postorder)
SQL | Join (Inner, Left, Right and Full Joins)
find command in Linux with examples
Analysis of Algorithms | Set 1 (Asymptotic Analysis)
SQL Interview Questions
Sort function in Lua programming

One of the most used functions in Lua is the sort function which is provided by the Lua library which tables a table as an argument and sorts the values that are present inside the table.
The sort function also takes one more argument with the table and that argument is a function which is known as the order function. This order function is used to provide the logic if we want to sort the elements of the table in a certain order.
The order function takes two arguments, and these two arguments must return true if the first argument should come first in the sorted array. If this function is not provided, sort uses the default less-than operation (corresponding to the `< ́ operator).
table.sort(x,f)
In the above syntax, the x identifier is used to represent the name of the table which entries we want to sort, and the f identifier is used to represent the order function which is not necessary to provide if you are okay with the default order of sorting.
Let’s consider a simple example of a table where we have different strings stored in it and we are printing the values of the table using the generic for loop.
Consider the example shown below −
 Live Demo
t = { "the", "quick", "brown", "fox" }
for i,v in ipairs(t) do print(v) end
the
quick
brown
fox
Now, let’s consider the scenario that we want to sort the elements of the above table, for that we just need to use the sort function that the Lua library provides us.
Consider the example shown below −
 Live Demo
t = { "the", "quick", "brown", "fox" }
table.sort(t)
for i,v in ipairs(t) do print(v) end
brown
fox
quick
the
Now let’s consider a more complex example, where we will try to use an order function.
Consider the example shown below −
 Live Demo
t = {
   { str = 42, dex = 10, wis = 100 },
   { str = 18, dex = 30, wis = 5 }
}
table.sort(t, function (k1, k2) return k1.str < k2.str end )
for i,v in ipairs(t) do print(v.str,v.dex,v.wis) end
In the above example, the idea is to sort the values in the table based on the “str” field, and hence when I print the values of the fields, they will be in that order.
18   30  5
42   10  100
Write a C macro PRINT(x) which prints x

13 May, 2022
At the first look, it seems that writing a C macro which prints its argument is child’s play.  Following program should work i.e. it should print x 
c
#define PRINT(x) (x)int main(){    printf("%s", PRINT(x));    return 0;}
But it would issue compile error because the data type of x, which is taken as variable by the compiler, is unknown. Now it doesn’t look so obvious. Isn’t it? Guess what, the followings also won’t work 
c
#define PRINT(x) ('x')#define PRINT(x) ("x")
But if we know one of the lesser known traits of C language, writing such a macro is really a child’s play.  In C, there’s a # directive, also called ‘Stringizing Operator’, which does this magic. Basically # directive converts its argument in a string. Voila! it is so simple to do the rest. So the above program can be modified as below. 
c
#include <stdio.h>#define PRINT(x) (#x)int main(){    printf("%s", PRINT(x));    return 0;}
Now if the input is PRINT(x), it would print x. In fact, if the input is PRINT(geeks), it would print geeks. You may find the details of this directive from Microsoft portal here.
mdsaif0405
C Macro
C-Macro & Preprocessor
c-puzzle
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Finding Network ID of a Subnet (using Subnet Mask)

08 Aug, 2019
In order to find network id (NID) of a Subnet, one must be fully acquainted with the Subnet mask.
Subnet Mask:It is used to find which IP address belongs to which Subnet. It is a 32 bit number, containing 0’s and 1’s. Here network id part and Subnet ID part is represented by all 1’s and host ID part is represented by all 0’s.
Example:If Network id of a entire network = 193.1.2.0 (it is class C IP). For more about class C IP see Classful Addressing.
In the above diagram entire network is divided into four parts, which means there are four subnets each having two bits for Subnet ID part.
Subnet-1: 193.1.2.0 to 193.1.2.63
Subnet-2: 193.1.2.64 to 193.1.2.127
Subnet-3: 193.1.2.128 to 193.1.2.191
Subnet-4: 193.1.2.192 to 193.1.2.255 
The above IP is class C, so it has 24 bits in network id part and 8 bits in host id part but you choose two bits for subnet id from host id part, so now there are two bits in subnet id part and six bits in host id part, i.e.,
24 bits in network id + 2 bits in subnet id = 26 (1's) and
6 bits in host id = 6 (0's) 
Therefore,
Subnet Mask = 11111111.11111111.11111111.11000000
                 = 255.255.255.192
If any given IP address performs bit wise AND operation with the subnet mask, then you get the network id of the subnet to which the given IP belongs.Example-1:
If IP address = 193.1.2.129 (convert it into binary form)
              = 11000001.00000001.00000010.10000001
Subnet mask   = 11111111.11111111.11111111.11000000
Bit Wise AND  = 11000001.00000001.00000010.10000000
Therefore, Nid = 193.1.2.128
Hence, this IP address belongs to subnet:3 which has Nid = 193.1.2.128Example-2:
If IP address = 193.1.2.67 (convert it into binary form)
              = 11000001.00000001.00000010.01000011
Subnet Mask   = 11111111.11111111.11111111.11000000
Bit Wise AND  = 11000001.00000001.00000010.01000000
Therefore, Nid = 193.1.2.64
Hence, this IP address belongs to subnet:2 which has Nid = 193.1.2.64
Computer Networks
GATE CS
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of Network Topology
RSA Algorithm in Cryptography
TCP Server-Client implementation in C
Socket Programming in Python
GSM in Wireless Communication
ACID Properties in DBMS
Types of Operating Systems
Normal Forms in DBMS
Page Replacement Algorithms in Operating Systems
Introduction of Operating System - Set 1
Global Variable in Ruby

25 Sep, 2019
Global Variable has global scope and accessible from anywhere in the program. Assigning to global variables from any point in the program has global implications. Global variable are always prefixed with a dollar sign ($). If we want to have a single variable, which is available across classes, we need to define a global variable. By default, an uninitialized global variable has a nil value and its use can cause the programs to be cryptic and complex. Global variable can be change anywhere in program.Syntax :
$global_variable = 5
Example :
# Ruby Program to understand Global Variable  # global variable $global_variable = 10  # Defining classclass Class1  def print_global  puts "Global variable in Class1 is #$global_variable" endend  # Defining Another Classclass Class2  def print_global  puts "Global variable in Class2 is #$global_variable" endend  # Creating objectclass1obj = Class1.newclass1obj.print_global   # Creating another objectclass2obj = Class2.newclass2obj.print_global 
Output :
Global variable in Class1 is 10
Global variable in Class2 is 10
In above example, a global variable define whose value is 10. This global variable can be access anywhere in the program.Example :
# Ruby Program to understand global variable $global_variable1 = "GFG"  # Defining Classclass Author  def instance_method    puts "global vars can be used everywhere. See? #{$global_variable1}, #{$another_global_var}"  end  def self.class_method    $another_global_var = "Welcome to GeeksForGeeks"    puts "global vars can be used everywhere. See? #{$global_variable1}"  endend  Author.class_method# "global vars can be used everywhere. See? GFG"# => "global vars can be used everywhere. See? GFG"  Author = Author.newAuthor.instance_method# "global vars can be used everywhere. See? # GFG, Welcome to GeeksForGeeks"# => "global vars can be used everywhere. See?# GFG, Welcome to GeeksForGeeks"
Output :
global vars can be used everywhere. See? GFG
global vars can be used everywhere. See? GFG, Welcome to GeeksForGeeks
In above example, We define two global variable in a class. we create a object of class Author than call method.
Ruby-Basics
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
outtext() function in C

06 Dec, 2019
The header file graphics.h contains outtext() function which displays text at current position.
Syntax :
void outtext(char *string);

Examples :
Input : string = "Hello Geek, Have a good day !"
Output : 

Input : string = "GeeksforGeeks is the best !"
Output :  

Note : Do not use text mode functions like printf while working in graphics mode. Ensure that the text doesn’t go beyond the screen while using outtext.
Below is the implementation for outtext() function:
// C Implementation for outtext()#include <graphics.h>  // driver codeint main(){    // gm is Graphics mode which is    // a computer display mode that    // generates image using pixels.    // DETECT is a macro defined in    // "graphics.h" header file    int gd = DETECT, gm;      // initgraph initializes the    // graphics system by loading a    // graphics driver from disk    initgraph(&gd, &gm, "");      // outtext function    outtext("Hello Geek, Have a good day !");      getch();      // closegraph function closes the    // graphics mode and deallocates    // all memory allocated by    // graphics system .    closegraph();      return 0;}
Output :


Akanksha_Rai
c-graphics
computer-graphics
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Unordered Sets in C++ Standard Template Library
What is the purpose of a function prototype?
Operators in C / C++
Exception Handling in C++
TCP Server-Client implementation in C
Smart Pointers in C++ and How to Use Them
'this' pointer in C++
Ways to copy a vector in C++
Storage Classes in C
Understanding "extern" keyword in C
Python Program for Maximum size square sub-matrix with all 1s

19 Apr, 2020
Given a binary matrix, find out the maximum size square sub-matrix with all 1s.
For example, consider the below binary matrix.
Python3
def print_max_sub_matrix(grid):           row_len = len(grid)    col_len = len(grid[0])          cache = [[0 for k in range(col_len)] for l in range(row_len)]          for i in range(0, row_len):         for j in range(0, col_len):            if (grid[i][j] == 1):                # if row(i) or column(j) is 0, set to 1 or                if i == 0 or j == 0:                    cache[i][j] = min(grid[i][j], 1)                else:                    cache[i][j] = min(cache[i][j-1], cache[i-1][j],cache[i-1][j-1]) + 1            else:                cache[i][j] = 0          max_in_cache = cache[0][0]     max_i = 0    max_j = 0          for i in range(row_len):         for j in range(col_len):             if max_in_cache < cache[i][j]:                 max_in_cache = cache[i][j]                 max_i = i                 max_j = j       for i in range(max_i, max_i - max_in_cache, - 1):         for j in range(max_j, max_j - max_in_cache, - 1):             print (grid[i][j], end = " ")         print("")   # Driver Program grid = [    [1, 1, 1, 1, 1],     [1, 1, 1, 1, 0],     [1, 1, 0, 1, 0],     [0, 1, 1, 1, 0],     [1, 1, 0, 1, 1],     [0, 0, 0, 0, 0]]   print("Maximum sub-matrix:") print_max_sub_matrix(grid)
Maximum size sub-matrix is: 
1 1 
1 1

Please refer complete article on Maximum size square sub-matrix with all 1s for more details!
chasezimmy
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PHP program to find the Standard Deviation of an array

05 Apr, 2018
Given an array of elements. We need to find the Standard Deviation of the elements of the array in PHP.
Examples:
Input : array(2, 3, 5, 6, 7)
Output : 1.5620499351813

Input : array(1, 2, 3, 4, 5)
Output : 1

The following problem can be solved using the PHP inbuilt functions. The inbuilt functions used to solve the above problem are as such:
array_sum(): The function returns the sum of all the elements of an array.count(): This function gives the number of elements currently present in the given array.sqrt(): The function returns the square root of the given number.
array_sum(): The function returns the sum of all the elements of an array.
count(): This function gives the number of elements currently present in the given array.
sqrt(): The function returns the square root of the given number.
To calculate the standard deviation, we have to first calculate the variance. The variance can be calculated as the sum of squares of differences between all numbers and means. Finally to get the standard deviation we will use the formula, √(variance/no_of_elements).
Below is the implementation in PHP to calculate the standard deviation:
<?php          // function to calculate the standard deviation    // of array elements    function Stand_Deviation($arr)    {        $num_of_elements = count($arr);                  $variance = 0.0;                          // calculating mean using array_sum() method        $average = array_sum($arr)/$num_of_elements;                  foreach($arr as $i)        {            // sum of squares of differences between                         // all numbers and means.            $variance += pow(($i - $average), 2);        }                  return (float)sqrt($variance/$num_of_elements);    }          // Input array    $arr = array(2, 3, 5, 6, 7);          print_r(Stand_Deviation($arr));      ?>
Output:
1.8547236990991
PHP-array
PHP
Technical Scripter
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Zero value in Golang

09 Aug, 2019
In Go language, whenever we allocate memory for a variable with the help of declaration or by using new and if the variable is not initialized explicitly, then the value of such types of variables are automatically initialized with their zero value. The initialization of the zero value is done recursively. So, every element of the array of the structs has its fields zero if they are not specified with any value. Following are the zero values for different types of variables:
Example 1:
// Go program to illustrate the concept of zero valuepackage main  import "fmt"  // Main Methodfunc main() {      // Creating variables    // of different types    var q1 int    var q2 float64    var q3 bool    var q4 string    var q5 []int    var q6 *int    var q7 map[int]string      // Displaying the zero value    // of the above variables    fmt.Println("Zero value for integer types: ", q1)    fmt.Println("Zero value for float64 types: ", q2)    fmt.Println("Zero value for boolean types: ", q3)    fmt.Println("Zero value for string types: ", q4)    fmt.Println("Zero value for slice types: ", q5)    fmt.Println("Zero value for pointer types: ", q6)    fmt.Println("Zero value for map types: ", q7)}
Output:
Zero value for integer types:  0
Zero value for float64 types:  0
Zero value for boolean types:  false
Zero value for string types:  
Zero value for slice types:  []
Zero value for pointer types:  <nil>
Zero value for map types:  map[]

Example 2:
// Go program to check the variable// contains zero value or notpackage main  import "fmt"  func main() {      // Creating variables of different types    var q1 int = 2    var q2 float64    var q3 bool    var q4 string      // Slice    var q5 []int      // Pointer    var q6 *int      // Map    var q7 map[int]string      // Checking if the given variables    // contain their zero value or not    if q1 == 0 {              fmt.Println("True")              } else {              fmt.Println("False")    }      if q2 == 0 {              fmt.Println("True")              } else {              fmt.Println("False")    }      if q3 == false {              fmt.Println("True")              } else {        fmt.Println("False")    }      if q4 == "" {              fmt.Println("True")              } else {              fmt.Println("False")    }      if q5 == nil {              fmt.Println("True")              } else {              fmt.Println("False")    }      if q6 == nil {              fmt.Println("True")              } else {              fmt.Println("False")    }      if q7 == nil {              fmt.Println("True")              } else {              fmt.Println("False")    }  }
Output:
False
True
True
True
True
True
True

Golang
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to remove array rows that contain only 0 using NumPy?

20 Aug, 2021
Numpy library provides a function called numpy.all() that returns True when all elements of n-d array passed to the first parameter are True else it returns False. Thus, to determine the entire row containing 0’s can be removed by specifying axis=1. It will traverse each row and will check for the condition given in first parameter. 
Example:
data=[[1,2,3]
      [0,0,0]
      [9,8,7]]
After removing row with all zeroes:
data=[[1,2,3]
      [9,8,7]]
Example 1:
Approach Followed: 
Take a numpy n-d array.
Remove rows that contain only zeroes using numpy.all() function.
Print the n-d array.
Python3
import numpy as np# take datadata = np.array([[1, 2, 3], [0, 0, 0], [4, 5, 6],                 [0, 0, 0], [7, 8, 9], [0, 0, 0]])# print original data having rows with all zeroesprint("Original Dataset")print(data) # remove rows having all zeroesdata = data[~np.all(data == 0, axis=1)] # data after removing rows having all zeroesprint("After removing rows")print(data)
Output:
Example 2:
Approach Followed:
Take 20 random numbers between 0-10, using numpy.random.choice() method.
Align them in rows and columns, using reshape() method.
Explicitly mark some rows as completely 0.
Remove rows having all zeroes.
Print dataset.
Python3
import numpy as np# take random data # random.choice(x,y) will pick y elements from range (0,(x-1))data = np.random.choice(10, 20) # specify the dimensions of data i.e (rows,columns)data = data.reshape(5, 4) # print original data having rows with all zeroesprint("Original Dataset")print(data) # make some rows entirely zerodata[1, :] = 0  # making 2nd row entirely 0data[4, :] = 0  # making last row entirely 0 # after making 2nd and 5th row as 0print("After making some rows as entirely 0")print(data)data = data[~np.all(data == 0, axis=1)] # data after removing rows having all zeroesprint("After removing rows")print(data)
Output:
clintra
Picked
Python numpy-arrayManipulation
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 ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function
Remove unique key from MySQL table?

To remove the unique key from MySQL, use the DROP command. The syntax is as follows −
ALTER TABLE yourTableName DROP INDEX yourKeyName;
To understand the above syntax, let us create a table with the unique key. The query to create a table is as follows −
mysql> create table DropIndexDemo
   −> (
   −> BookId int unique key,
   −> BookName varchar(200)
   −> );
Query OK, 0 rows affected (0.88 sec)
Now you can check what is the key name with the help of show command. This unique key will get deleted. The query is as follows −
mysql> show index from DropIndexDemo;
The following is the output −
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
| Table     | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible |
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
| dropindex | 0          | BookId  | 1             | BookId      | A         | 0           | NULL     | NULL   | YES  | BTREE      |         |               | YES     |
+-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
1 row in set (0.17 sec)
Look at the above sample output, your key name is ‘BookId’. Now here is the query to remove unique key −
mysql> alter table DropIndex drop index BookId ;
Query OK, 0 rows affected (0.33 sec)
Records: 0 Duplicates: 0 Warnings: 0
We have removed the unique key from MySQL table DropIndex. The BookId column had unique key before.
Now display the table structure with the help of desc command. This won’t display Unique Key since we have deleted it −
mysql> desc DropIndex;
The following is the output −
+----------+--------------+------+-----+---------+-------+
| Field    | Type         | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| BookId   | int(11)      | YES  |     | NULL    |       |
| BookName | varchar(200) | YES  |     | NULL    |       |
+----------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
Look at the above sample output there is no unique key in column BookId.
numpy.squeeze() in Python

28 Nov, 2018
numpy.squeeze() function is used when we want to remove single-dimensional entries from the shape of an array.
Syntax : numpy.squeeze(arr, axis=None )
Parameters :arr : [array_like] Input array.axis : [None or int or tuple of ints, optional] Selects a subset of the single-dimensional entries in the shape. If an axis is selected with shape entry greater than one, an error is raised.
Return :squeezed [ndarray] The input array, but with all or a subset of the dimensions of length 1 removed. This is always a itself or a view into arr.
Code #1 :
# Python program explaining# numpy.squeeze function  import numpy as geek  in_arr = geek.array([[[2, 2, 2], [2, 2, 2]]])   print ("Input array : ", in_arr) print("Shape of input array : ", in_arr.shape)    out_arr = geek.squeeze(in_arr)   print ("output squeezed array : ", out_arr)print("Shape of output array : ", out_arr.shape) 
Output :
Input array :  [[[2 2 2]
  [2 2 2]]]
Shape of input array :  (1, 2, 3)
output squeezed array :  [[2 2 2]
 [2 2 2]]
Shape of output array :  (2, 3)

 Code #2 :
# Python program explaining# numpy.squeeze functionimport numpy as geekin_arr = geek.arange(9).reshape(1, 3, 3)   print ("Input array : ", in_arr)  out_arr = geek.squeeze(in_arr, axis = 0)   print ("output array : ", out_arr)  print("The shapes of Input and Output array : ")   print(in_arr.shape, out_arr.shape)
Output :
Input array :  [[[0 1 2]
  [3 4 5]
  [6 7 8]]]
output array :  [[0 1 2]
 [3 4 5]
 [6 7 8]]
The shapes of Input and Output array : 
(1, 3, 3) (3, 3)

Note :
ValueError :
If axis is not None, and an axis being squeezed is not of length 1.
 Code #3 :
# Python program explaining# numpy.squeeze function# when value error occursimport numpy as geek  in_arr = geek.arange(9).reshape(1, 3, 3)   print ("Input array : ", in_arr)  out_arr = geek.squeeze(in_arr, axis = 1)   print ("output array : ", out_arr)  print("The shapes of Input and Output array : ")   print(in_arr.shape, out_arr.shape)
Output :
ValueError                                Traceback (most recent call last)
 in ()
      5 
      6 print ("Input array : ", in_arr)
----> 7 out_arr = geek.squeeze(in_arr, axis=1)
      8 print ("output array : ", out_arr)
      9 print("The shapes of Input and Output array : ")

~\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py in squeeze(a, axis)
   1196     try:
   1197         # First try to use the new axis= parameter
-> 1198         return squeeze(axis=axis)
   1199     except TypeError:
   1200         # For backwards compatibility

ValueError: cannot select an axis to squeeze out which has size not equal to one

Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Introduction To PYTHON
Python OOPs Concepts
Convert integer to string in Python
Python Program to Count trailing zeroes in factorial of a number

14 Jun, 2022
Given an integer n, write a function that returns count of trailing zeroes in n!.  Examples :
Input: n = 5
Output: 1 
Factorial of 5 is 120 which has one trailing 0.

Input: n = 20
Output: 4
Factorial of 20 is 2432902008176640000 which has
4 trailing zeroes.

Input: n = 100
Output: 24
Trailing 0s in n! = Count of 5s in prime factors of n!
                  = floor(n/5) + floor(n/25) + floor(n/125) + ....
Python3
# Python3 program to# count trailing 0s# in n ! # Function to return# trailing 0s in# factorial of ndef findTrailingZeros(n):         # Initialize result    count = 0     # Keep dividing n by    # powers of 5 and    # update Count    i = 5    while (n / i>= 1):        count += int(n / i)        i *= 5     return int(count) # Driver programn = 100print("Count of trailing 0s "+    "in 100 ! is", findTrailingZeros(n)) # This code is contributed by Smitha Dinesh Semwal
Count of trailing 0s in 100 ! is 24
Time Complexity:  O(log5n)
Auxiliary Space: O(1)
Please refer complete article on Count trailing zeroes in factorial of a number for more details!
chandramauliguptach
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install and Configure Apache Subversion(SVN) In Linux?

06 Oct, 2021
Apache Subversion (SVN), is a version control system like Git. it is distributed under an open-source license. SVN was created by CollabNet Inc. but now it is developed as a project of the Apache Software Foundation.
Apache Subversion(SVN) can be easily downloaded and installed with the use of the command-line. Following steps provide a step-by-step procedure to install Apache SVN:
Step 1: First, we need to Install the subversion, apache2 and libapache2-svn/libapache2-mod-svn packages.For this open terminal and type the following command and press Enter:
$ sudo apt install subversion apache2 libapache2-mod-svn
 Step 2: Now create a SVN directory, at the root of file system. Type the following command and press Enter:
$ sudo mkdir /svn
 Step 3: Now, change the owner’s permission of the directory to the webserver user, www-data by default.
$ sudo chown www-data:www-data /svn
 Step 4: Now change to superuser by typing this command and then type password
$ sudo su
now switch to www-data user
$ su -s /bin/bash www-data
Step 5: Create a new SVN repository to store files.
$ svnadmin create /svn/repo
Step 6: Now we’ll have to create credentials for User:
$ htpasswd -cmb /svn/passwd admin password
here “admin” is username and “password” is password Step 7: Now exit from www-data and install Vim editor. Type the following command to install Vim editor:
$ sudo apt-get install vim
 Step 8: Open and edit SVN configuration file in sudo mode with the use of following command:
$ sudo vim /etc/apache2/mods-enabled/dav_svn.conf
Now, paste the following code in that file:
<Location /repo>         DAV svn         SVNPath /svn/repo         AuthUserFile /svn/passwd         Require valid-user         AuthType basic         AuthName "Subversion"</Location>
Now save the file and exit the Vim Editor by using the command :wq Step 9: Now restart Apache Subversion and you are done with the installation process. Type the following command and press Enter:
$ sudo /etc/init.d/apache2 restart
how-to-install
Technical Scripter 2019
How To
Installation Guide
Linux-Unix
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Set Git Username and Password in GitBash?
How to Install and Use NVM on Windows?
How to Install Jupyter Notebook on MacOS?
How to Permanently Disable Swap in Linux?
How to Import JSON Data into SQL Server?
Installation of Node.js on Linux
Installation of Node.js on Windows
How to Install and Use NVM on Windows?
How to Install Jupyter Notebook on MacOS?
How to Add External JAR File to an IntelliJ IDEA Project?