code-rag-bench/online-tutorials huggingface dataset:
How to Map a Rune to Uppercase in Golang?

27 Sep, 2019
Rune is a superset of ASCII or it is an alias of int32. It holds all the characters available in the world’s writing system, including accents and other diacritical marks, control codes like tab and carriage return, and assigns each one a standard number. This standard number is known as a Unicode code point or rune in the Go language.You are allowed to map the given rune into the upper case with the help of ToUpper() function. This function changes the case of the given rune(if the case of the rune is lower or title) into upper case and if the given rune is already present in upper case, then this function does nothing. This function is defined under Unicode package, so for accessing this method you need to import the Unicode package in your program.
Syntax:
func ToUpper(r rune) rune
Example:
// Go program to illustrate how to// Map a rune to Uppercasepackage main  import (    "fmt"    "unicode")  // Main functionfunc main() {      // Creating rune    rune_1 := 'G'    rune_2 := 'e'    rune_3 := 'E'    rune_4 := 'k'      // Mapping the given rune    // into upper case    // Using ToUpper() function    fmt.Printf("Result 1: %c ", unicode.ToUpper(rune_1))    fmt.Printf("\nResult 2: %c ", unicode.ToUpper(rune_2))    fmt.Printf("\nResult 3: %c ", unicode.ToUpper(rune_3))    fmt.Printf("\nResult 4: %c ", unicode.ToUpper(rune_4))    fmt.Printf("\nResult 5: %c ", unicode.ToUpper('s'))  }
Output:
Result 1: G 
Result 2: E 
Result 3: E 
Result 4: K 
Result 5: S 

Golang
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Go
Golang Maps
How to Split a String in Golang?
Interfaces in Golang
Slices in Golang
Different Ways to Find the Type of Variable in Golang
How to convert a string in lower case in Golang?
How to Parse JSON in Golang?
How to Trim a String in Golang?
Inheritance in GoLang
Types of Digital Signature Attacks

22 Jun, 2022
Digital Signature is a mathematical technique that verifies the authenticity of the message or document and also provides non-repudiation where the sender cannot deny signing the document. As the digital signature provides authenticity and non-repudiation in order to secure important data, it is very much susceptible to various attacks. 
Types of Digital Signature Attacks : 
There are three types of attacks on Digital Signatures:
1. Chosen-message Attack
2. Known-message Attack
3. Key-only Attack 
Let us consider an example where c is the attacker and A is the victim whose message and signature are under attack. 
1. Chosen-message Attack : 
The chosen attack method is of two types:
Generic chosen-method – In this method C tricks A to digitally sign the messages that A does not intend to do and without the knowledge about A’s public key.Direct chosen-method – In this method C has the knowledge about A’s public key and obtains A’s signature on the messages and replaces the original message with the message C wants A to sign with having A’s signature on them unchanged.
Generic chosen-method – In this method C tricks A to digitally sign the messages that A does not intend to do and without the knowledge about A’s public key.
Direct chosen-method – In this method C has the knowledge about A’s public key and obtains A’s signature on the messages and replaces the original message with the message C wants A to sign with having A’s signature on them unchanged.
2. Known-message Attack : 
In the known message attack, C has a few previous messages and signatures of A. Now C tries to forge the signature of A on to the documents that A does not intend to sign by using the brute force method by analyzing the previous data to recreate the signature of A. This attack is similar to known-plain text attack in encryption. 
3. Key-only Attack : 
In key-only attack, the public key of A is available to every one and C makes use of this fact and try to recreate the signature of A and digitally sign the documents or messages that A does not intend to do. This would cause a great threat to authentication of the message which is non-repudiated as A cannot deny signing it.
sahithya3chow
cryptography
Computer Networks
cryptography
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Differences between TCP and UDP
Types of Network Topology
RSA Algorithm in Cryptography
GSM in Wireless Communication
Socket Programming in Python
Differences between IPv4 and IPv6
Secure Socket Layer (SSL)
Wireless Application Protocol
Mobile Internet Protocol (or Mobile IP)
Data encryption standard (DES) | Set 1
How to Change Apache HTTP Port in Linux?

19 Feb, 2021
The Apache HTTP server is one of the internet’s most popular web servers today, thanks to its versatility, consistency, and a plethora of features, some of which are actually not available on other web servers, such as Nginx’s competitor. Some of Apache’s most significant features include the ability to load and run various types of modules and special configurations at runtime, without actually stopping the server or, worse, compiling the program whenever most of the new module is installed, and the special role played by .htaccess files that can modify web server configurations specific to webroot directories.
By default, the Apache webserver is instructed to listen and bind on port 80.0 for incoming connections. If you opt for a TLS setup, the server listens on port 443 for stable connections.
You need to add a new statement containing the new port for future bindings in order to instruct the Apache webserver to connect and listen to web traffic on ports other than normal web ports.
The configuration file that needs to be changed on a Debian/Ubuntu-based device is /etc/apache2/ports.conf and update /etc/httpd/conf/httpd.conf on RHEL/CentOS-based distributions.
With a console text editor, open a file unique to your own distribution and add a new port comment, as seen in the excerpt below.
nano /etc/apache2/ports.conf     [On Debian/Ubuntu]
Before port 8081
In this example, the Apache HTTP server will be configured to listen to the connections on port 8081. Make sure that you apply the statement below to this file after the directive instructing the webserver to listen on port 80, as seen in the image below.
Listen 8081
After port 8081
After you have added the above line, to start the binding method, unique to your own vhost requirements, you need to build or change an Apache virtual host in the Debian/Ubuntu-based distribution.
Finally, to implement the changes and connect Apache to a new port, restart the daemon.
# systemctl restart apache2
 Then use the netstat or ss command to search the local network sockets table.
# netstat -tlpn| grep apache
OR
# ss -tlpn| grep apache
You can also open a window and navigate to the IP address or domain name on port 8081 of your computer. The default Apache page in the browser should be shown. If you are unable to access the webpage, however, go back to the server console and make sure that the correct firewall rules are configured to allow port traffic.
http://server.ip:8081
Picked
Technical Scripter 2020
How To
Linux-Unix
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas dataframe.mode()

24 Nov, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas dataframe.mode() function gets the mode(s) of each element along the axis selected. Adds a row for each mode per label, fills in gaps with nan. Note that there could be multiple values returned for the selected axis (when more than one item share the maximum frequency), which is the reason why a dataframe is returned.
Syntax: DataFrame.mode(axis=0, numeric_only=False)Parameters :axis : get mode of each column1, get mode of each rownumeric_only : if True, only apply to numeric columns
Returns : modes : DataFrame (sorted)
Example #1: Use mode() function to find the mode over the index axis.
# importing pandas as pdimport pandas as pd  # Creating the dataframe df=pd.DataFrame({"A":[14,4,5,4,1],                 "B":[5,2,54,3,2],                 "C":[20,20,7,3,8],                 "D":[14,3,6,2,6]})  # Print the dataframedf
Lets use the dataframe.mode() function to find the mode of dataframe
# find mode of dataframe df.mode()
Output :
 Example #2: Use mode() function to find the mode over the column axis
# importing pandas as pdimport pandas as pd  # Creating the dataframe df=pd.DataFrame({"A":[14,4,5,4,1],                 "B":[5,2,54,3,2],                 "C":[20,20,7,3,8],                 "D":[14,3,6,2,6]})  # Print the dataframedf
Lets use the dataframe.mode() function to find the mode
# axis = 1 indicates over the column axisdf.mode(axis = 1)
Output :
In the 0th and 3rd row, 14 and 3 is the mode, as they have the maximum occurrence (i.e. 2). In rest of the column all element are mode because they have the same frequency of occurrence.
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
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
Enumerate() in Python
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
Python OOPs Concepts
Introduction To PYTHON
How to read Excel file and select specific rows and columns in R?

20 May, 2021
In this article, we will discuss how to read an Excel file and select specific rows and columns from it using R Programming Language.
File Used:
To read an Excel file into R we have to pass its path as an argument to read_excel() function readxl library.
Syntax:
read_excel(path)
To select a specific column we can use indexing.
Syntax:
df [ row_index , column_index ]
Here df represents data frame name or Excel file name or anything
For this, we have to pass the index of the row to be extracted as input to the indexing. As a result, the row at the provided index will be fetched and displayed.
Example 1 :
R
library(readxl)  setwd('C:/Users/KRISHNA KARTHIKEYA/Documents')df=read_excel('OSWT1.xlsx')  a=df[5,]print(a)
Output :
Example 2 :
R
library(readxl)  setwd('C:/Users/KRISHNA KARTHIKEYA/Documents')df=read_excel('OSWT1.xlsx')  a=df[6,]print(a)
Output :
Example 3 :
R
library(readxl)  setwd('C:/Users/KRISHNA KARTHIKEYA/Documents')df=read_excel('OSWT1.xlsx')  a=df[7,]print(a)
Output :
To get multiple rows similarly not much modification is required. The index of the rows to be extracted should be passed as a vector to the row_index part of indexing syntax.
Example 4 : 
R
library("readxl")  df=read_excel("C:/users/KRISHNA KARTHIKEYA/Documents/OSWT1.xlsx")print(df[c(2,3),])
Output :
This is similar to the approach followed above except that to extract the column index of the column needs to be given as an argument.
Example 1 :
R
library(readxl)  setwd('C:/Users/KRISHNA KARTHIKEYA/Documents')df=read_excel('OSWT1.xlsx')  a=df[,2]print(a)
Output :
Example 2:
R
library(readxl)  setwd('C:/Users/KRISHNA KARTHIKEYA/Documents')df=read_excel('OSWT1.xlsx')  a=df[,3]print(a)
Output : 
Example 3 :
R
library(readxl)  setwd('C:/Users/KRISHNA KARTHIKEYA/Documents')df=read_excel('OSWT1.xlsx')  a=df[,4]print(a)
Output :
To get multiple columns at once the index of the columns to be extracted should be given as a vector in column_index part of the indexing syntax. All the columns with the index provided will be fetched and displayed.
Example 4 :
R
library("readxl")  df=read_excel("C:/users/KRISHNA KARTHIKEYA/Documents/OSWT1.xlsx")  print(df[,c(2,3)])
Output : 
Picked
R-Excel
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to filter R DataFrame by values in a column?
R - if statement
Logistic Regression in R Programming
Replace Specific Characters in String in R
How to import an Excel File into R ?
Joining of Dataframes in R Programming
What is NgClass in Angular 10 ?

30 Apr, 2021
In this article, we are going to see what is NgClass in Angular 10 and how to use it.
NgClass is used to Add or remove CSS classes on an HTML element
Syntax:
<element [ngClass] = "typescript_property">
Approach: 
Create the angular app to be used
In app.component.html make an element and sets its class using ngclass directive
serve the angular app using ng serve to see the output
Example 1:
app.component.ts
import { Component, OnInit } from '@angular/core';  @Component({    selector: 'app-root',    templateUrl: './app.component.html'})export class AppComponent {    }
app.component.html
<div [ngClass] ="'gfgclass'">  GeeksforGeeks</div>
Output:
Angular10
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
VBA - Year Function

The Year function returns an integer that represents a year of the specified date.
Year(date) 

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox(Year("2013-06-30"))
End sub
When you execute the above function, it produces the following output.
2013


    101 Lectures 
     6 hours 

 Pavan Lalwani

    41 Lectures 
     3 hours 

 Arnold Higuit

    80 Lectures 
     5.5 hours 

 Prashant Panchal

    25 Lectures 
     2 hours 

 Prashant Panchal

    26 Lectures 
     2 hours 

 Arnold Higuit

    92 Lectures 
     10.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
PostgreSQL - Removing Temporary Table - GeeksforGeeks

28 Aug, 2020
In PostgreSQL, one can drop a temporary table by the use of the DROP TABLE statement.
Syntax: DROP TABLE temp_table_name;
Unlike the CREATE TABLE statement, the DROP TABLE statement does not have the TEMP or TEMPORARY keyword created specifically for temporary tables. To demonstrate the process of dropping a temporary table let’s first create one by following the below instructions.First, we create a sample database(say, test) to add a temporary table using the below statement:
CREATE DATABASE test;
After creating the database we switch into it using the following command:
\c test;
Now we add a temporary table (say, mytemp) to the test database as below:
CREATE TABLE mytemp(c INT);
Verify if the table has been created using the below statement:
SELECT * FROM mytemp;
It should show you the below table:Now that our temporary table is created we remove it in the below example.
Example:We use the DROP TABLE statement inside the database test as follows to drop the temporary table:
DROP TABLE mytemp;
Now we verify if the table has been removed successfully using the below statement:
SELECT * FROM mytemp;
Output:
The above-shown error raised by PostgreSQL shows that the mytemp table doesn’t exist anymore.
postgreSQL-managing-table
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - GROUP BY clause
PostgreSQL - DROP INDEX
PostgreSQL - Copy Table
PostgreSQL - Interval Data Type
PostgreSQL - LEFT JOIN
PostgreSQL - TEXT Data Type
PostgreSQL - Record type variable
PostgreSQL - TIME Data Type
PostgreSQL - CREATE PROCEDURE
PostgreSQL - ROW_NUMBER Function
GATE | GATE-CS-2007 | Question 85

20 Nov, 2018
In a look-ahead carry generator, the carry generate function Gi and the carry propagate function Pi for inputs Ai and Bi are given by:
Pi = Ai ⨁ Bi and Gi = AiBi 
The expressions for the sum bit Si and the carry bit Ci+1 of the look-ahead carry adder are given by:
Si = Pi ⨁ Ci and Ci+1 = Gi + PiCi , where C0 is the input carry. 
Consider a two-level logic implementation of the look-ahead carry generator. Assume that all Pi and Gi are available for the carry generator circuit and that the AND and OR gates can have any number of inputs. The number of AND gates and OR gates needed to implement the look-ahead carry generator for a 4-bit adder with S3, S2, S1, S0 and C4 as its outputs are respectively:(A) 6, 3(B) 10, 4(C) 6, 4(D) 10, 5Answer: (B)Explanation: let the carry input be c0
Now,
c1 = g0 + p0c0 = 1 AND, 1 OR
c2 = g1 + p1g0 + p1p0c0 
   = 2 AND, 1 OR

c3 = g2 + p2g1 + p2p1go + p2p1p0c0 
   = 3 AND, 1 OR
c4 = g3 + p3g2 + p3p2g1 + p3p2p1g0 + p3p2p1p0c0 
   = 4 AND, 1 OR
So, total AND gates = 1+2+3+4 = 10 , OR gates = 1+1+1+1 = 4
So as a general formula we can observe that we need a total of ” n(n+1)/2 ” AND gates and “n” OR gates for a n-bit carry look ahead circuit used for addition of two binary numbers.Quiz of this Question
GATE-CS-2007
GATE-GATE-CS-2007
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas dataframe.eval()

20 Nov, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas dataframe.eval() function is used to evaluate an expression in the context of the calling dataframe instance. The expression is evaluated over the columns of the dataframe.
Syntax: DataFrame.eval(expr, inplace=False, **kwargs)
Parameters:expr : The expression string to evaluate.inplace : If the expression contains an assignment, whether to perform the operation inplace and mutate the existing DataFrame. Otherwise, a newDataFrame is returned.kwargs : See the documentation for eval() for complete details on the keyword arguments accepted by query().
Returns: ret : ndarray, scalar, or pandas object
Example #1: Use eval() function to evaluate the sum of all column element in the dataframe and insert the resulting column in the dataframe.
# importing pandas as pdimport pandas as pd  # Creating the dataframe df=pd.DataFrame({"A":[1,5,7,8],                 "B":[5,8,4,3],                 "C":[10,4,9,3]})  # Print the first dataframedf
Let’s evaluate the sum over all the columns and add the resultant column to the dataframe
# To evaluate the sum over all the columnsdf.eval('D = A + B+C', inplace = True)  # Print the modified dataframedf
Output :
 
Example #2: Use eval() function to evaluate the sum of any two column element in the dataframe and insert the resulting column in the dataframe. The dataframe has NaN value.
Note : Any expression can not be evaluated over NaN values. So the corresponding cells will be NaN too.
# importing pandas as pdimport pandas as pd  # Creating the dataframedf=pd.DataFrame({"A":[1,2,3],                 "B":[4,5,None],                 "C":[7,8,9]})  # Print the dataframedf
Let’s evaluate the sum of column “B” and “C”.
# To evaluate the sum of two columns in the dataframedf.eval('D = B + C', inplace = True)  # Print the modified dataframedf
Output :
Notice, the resulting column ‘D’ has NaN value in the last row as the corresponding cell used in evaluation was a NaN cell.
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to hash string with md5 function in Node.js ?

13 Jun, 2022
Hashing means taking any string as a key and generating some other string for it as a value. It’s like key-value pair in maps or dictionaries. md5 hash is an encryption algorithm that takes the various bits of a file and outputs a unique text string. md5 is a one-way encryption algorithm, i.e. there is no direct way of decryption. Using md5 hashing, you can only compare if two strings are equal or not by comparing the hash strings generated for them. For this purpose, we are going to use the md5 npm package and prompt module  md5 is a javascript module that is used to encrypt the data and the prompt module is used for taking the input from the terminal.
Steps to use md5 function to hash the string:
Step 1: create an “app.js” file and initialize the project using npm.
npm init
Step 2: Install md5 and prompt npm packages using npm install.
npm install md5
npm install prompt
Project structure:
Step 3: Now let’s code the “app.js” file. We take the required string as input from the user then use the md5() function to generate its hash string.
app.js
Javascript
// Prompt is used to take input from consoleconst prompt = require("prompt"); // md5 is used to hash the given stringconst md5 = require("md5"); // Utility function to perform the operationfunction hash() {   // Start the prompt  prompt.start();   // Get string input as str from the console  prompt.get(["str"], function (err, res) {     // To handle any error if occurred    if (err) {      console.log(err);    } else {       // To generate the hashed string      const hash = md5(res.str);       // To print hashed string in the console      console.log("hashed string is: ", hash);    }  });} // Calling the functionhash();
Step 4: Run app.js file using below command:
node app.js
Output:
nikhatkhan11
JavaScript-Questions
NodeJS-Questions
Picked
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python program to convert camel case string to snake case

01 Feb, 2021
Given a string in camel case, write a Python program to convert the given string from camel case to snake case.Examples: 
Input : GeeksForGeeks
Output : geeks_for_geeks

Input : ThisIsInCamelCase
Output : this_is_in_camel_case
Let’s see the different ways we can do this task. Method #1 : Naive ApproachThis is a naive implementation to convert camel case to snake case. First, we initialize a variable ‘res’ with an empty list and append first character (in lower case) to it. Now, Each time we encounter a Capital alphabet, we append ‘_’ and the alphabet (in lower case) to ‘res’, otherwise, just append the alphabet only.  
Python3
# Python3 program to convert string# from camel case to snake case def change_case(str):    res = [str[0].lower()]    for c in str[1:]:        if c in ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'):            res.append('_')            res.append(c.lower())        else:            res.append(c)         return ''.join(res)     # Driver codestr = "GeeksForGeeks"print(change_case(str))
geeks_for_geeks
 
  Method #2 : List comprehension
Python3
# Python3 program to convert string# from camel case to snake case def change_case(str):         return ''.join(['_'+i.lower() if i.isupper()               else i for i in str]).lstrip('_')     # Driver codestr = "GeeksForGeeks"print(change_case(str))
geeks_for_geeks
 
  Method #3 : Python reduce()Python reduce() method applies a function to all the string alphabets, that wherever it find uppercase alphabet, it add ‘_’ in front of it and replace the uppercase alphabet with lowercase alphabet. 
Python3
# Python3 program to convert string# from camel case to snake casefrom functools import reduce def change_case(str):         return reduce(lambda x, y: x + ('_' if y.isupper() else '') + y, str).lower()     # Driver codestr = "GeeksForGeeks"print(change_case(str))
geeks_for_geeks
 
  Method #4 : Python Regex 
Python3
# Python3 program to convert string# from camel case to snake caseimport re def change_case(str):    s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', str)    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()     # Driver codestr = "GeeksForGeeks"print(change_case(str))
geeks_for_geeks
 
shubham_singh
dulanthaf
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
MongoDB – Comparison Query Operators

10 May, 2020
MongoDB uses various comparison query operators to compare the values of the documents. The following table contains the comparison query operators:
In the following examples, we are working with:
Database: GeeksforGeeksCollection: contributorDocument: three documents that contain the details of the contributors in the form of field-value pairs.
In this example, we are retrieving only those employee’s documents whose name is not Amit or Suman.
db.contributor.find({name: {$nin: ["Amit", "Suman"]}}).pretty()
In this example, we are retrieving only those employee’s documents whose name is either Amit or Suman.
db.contributor.find({name: {$in: ["Amit", "Suman"]}}).pretty()
In this example, we are selecting those documents where the value of the salary field is less than 2000.
db.contributor.find({salary: {$lt: 2000}}).pretty()
In this example, we are selecting those documents where the value of the branch field is equal to CSE.
db.contributor.find({branch: {$eq: "CSE"}}).pretty()
In this example, we are selecting those documents where the value of the branch field is not equal to CSE.
db.contributor.find({branch: {$ne: "CSE"}}).pretty()
In this example, we are selecting those documents where the value of the salary field is greater than 1000.
db.contributor.find({salary: {$gt: 1000}}).pretty()
In this example, we are selecting those documents where the value of the joiningYear field is greater than equals to 2017.
db.contributor.find({joiningYear: {$gte: 2017}})
In this example, we are selecting those documents where the value of the salary field is less than equals to 1000.
db.contributor.find({salary: {$lte: 1000}}).pretty()
MongoDB
MongoDB-operators
MongoDB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What's the difference between assignment operator and copy constructor in C++?

The Copy constructor and the assignment operators are used to initialize one object to another object. The main difference between them is that the copy constructor creates a separate memory block for the new object. But the assignment operator does not make new memory space. It uses reference variable to point to the previous memory block.
classname (const classname &obj) {
   // body of constructor
}
classname Ob1, Ob2;
Ob2 = Ob1;
Let us see the detailed differences between Copy constructor and Assignment Operator.
Division without using ‘/’ operator in C++ Program

In this tutorial, we are going to learn how to divide a number without using the division (/) operator.
We have given two numbers, the program should return the quotient of the division operation.
We are going to use the subtraction (-) operator for the division.
Let's see the steps to solve the problem.
Initialize the dividend and divisor.
Initialize the dividend and divisor.
If the number is zero, then return 0.
If the number is zero, then return 0.
Store whether the result will be negative or not by checking the signs of dividend and divisor.
Store whether the result will be negative or not by checking the signs of dividend and divisor.
Initialize a count to 0.
Initialize a count to 0.
Write a loop that runs until the number one is greater than or equals to the number two.Subtract the number two from the number one and assign the result to the number oneIncrement the counter.
Write a loop that runs until the number one is greater than or equals to the number two.
Subtract the number two from the number one and assign the result to the number one
Subtract the number two from the number one and assign the result to the number one
Increment the counter.
Increment the counter.
Print the counter.
Print the counter.
Let's see the code.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int division(int num_one, int num_two) {
   if (num_one == 0) {
      return 0;
   }
   if (num_two == 0) {
      return INT_MAX;
   }
   bool negative_result = false;
   if (num_one < 0) {
      num_one = -num_one ;
      if (num_two < 0) {
         num_two = -num_two ;
      }
      else {
         negative_result = true;
      }
   }
   else if (num_two < 0) {
      num_two = -num_two;
      negative_result = true;
   }
   int quotient = 0;
   while (num_one >= num_two) {
      num_one = num_one - num_two;
      quotient++;
   }
   if (negative_result) {
      quotient = -quotient;
   }
   return quotient;
}
int main() {
   int num_one = 24, num_two = 5;
   cout << division(num_one, num_two) << endl;
   return 0;
}
If you run the above code, then you will get the following result.
4
If you have any queries in the tutorial, mention them in the comment section.
How do I display only the visible text with jQuery?

To display only the visible text, use the concept of − visible selector in jQuery. It selects the
element currently visible. Following is the code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=
1.0">
<title>Document</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<div id="myDiv">
<span class="test" style="display:none"><b>Test Class</b></span>
<span class="demo"> <b>Demo class</b></span>
</div>
<script>
   $('#myDiv').children(":visible").text()
</script>
</body>
</html>
To run the above program, save the file name “anyName.html(index.html)” and right click on the
file. Select the option “Open with Live Server” in VS Code editor.
This will produce the following output displaying the visible text −
Cryptography with Python - XOR Process

In this chapter, let us understand the XOR process along with its coding in Python.
XOR algorithm of encryption and decryption converts the plain text in the format ASCII bytes and uses XOR procedure to convert it to a specified byte. It offers the following advantages to its users −
Fast computation
No difference marked in left and right side
Easy to understand and analyze
You can use the following piece of code to perform XOR process −
def xor_crypt_string(data, key = 'awesomepassword', encode = False, decode = False):
   from itertools import izip, cycle
   import base64
   
   if decode:
      data = base64.decodestring(data)
   xored = ''.join(chr(ord(x) ^ ord(y)) for (x,y) in izip(data, cycle(key)))
   
   if encode:
      return base64.encodestring(xored).strip()
   return xored
secret_data = "XOR procedure"

print("The cipher text is")
print xor_crypt_string(secret_data, encode = True)
print("The plain text fetched")
print xor_crypt_string(xor_crypt_string(secret_data, encode = True), decode = True)
The code for XOR process gives you the following output −
The function xor_crypt_string() includes a parameter to specify mode of encode and decode and also the string value.
The function xor_crypt_string() includes a parameter to specify mode of encode and decode and also the string value.
The basic functions are taken with base64 modules which follows the XOR procedure/ operation to encrypt or decrypt the plain text/ cipher text.
The basic functions are taken with base64 modules which follows the XOR procedure/ operation to encrypt or decrypt the plain text/ cipher text.
Note − XOR encryption is used to encrypt data and is hard to crack by brute-force method, that is by generating random encrypting keys to match with the correct cipher text.

    10 Lectures 
     2 hours 

 Total Seminars

    10 Lectures 
     2 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
\bigvee - Tex Command

\bigvee - Used to draw big V symbol.
{ \bigvee }
\bigvee command draws V symbol.

\bigvee 

⋁



\bigvee 

⋁


\bigvee 

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Array sum in C++ STL

The array is a linear data structure that stores elements of the same data type in continuous memory locations.
Array sum is the sum of all elements of the array.
In c++ programming language there are multiple methods by with you can find the array sum.
The basic method to find the sum of all elements of the array is to loop over the elements of the array and add the element’s value to the sum variable.
Step 1 : For i from 0 to n-1, follow step 2 ;
Step 2 : sum = sum + arr[i]
Step 3 : print sum.
 Live Demo
#include <iostream>
using namespace std;
int main (){
   int arr[] = { 2, 5, 7, 8, 2, 6, 9 };
   int n = 7, sum = 0;
   for(int i = 0; i<n ; i++){
      sum+=arr[i];
   }
   cout<<"The array sum is "<<sum;
   return 0;
}
The array sum is 39
The accumulate method in c++ used to find the array sum. This function can be accessed from the numeric library in c++.
accumulate(array_name , array_name+length , sum);
 Live Demo
#include <iostream>
#include <numeric>
using namespace std;
int main (){
   int arr[] = { 2, 5, 7, 8, 2, 6, 9 };
   int n = 7, sum = 0;
   sum = accumulate(arr, arr+n, sum);
   cout<<"The array sum is "<<sum;
   return 0;
}
The array sum is 39
You can use the accumulate function on vectors too. It will return the sum of array which is it vector form.
 Live Demo
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int arraySum(vector<int> &v){
   int initial_sum = 0;
   return accumulate(v.begin(), v.end(), initial_sum);
}
int main(){
   vector<int> v{12, 56, 76, 2, 90 , 3} ;
   int sum = 0;
   sum=accumulate(v.begin(), v.end(), sum);
   cout<<"The sum of array is "<<sum;
   return 0;
}
The sum of array is 239
GATE | GATE CS 2010 | Question 43 - GeeksforGeeks

28 Jun, 2021
Which of the following functional dependencies hold for relations R(A, B, C) and S(B, D, E):
B -> A
A -> C
The relation R contains 200 tuples and the rel ation S contains 100 tuples. What is the maximum number of tuples possible in the natural join of R and S (R natural join S)(A) 100(B) 200(C) 300(D) 2000Answer: (A)Explanation:
From the given set of functional dependencies, it can be observed that B is a candidate key of R. So all 200 values of B must be unique in R. There is no functional dependency given for S. To get the maximum number of tuples in output, there can be two possibilities for S.1) All 100 values of B in S are same and there is an entry in R that matches with this value. In this case, we get 100 tuples in output.2) All 100 values of B in S are different and these values are present in R also. In this case also, we get 100 tuples.
Quiz of this Question
GATE-CS-2010
GATE-GATE CS 2010
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-1) | Question 30
GATE | GATE-CS-2001 | Question 23
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2015 (Set 1) | Question 65
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2015 (Set 1) | Question 42
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2014-(Set-1) | Question 65
C++ Program to count Vowels in a string using Pointer
Java HashSet

A HashSet is a collection of items where every item is unique, and it is found in the java.util 
package:
Create a HashSet object called cars that will store strings:
import java.util.HashSet; // Import the HashSet class

HashSet<String> cars = new HashSet<String>();

The HashSet class has many useful methods. For example, to 
add items to it, use the add() method:
// Import the HashSet class
import java.util.HashSet;

public class Main {
  public static void main(String[] args) {
    HashSet<String> cars = new HashSet<String>();
    cars.add("Volvo");
    cars.add("BMW");
    cars.add("Ford");
    cars.add("BMW");
    cars.add("Mazda");
    System.out.println(cars);
  }
}


Try it Yourself »

Note: In the example above, even though BMW is added twice it only appears once in the set
because every item in a set has to be unique.
To check whether an item exists in a HashSet, use the contains() method:
cars.contains("Mazda");


Try it Yourself »

To remove an item, use the remove() method:
cars.remove("Volvo");


Try it Yourself »

To remove all items, use the clear() method:
cars.clear();


Try it Yourself »

To find out how many items there are, use the size method:
cars.size();


Try it Yourself »

Loop through the items of an HashSet with a for-each loop:
for (String i : cars) {
  System.out.println(i);
}

Try it Yourself »

Items in an HashSet are actually objects. In the examples above, we created 
items 
(objects) of type "String". Remember that a String in Java is an object (not a primitive type). To use other types, such as int, you must specify an equivalent wrapper class: Integer. For other primitive types, 
use: Boolean for boolean, Character for char, Double for double, 
etc:
Use a HashSet that stores Integer objects:
import java.util.HashSet;

public class Main {
  public static void main(String[] args) {

    // Create a HashSet object called numbers
    HashSet<Integer> numbers = new HashSet<Integer>();

    // Add values to the set
    numbers.add(4);
    numbers.add(7);
    numbers.add(8);

    // Show which numbers between 1 and 10 are in the set
    for(int i = 1; i <= 10; i++) {
      if(numbers.contains(i)) {
        System.out.println(i + " was found in the set.");
      } else {
        System.out.println(i + " was not found in the set.");
      }
    }
  }
}


Try it Yourself »

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to count number of rows in a table with jQuery?

Live Demo
<html>
<head>
<title>table</title>
   <style type="text/css">
   table,th,td {
      border:2px solid black;
      margin-left:400px;
   }
   h2 {
      margin-left:400px;
   }
   button {
      margin-left:400px;
   }
   </style>
   <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
   $(document).ready(function () {
      $("button").click(function () {
         var rowcount = $('table tr').length;
         alert("No. Of Rows ::" +rowcount);
      });
   });
</script>
</head>
<body>
<div>
<h2>HTML TABLE</h2>
<table>
<tr>
<th>
NAME
</th>
<th>
AGE
</th>
</tr>
<tr>
<td>DD</td>
<td>35</td>
</tr>
<tr>
<td>SB</td>
<td>35</td>
</tr>
<tr>
<td>AD</td>
<td>5</td>
</tr>
<tr>
<td>AA</td>
<td>5</td>
</tr>
</table>
<button type="button" id="btn">Click Here</button>
</div>
</body>
</html>
Beans and Dependency Injection

In Spring Boot, we can use Spring Framework to define our beans and their dependency injection. The @ComponentScan annotation is used to find beans and the corresponding injected with @Autowired annotation.
If you followed the Spring Boot typical layout, no need to specify any arguments for @ComponentScan annotation. All component class files are automatically registered with Spring Beans.
The following example provides an idea about Auto wiring the Rest Template object and creating a Bean for the same −
@Bean
public RestTemplate getRestTemplate() {
   return new RestTemplate();
}
The following code shows the code for auto wired Rest Template object and Bean creation object in main Spring Boot Application class file −
package com.tutorialspoint.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
public class DemoApplication {
@Autowired
   RestTemplate restTemplate;
   
   public static void main(String[] args) {
      SpringApplication.run(DemoApplication.class, args);
   }
   @Bean
   public RestTemplate getRestTemplate() {
      return new RestTemplate();   
   }
}

    102 Lectures 
     8 hours 

 Karthikeya T

    39 Lectures 
     5 hours 

 Chaand Sheikh

    73 Lectures 
     5.5 hours 

 Senol Atac

    62 Lectures 
     4.5 hours 

 Senol Atac

    67 Lectures 
     4.5 hours 

 Senol Atac

    69 Lectures 
     5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
How to create a dotted vertical line using ggplot2 in R?

To create a vertical line using ggplot2, we can use geom_vline function of ggplot2 package and if we want to have a dotted vertical line then linetype will be set to 3 inside the same function. To draw the line, we will have to provide xintercept because the line will start on X-axis.
Check out the below example to understand how it works.
Following snippet creates a sample data frame −
x<-rpois(20,5)
y<-rpois(20,2)
df<-data.frame(x,y)
df
The following dataframe is created −
   x  y
1  5  2
2  3  4
3  6  2
4  3  4
5  4  2
6  5  2
7  7  1
8  4  2
9  3  2
10 4  4
11 6  2
12 2  2
13 7  1
14 7  1
15 6  1
16 7  1
17 7  2
18 7  1
19 6  3
20 4  3
To load ggplot2 package and create point chart between x and y with vertical line at X=5, add the following code to the above snippet −
library(ggplot2)
ggplot(df,aes(x,y))+geom_point()+geom_vline(xintercept=5)
If you execute all the above given snippets as a single program, it generates the following output −
Now, to create point chart between x and y with dotted vertical line at X=5, add the following code to the above snippet −
ggplot(df,aes(x,y))+geom_point()+geom_vline(xintercept=5,linetype=3)

If you execute all the above given snippets as a single program, it generates the following output −
How to create a canvas image using Fabric.js ? - GeeksforGeeks

07 Jan, 2022
In this article, we are going to see how to create a canvas-like image in JavaScript. Thee canvas like image means the image is movable and can be resized according to requirement.
Approach: To make this possible we are going to use a JavaScript library called FabricJS. After importing the library, we will create a canvas block in the body tag which will contain our image. Further, we will create an img element which contains the image to be added inside the canvas and set the style attribute to display:none; because we don’t want the image to be visible outside the canvas. After this, we will initialize instances of Canvas and Image provided by FabricJS and render the Image on the Canvas as given in the example below.
Syntax:
 fabric.Image( image_element ); 
Example: This example uses FabricJS to create simple editable canvas image.
html
<!DOCTYPE html><html>  <head>    <title>        How to create a canvas-type        image with JavaScript?    </title>      <!-- Loading the FabricJS library -->    <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.6.2/fabric.min.js">    </script></head>  <body>    <canvas id="canvas" width="600" height="200"        style="border:1px solid #000000">    </canvas>      <!-- Add the image to be used in the canvas        and hide it here because only need it        inside the canvas -->    <img style="display: none;" src="https://media.geeksforgeeks.org/wp-content/uploads/20200327230544/g4gicon.png"                id="my-image" alt="">                      <script>        // Initiate a Canvas instance        var canvas = new fabric.Canvas("canvas");          // Get the image element        var image = document.getElementById('my-image');          // Initiate a Fabric instance        var fabricImage = new fabric.Image(image);          // Add the image to canvas        canvas.add(fabricImage);    </script></body>  </html>
sumitgumber28
HTML-Misc
JavaScript-Misc
HTML
JavaScript
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
REST API (Introduction)
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
File uploading in React.js
CSS position: absolute;

The position: absolute; property allows you to position element relative to the nearest positioned ancestor.
You can try to run the following code to implement CSS position: absolute;
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         div.one {
            position: relative;
            width: 500px;
           height: 150px;
           border: 2px solid blue;
         }
         div.two {
            position: absolute;
            top: 70px;
            right: 0;
            width: 300px;
            height: 50px;
            border: 2px solid yellow;
         }
      </style>
   </head>
   <body>
      <h2>position: absolute;</h2>
      The position: absolute; property allows you to position element relative to the nearest positioned ancestor.
      <div class = "one">div has position: relative;
         <div class = "two">div has position: absolute;</div>
      </div>
   </body>
</html>
MATLAB - Scalar Operations of Matrices

When you add, subtract, multiply or divide a matrix by a number, this is called the scalar operation.
Scalar operations produce a new matrix with same number of rows and columns with each element of the original matrix added to, subtracted from, multiplied by or divided by the number.
Create a script file with the following code −
a = [ 10 12 23 ; 14 8 6; 27 8 9];
b = 2;
c = a + b
d = a - b
e = a * b
f = a / b
When you run the file, it displays the following result −
c =
      12    14    25
      16    10     8
      29    10    11
d =
      8    10    21
      12     6     4
      25     6     7
e =
      20    24    46
      28    16    12
      54    16    18
f =
      5.0000    6.0000   11.5000
      7.0000    4.0000    3.0000
      13.5000    4.0000    4.5000


    30 Lectures 
     4 hours 

 Nouman Azam

    127 Lectures 
     12 hours 

 Nouman Azam

    17 Lectures 
     3 hours 

 Sanjeev

    37 Lectures 
     5 hours 

 TELCOMA Global

    22 Lectures 
     4 hours 

 TELCOMA Global

    18 Lectures 
     3 hours 

 Phinite Academy
 Print
 Add Notes
 Bookmark this page
QTP - Ordinal Identifiers

Sometimes, there are series of objects with same class name and properties. Let us say, in a window, there are series of checkboxes with the same set of properties. If we want to act on those objects, we need to uniquely identify them so that QTP will be able to act on it.
An Ordinal Identifier assigns a numerical value to the test objects, which indicates its location or order relative to its group. The Ordered value enables QTP to recognize it uniquely when the inbuilt properties are NOT sufficient to do so.
There are three Ordinal Identifiers in QTP that can be used in different context −
Index
Location
Creation Time
An object appearing first in the page/Window will have a smaller Index value when compared to another object that comes later in the same page/Window.
The value of index for the group of text boxes will be as follows −
The Location property works vertically from top to bottom and from left to right. Hence, for the same case, the value of location for the group of text boxes will be as follows −
The Creation Time property holds good only for web based application. When we open two browser sessions of the same website, QTP will not be able to recognize the window, as both the windows will have the same set of properties. Hence, we can use creation time with which QTP will be able to act on the window.
'Will have CreationTime value = 0 
SystemUtil.Run "iexplore.exe", "http://www.google.com"       

'Will have CreationTime value = 1  
SystemUtil.Run "iexplore.exe", "http://www.yahoo.com"        

'Will have CreationTime value = 2    
SystemUtil.Run "iexplore.exe", "http://www.microsoft.com"   

'Will have CreationTime value = 3   
SystemUtil.Run "iexplore.exe", "http://www.facebook.com" 
Hence, to work on a specific browser, we need to explicitly mention the Creation time in OR or we can use the description of objects, which we will see in detail in descriptive programming section.
'Sync's www.google.com 
Browser("creationtime:=" ).Sync                  

'Gets the RO text property of www.yahoo.com  
Browser("creationtime:=1").GetROProperty("text")    

'Highlights microsoft.com 
Browser("creationtime:=2").Highlight                

    108 Lectures 
     8 hours 

 Pavan Lalwani
 Print
 Add Notes
 Bookmark this page