code-rag-bench/online-tutorials huggingface dataset:
Function Overloading and float in C++ - GeeksforGeeks

03 Sep, 2018
Although polymorphism is a widely useful phenomena in C++ yet it can be quite complicated at times. For instance consider the following code snippet:
#include<iostream>using namespace std;void test(float s,float t){    cout << "Function with float called ";}void test(int s, int t){    cout << "Function with int called ";}int main(){    test(3.5, 5.6);    return 0;}
It may appear that the call to the function test in main() will result in output “Function with float called” but the code gives following error:
In function 'int main()':
13:13: error: call of overloaded 'test(double, double)' is ambiguous
 test(3.5,5.6);
It’s a well known fact in Function Overloading, that the compiler decides which function needs to be invoked among the overloaded functions. If the compiler can not choose a function amongst two or more overloaded functions, the situation is -” Ambiguity in Function Overloading”.
The reason behind the ambiguity in above code is that the floating literals 3.5 and 5.6 are actually treated as double by the compiler. As per C++ standard, floating point literals (compile time constants) are treated as double unless explicitly specified by a suffix [See 2.14.4 of C+++ standard here). Since compiler could not find a function with double argument and got confused if the value should be converted from double to int or float.
Rectifying the error: We can simply tell the compiler that the literal is a float and NOT double by providing suffix f.
Look at the following code :
#include<iostream>using namespace std;void test(float s,float t){    cout << "Function with float called ";}void test(int s,int t){    cout << "Function with int called ";}int main(){    test(3.5f, 5.6f); // Added suffix "f" to both values to                      // tell compiler, it's a float value    return 0;}
Output:
Function with float called
 
This article is contributed by Aakash Sachdeva. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
cpp-data-types
CPP-Functions
cpp-overloading
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Multidimensional Arrays in C / C++
rand() and srand() in C/C++
Core Dump (Segmentation fault) in C/C++
Left Shift and Right Shift Operators in C/C++
Substring in C++
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
Inheritance in C++
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
What is JSON.parse() and and explain its use in javascript?

When the data is received from web server, the data is always a string .So to change it to the object, JSON.parse() method is used. 
 Live Demo
<html>
<body>
<script>
   var obj = '{"name":"Jon", "age":20, "city":"Columbia"}';
   var res = JSON.parse(obj);
   document.write(res);
   console.log(res);
</script>
</body>
</html>
[object object]
{"name":"Jon", "age":"20", "city":"Columbia"}
C - perror function

C - Programming HOME
C - Basic Introduction
C - Program Structure
C - Reserved Keywords
C - Basic Datatypes
C - Variable Types
C - Storage Classes
C - Using Constants
C - Operator Types
C - Control Statements
C - Input and Output
C - Pointing to Data
C - Using Functions
C - Play with Strings
C - Structured Datatypes
C - Working with Files
C - Bits Manipulation
C - Pre-Processors
C - Useful Concepts
C - Built-in Functions
C - Useful Resources
Computer Glossary
Who is Who
Copyright © 2014 by tutorialspoint
#include <stdio.h>
#include <errno.h>

void perror(const char *s);

The perror() function shall map the error number accessed through the symbol errno to a language-dependent error message, which shall be written to the standard error stream as follows:
First (if s is not a null pointer and the character pointed to by s is not the null byte), the string pointed to by s followed by a colon and a <space>.
First (if s is not a null pointer and the character pointed to by s is not the null byte), the string pointed to by s followed by a colon and a <space>.
Then an error message string followed by a <newline>.
Then an error message string followed by a <newline>.
Simply perror will retun a message corresponding to errno. The errno is a special system variable that is set if a system call cannot perform its set task.
The perror() function shall not return a value.
#include <stdio.h>
#include <errno.h>

extern int errno ;

int main ()
{
  FILE * pFile;
  pFile = fopen ("unexist.ent","rb");
  if (pFile == NULL)
  {
    perror ("The following error occurred");
    printf( "Value of errno: %d\n", errno );
  }
  else
    fclose (pFile);
  return 0;
}

If file unexist.ent does not exit then it will produce following result:
The following error occurred: No such file or directory
Value of errno: 29


Advertisements


    6 Lectures 
     1.5 hours 

 Mr. Pradeep Kshetrapal

    41 Lectures 
     5 hours 

 AR Shankar

    11 Lectures 
     58 mins

 Musab Zayadneh

    59 Lectures 
     15.5 hours 

 Narendra P

    11 Lectures 
     1 hours 

 Sagar Mehta

    39 Lectures 
     4 hours 

 Vikas Yadav
 Print
 Add Notes
 Bookmark this page
Java Program for Binary Insertion Sort

Binary insertion sort uses the binary search to find the right position to insert an element at a specific index at every iteration. First, the location where the element needs to be inserted is found. Then, the elements are shifted to the next right location. Now, the specific element is placed in the position.
Following is the Java code for Binary Insertion Sort −
 Live Demo
public class Demo{
   void Cocktail_Sort(int my_arr[]){
      boolean swapped = true;
      int start = 0;
      int end = my_arr.length;
      while (swapped == true) {
         swapped = false;
         for (int i = start; i < end - 1; ++i) {
            if (my_arr[i] > my_arr[i + 1]) {
               int temp = my_arr[i];
               my_arr[i] = my_arr[i + 1];
               my_arr[i + 1] = temp;
               swapped = true;
            }
         }
         if (swapped == false)
            break;
         swapped = false;
         end = end - 1;
         for (int i = end - 1; i >= start; i--) {
            if (my_arr[i] > my_arr[i + 1]) {
               int temp = my_arr[i];
               my_arr[i] = my_arr[i + 1];
               my_arr[i + 1] = temp;
               swapped = true;
            }
         }
         start = start + 1;
      }
   }
   void print_values(int my_arr[]){
      for (int i = 0; i < my_arr.length; i++)
      System.out.print(my_arr[i] + " ");
      System.out.println();
   }  
   public static void main(String[] args){
      Demo my_object = new Demo();
      int my_arr[] = { 6, 8, 34, 21, 0, 1, 98, 64, 6};
      System.out.println("The array contains ");
      for (int i = 0; i < my_arr.length; i++)
      System.out.print(my_arr[i] + " ");
      System.out.println();
      my_object.Cocktail_Sort(my_arr);
      System.out.println("The array after implementing cocktail sort is : ");
      my_object.print_values(my_arr);
   }
}
The array contains
6 8 34 21 0 1 98 64 6
The array after implementing cocktail sort is :
0 1 6 6 8 21 34 64 98
Print leading zeros with C++ output operator

Here we will see how to print leading zeros as output in C++. We know that if we directly put some zeros before some numeric values, then all zeros are discarded, and only exact numbers are printed.
In C, we can solve this problem by using some options of format specifier. In C++ we can manipulate the output sequence using iomanip library. In this library we will get setw() function to make some space between previous text and current text. Then we can use setfill(char) function to add some characters into that field.
Please check the following code to get the idea about setw() and setfill().
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
   int number = 256; //want to print 00000256, so total 8
   characters
   cout << setw(8) << setfill('0') << number;
}
00000256
GATE | GATE CS 2008 | Question 45 - GeeksforGeeks

28 Jun, 2021
Dijkstra’s single source shortest path algorithm when run from vertex a in the below graph, computes the correct shortest path distance to
(A) only vertex a(B) only vertices a, e, f, g, h(C) only vertices a, b, c, d(D) all the verticesAnswer: (D)Explanation: Dijkstra’s single source shortest path is not guaranteed to work for graphs with negative weight edges, but it works for the given graph.Let us see...
Let us run the 1st pass
b 1
b is minimum, so shortest distance to b is 1.

After 1st  pass, distances are
c 3, e -2.  
e is minimum, so shortest distance to e is -2

After 2nd pass, distances are
c 3, f 0.  
f is minimum, so shortest distance to f is 0

After 3rd pass, distances are
c 3, g 3.  
Both are same, let us take g. so shortest distance to g is 3.

After 4th pass, distances are
c 3, h 5  
c is minimum, so shortest distance to c is 3

After 5th pass, distances are
h  -2
h is minimum, so shortest distance to h is -2
Quiz of this Question
GATE-CS-2008
GATE-GATE CS 2008
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-IT-2004 | Question 71
GATE | GATE CS 2011 | Question 7
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE CS 2010 | Question 24
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE CS 2018 | Question 37
GATE | GATE-IT-2004 | Question 83
GATE | GATE-CS-2016 (Set 1) | Question 63
Changing the Mouse Cursor - Tkinter - GeeksforGeeks

24 Jan, 2021
Prerequisite: Python GUI – tkinter
Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python.
In this article, we will learn, how to change the mouse cursor in Tkinter Using Python.
A mouse cursor is treated as an indicator, which is used to show the current position of the user position on a computer. It is also called a pointer.
Every mouse cursor has its own use. For example, for dragging the image we use fleur mouse cursor, for rotating the text we use exchange mouse cursor etc.
There are about 20 cursors that can be found in Tkinter:
arrow
circle
clock
cross
dotbox
exchange
fleur
heart
man
mouse
pirate
plus
shuttle
sizing
spider
spraycan
star
target
tcross
trek
Step1: Create Normal Tkinter window and add Button
Python3
# Import Required Libraryfrom tkinter import *  # Create Objectroot = Tk()  # Set geometryroot.geometry("400x400")  Button(root,text="Button",font=("Helvetica 15 bold")).pack()  # Execute Tkinterroot.mainloop()
Output:
Step2: Add cursor in button
For adding a cursor in Button, use cursor attributes.
Button(root,text="Button",font=("Helvetica 15 bold"),cursor="star").pack()
Use all cursors
Make a list, which contains all cursors
Iterate through all cursors.
Below is the GUI looks like:-
Below is the implementation:
Python3
# Import Required Libraryfrom tkinter import *  # Create Objectroot = Tk()  # Set geometryroot.geometry("200x530")  # List of cursorscursors =[        "arrow",        "circle",        "clock",        "cross",        "dotbox",        "exchange",        "fleur",        "heart",        "man",        "mouse",        "pirate",        "plus",        "shuttle",        "sizing",        "spider",        "spraycan",        "star",        "target",        "tcross",        "trek"]      # Iterate through all cursorsfor cursor in cursors:    Button(root,text=cursor,cursor=cursor).pack()    # Execute Tkinterroot.mainloop()
Output:-
For making the cursor globally, use config() method.
Python3
# Import Required Libraryfrom tkinter import *  # Create Objectroot = Tk()  # Set geometryroot.geometry("400x400")  # Cursorroot.config(cursor="star")  # Execute Tkinterroot.mainloop()
Output:-
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
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
Defaultdict in Python
Python | os.path.join() method
Python | Get unique values from a list
Selecting rows in pandas DataFrame based on conditions
Create a directory in Python
Python | Pandas dataframe.groupby()
ISRO | ISRO CS 2009 | Question 42 - GeeksforGeeks

06 Jun, 2018
Substitution of values for names (whose values are constants) is done in(A) Local optimization(B) Loop optimization(C) Constant folding(D) Strength reductionAnswer: (C)Explanation: Constant folding is the process of recognizing and evaluating constant expressions at compile time rather than computing them at runtime.
Example: x = 256 * 256 * 256;

Most modern compilers would not actually generate two multiply instructions and a store for this statement. Instead, they identify constructs such as these and substitute the computed values at compile time (in this case, 16777216). The resulting code would load the computed value and store it rather than loading and multiplying several values.
Example:
int a = 30;
int b = 10
int c;
c = b * 4;    // replace b by 10
if (c > 10) {
c = c - 10;
 }
return c * (60 / a);  // (60 / a is replaced with 2)
So, option (C) is correct.
Quiz of this Question
ISRO
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ISRO | ISRO CS 2017 | Question 44
ISRO | ISRO CS 2017 | Question 31
ISRO | ISRO CS 2017 | Question 32
ISRO | ISRO CS 2017 | Question 33
ISRO | ISRO CS 2017 | Question 34
ISRO | ISRO CS 2017 | Question 35
ISRO | ISRO CS 2017 | Question 36
ISRO | ISRO CS 2017 | Question 37
ISRO | ISRO CS 2017 | Question 38
ISRO | ISRO CS 2017 | Question 39
Python | Test list element similarity - GeeksforGeeks

27 Jun, 2019
Given a list, your task is to determine the list is K percent same i.e has element that is populated more than K % times.Given below are few methods to solve the task.Method #1 Using collections.Counter
# Python3 code to demonstrate# to check whether the list# K percent same or notfrom collections import Counter  # initializing listini_list1 = [1, 2, 3, 1, 1, 1, 1, 1, 3, 2]  # printing initial listprint ("Initial list", ini_list1)  # initializing KK = 60  # code to check whether list is K % same or noti, freq = Counter(ini_list1).most_common(1)[0]  if len(ini_list1)*(K / 100) <= freq:    print("True")else:    print("False")
Output:
Initial list [1, 2, 3, 1, 1, 1, 1, 1, 3, 2] 
True

Method #2: Using dictionary and its values
# Python3 code to demonstrate# to check whether the list# K percent same or notfrom collections import Counter, defaultdict  # initializing listini_list1 = [1, 2, 3, 1, 1, 1, 1, 1, 3, 2]  # printing initial listprint ("Initial list", ini_list1)  # initializing KK = 60  # code to check whether list is K % same or notfreq = defaultdict(int)for x in ini_list1:    freq[x] += 1freq = freq.values()if max(freq) >= (K / 100) * sum(freq):    print ("True")else:    print ("False")
Output:
initial list [1, 2, 3, 1, 1, 1, 1, 1, 1, 1]
True

Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
How do you run JavaScript script through the Terminal? - GeeksforGeeks

29 Mar, 2022
You can Run your JavaScript File from your Terminal only if you have installed NodeJs runtime. If you have Installed it then Simply open the terminal and type “node FileName.js”. If you don’t have NodeJs runtime environment then go to NodeJs Runtime Environment Download and Download it. Example 1: Create a JavaScript File Name this file as New.js. 
javascript
// Simple Addition Function in Javascriptfunction add(a, b) {return a+b}console.log(add(4, 6))
Output:
10
Steps :
Open Terminal or Command Prompt.Set Path to where File is Located (using cd).Type “node New.js” and Click Enter
Open Terminal or Command Prompt.
Set Path to where File is Located (using cd).
Type “node New.js” and Click Enter
Examples 2: Create a JavaScript File Name this file as New2.js. 
javascript
// Simple Subtraction Function in Javascriptfunction sub(a, b) {return a-b}console.log(sub(6, 2))
Output:
4
JavaScript is best known for web page development but it is also used in a variety of non-browser environments. You can learn JavaScript from the ground up by following this JavaScript Tutorial and JavaScript Examples.
simranarora5sos
JavaScript-Misc
Node.js
Picked
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Difference Between PUT and PATCH Request
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Fix "Unable to locate adb within SDK" in Android Studio - GeeksforGeeks

11 Jun, 2021
The following error occurs when the adb file is not found within the SDK system folder. A software development kit (SDK) provides the software required to build your applications for a target platform.
To resolve this, firstly you need to check if the adb is even present in the SDK folder. For this, open C:\Users\Username\AppData\Local\Android\Sdk\platform-tools, check if adb.exe is present.
Case 1: If adb is not present:
If the adb is not present, installing the platform-tools resolves the problem. For this, open Android Studio, click on SDK Manager in the toolbar or click Tools > SDK Manager, click on SDK Tools, then check-mark ‘✓’ Android-SDK Platform-Tools (as shown below).
Case 2: If adb is present
This generally occurs if the platform-tools are not installed properly. Reinstalling the platform tools might fix this problem. Open Android Studio, click SDK Manager in the toolbar or click Tools > SDK Manager, click SDK Tools, then uncheck Android-SDK Platform-Tools (as shown above). After this, open C:\Users\Username\AppData\Local\Android\Sdk and delete the platform-tools folder. Then go back to Android Studio and in the SDK Tools, check-mark ‘✓’ Android-SDK Platform-Tools.
If you’re using Android Studio, you can simply use the IDE instead of this method and manage your SDK tools as stated in METHOD 1.
Case 1: If adb is not present
Install the platform tools. For this, open C:\Users\Prasoon\AppData\Local\Android\Sdk\tools\bin\sdkmanager. Type in:
sdkmanager "platform-tools"
Case 2: If adb is present
Reinstalling the platform-tools might fix this problem. For this, open C:\Users\Prasoon\AppData\Local\Android\Sdk\tools\bin\sdkmanager. Type in:
sdkmanager --uninstall "platform-tools"
Now the platform-tools are uninstalled. Open C:\Users\Username\AppData\Local\Android\Sdk and delete the platform-tools folder from there.
Now you need to reinstall the platform tools. Go back to the sdkmanager command-line tool and type in:
sdkmanager "platform-tools"
Sometimes, the windows security might quarantine adb.exe. You can simply resolve this issue by checking if the file is quarantined. If so, select the Allow on device option (as shown below).
Android-Studio
Picked
Android
Android
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Create and Add Data to SQLite Database in Android?
Resource Raw Folder in Android Studio
Broadcast Receiver in Android With Example
Services in Android with Example
Android RecyclerView in Kotlin
CardView in Android With Example
Content Providers in Android with Example
Navigation Drawer in Android
How to Update Gradle in Android Studio?
Flutter - Custom Bottom Navigation Bar
How to Print Fast Output in Competitive Programming using Java? - GeeksforGeeks

16 Aug, 2021
In Competitive programming, most of the students use C++ as their primary language as it is faster than the other languages(e.g Java, Python) but for a student/professional who use Java as his/her primary language taking Input from input streams and printing fast output is the main difficulty faced during contests on competitive platforms(eg. CodeChef, CodeForces, Spoj, etc).
In this article, there defined the fastest method to print O/P using Java (Mainly in Competitive Programming).
BufferedWriter Class: It writes text to a character-output stream, buffering characters to provide for the efficient writing of single characters, arrays, and strings. It makes the performance fast.
BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
Methods of BufferedWriter:
write(): writes a single character to the internal buffer of the writer.
write(char[] array): writes the characters from the specified array to the writer.
write(String data): writes the specified string to the writer.
flush(): used to clear the internal buffer.
close(): used to close the buffered writer.
Below is the implementation of the problem statement:
Java
// Print fast Output in Competitive Programming using JAVAimport java.io.*; class GFG {    public static void main(String[] args) throws Exception    {        String[] gfg = { "Geeks", "For", "Geeks" };         BufferedWriter output = new BufferedWriter(            new OutputStreamWriter(System.out));         for (int i = 0; i < gfg.length; i++) {            output.write(gfg[i] + "\n");        }         output.flush();    }}
Geeks
For
Geeks
 
clintra
Technical Scripter 2020
Competitive Programming
Java
Java Programs
Technical Scripter
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Multistage Graph (Shortest Path)
Breadth First Traversal ( BFS ) on a 2D array
Check whether bitwise AND of a number with any subset of an array is zero or not
Shortest path in a directed graph by Dijkstra’s algorithm
5 Best Books for Competitive Programming
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Object Oriented Programming (OOPs) Concept in Java
Arrays.sort() in Java with examples
Packages in Java - GeeksQuiz

07 Mar, 2018
1) Every class is part of some package. 
2) All classes in a file are part of the same package. 
3) If no package is specified, the classes in the file 
   go into a special unnamed package 
4) If no package is specified, a new package is created with 
   folder name of class and the class is put in this package. 
Java applets can not be written in any programming language. IncorrectIt can be written in other programming language.
An applet is not a small program. Incorrect It is a small program.
An applet can be run on its own. Incorrect No applet don't run on its own.
Applets are embedded in another applications. Correct. Yes applets are embedded in another applicationFor more infor mation on applet Refer:Java Applet Basics
Option (D) is correct.
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Best Time to Buy and Sell Stock
Must Do Coding Questions for Product Based Companies
How to Replace Values in Column Based on Condition in Pandas?
C Program to read contents of Whole File
Insert Image in a Jupyter Notebook
How to Replace Values in a List in Python?
How to Read Text Files with Pandas?
How to Compare Two Columns in Pandas?
Python Data Structures and Algorithms
Data Science With Python Tutorial
Python | Ways to concatenate tuples - GeeksforGeeks

29 Oct, 2019
Many times, while working with records, we can have a problem in which we need to add two records and store them together. This requires concatenation. As tuples are immutable, this task becomes little complex. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using + operatorThis is the most Pythonic and recommended method to perform this particular task. In this, we add two tuples and return the concatenated tuple. No previous tuple is changed in this process.
# Python3 code to demonstrate working of# Ways to concatenate tuples# using + operator  # initialize tuplestest_tup1 = (1, 3, 5)test_tup2 = (4, 6)  # printing original tuplesprint("The original tuple 1 : " + str(test_tup1))print("The original tuple 2 : " + str(test_tup2))  # Ways to concatenate tuples# using + operatorres = test_tup1 + test_tup2  # printing resultprint("The tuple after concatenation is : " + str(res))
The original tuple 1 : (1, 3, 5)
The original tuple 2 : (4, 6)
The tuple after concatenation is : (1, 3, 5, 4, 6)

 
Method #2 : Using sum()This is yet another way in which this task can be performed. In this, we add the tuples to one other using sum function.
# Python3 code to demonstrate working of# Ways to concatenate tuples# using sum()  # initialize tuplestest_tup1 = (1, 3, 5)test_tup2 = (4, 6)  # printing original tuplesprint("The original tuple 1 : " + str(test_tup1))print("The original tuple 2 : " + str(test_tup2))  # Ways to concatenate tuples# using sum()res = sum((test_tup1, test_tup2), ())  # printing resultprint("The tuple after concatenation is : " + str(res))
The original tuple 1 : (1, 3, 5)
The original tuple 2 : (4, 6)
The tuple after concatenation is : (1, 3, 5, 4, 6)

Python tuple-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
BeautifulSoup - Scraping Link from HTML - GeeksforGeeks

24 Jan, 2021
Prerequisite: Implementing Web Scraping in Python with BeautifulSoup
In this article, we will understand how we can extract all the links from a URL or an HTML document using Python.
bs4 (BeautifulSoup): It is a library in python which makes it easy to scrape information from web pages, and helps in extracting the data from HTML and XML files. This library needs to be downloaded externally as it does not come readily with Python package. To install this library, type the following command in your terminal.
pip install bs4
requests: This library enables to send the HTTP requests and fetch the web page content very easily. This library also needs to be downloaded externally as it does not come readily with Python package. To install this library, type the following command in your terminal.
pip install requests
Import the required libraries (bs4 and requests)
Create a function to get the HTML document from the URL using requests.get() method by passing URL to it.
Create a Parse Tree object i.e. soup object using of BeautifulSoup() method, passing it HTML document extracted above and Python built-in HTML parser.
Use the a tag to extract the links from the BeautifulSoup object.
Get the actual URLs from the form all anchor tag objects with get() method and passing href argument to it.
Moreover, you can get the title of the URLs with get() method and passing title argument to it.
Python3
# import necessary librariesfrom bs4 import BeautifulSoupimport requestsimport re    # function to extract html document from given urldef getHTMLdocument(url):          # request for HTML document of given url    response = requests.get(url)          # response will be provided in JSON format    return response.text      # assign required credentials# assign URLurl_to_scrape = "https://practice.geeksforgeeks.org/courses/"  # create documenthtml_document = getHTMLdocument(url_to_scrape)  # create soap objectsoup = BeautifulSoup(html_document, 'html.parser')    # find all the anchor tags with "href" # attribute starting with "https://"for link in soup.find_all('a',                           attrs={'href': re.compile("^https://")}):    # display the actual urls    print(link.get('href'))  
Output:
Picked
Python BeautifulSoup
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
SUM() Function in SQL Server - GeeksforGeeks

21 Jan, 2021
SUM() :
This function in SQL Server is used to compute the sum of the specified group of values.
Features :
This function is used to compute the sum of the specified group of values.
This function comes under Numeric Functions.
This function accepts only one parameter namely expression.
This function ignores the null value.
Syntax :
SUM(expression)
Parameter :
This method accepts one parameter.
expression –  A specified expression which can either be a field or a given formula.
Returns :
It returns the sum of the specified group of values.
Example-1 :
Using SUM() function and getting the output.
CREATE TABLE product
(  
user_id int IDENTITY(100, 2) NOT NULL,    
product_1 VARCHAR(10),
product_2 VARCHAR(10),
price int  
);
INSERT product(product_1, price)  
VALUES ('rice', 400);

INSERT product(product_2, price)  
VALUES ('grains', 600);

SELECT SUM(price) FROM product;
Output :
1000
Example-2 :
Using SUM() function and finding the sum of all the stated float values.
CREATE TABLE floats
(  
user_id int IDENTITY(100, 2) NOT NULL,
float_val float
);
INSERT floats(float_val)  
VALUES (3.6);

INSERT floats(float_val)  
VALUES (2.1);

INSERT floats(float_val)  
VALUES (6.3);

INSERT floats(float_val)  
VALUES (9.0);

INSERT floats(float_val)  
VALUES (7.0);

SELECT SUM(float_val) FROM floats;
Output :
28
Example-3 :
Using SUM() function and getting the output where MRP is less than the sum of all the MRP’s.
CREATE TABLE package
(  
user_id int IDENTITY(100, 4) NOT NULL,  
item VARCHAR(10),
mrp int  
);
INSERT package(item, mrp)  
VALUES ('book1', 3);

INSERT package(item, mrp)  
VALUES ('book2', 350);

INSERT package(item, mrp)  
VALUES ('book3', 400);

SELECT * FROM package
WHERE mrp < (SELECT SUM(mrp) FROM package);
Output :
  | user_id  | item     | mrp
--------------------------------
1 | 100      | book1    | 3
--------------------------------
2 | 104      | book2    | 350
--------------------------------
3 | 108      | book3    | 400
Example-4 :
Using SUM() function and getting the sum of all the (MRP-sales price) values.
CREATE TABLE package
(  
user_id int IDENTITY(100, 4) NOT NULL,  
item VARCHAR(10),
mrp int,
sp int
);
INSERT package(item, mrp, sp)  
VALUES ('book1', 250, 240);

INSERT package(item, mrp, sp)  
VALUES ('book2', 350, 320);

INSERT package(item, mrp, sp)  
VALUES ('book3', 400, 350);

SELECT SUM(mrp-sp) FROM package;
Output :
90
Application :
This function is used to compute the sum of the specified group of values.
DBMS-SQL
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL | Subquery
SQL Query to Convert VARCHAR to INT
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
How to Select Data Between Two Dates and Times in SQL Server?
How to Write a SQL Query For a Specific Date Range and Date Time?
SQL Query to Compare Two Dates
C program to calculate the value of nPr - GeeksforGeeks

02 Nov, 2021
nPr represents n permutation r and value of nPr is (n!) / (n-r)!. 
C
#include<stdio.h> int fact(int n){    if (n <= 1)        return 1;    return n*fact(n-1);} int nPr(int n, int r){    return fact(n)/fact(n-r);} int main(){    int n, r;    printf("Enter n: ");    scanf("%d", &n);     printf("Enter r: ");    scanf("%d", &r);     printf("%dP%d is %d", n, r, nPr(n, r));     return 0;}
Enter n: 5
Enter r: 2
5P2 is 20 
Time Complexity: O(n)
Auxiliary Space: O(n)
Please refer Permutation Coefficient for efficient methods to compute nPr.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above 
subhammahato348
factorial
Combinatorial
Mathematical
Mathematical
Combinatorial
factorial
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Print all possible strings of length k that can be formed from a set of n characters
Count of subsets with sum equal to X
Python program to get all subsets of given size of a set
Print all distinct permutations of a given string with duplicates
Heap's Algorithm for generating permutations
C++ Data Types
Set in C++ Standard Template Library (STL)
Merge two sorted arrays
Modulo Operator (%) in C/C++ with Examples
Java Program to Find the Perimeter of a Circle - GeeksforGeeks

07 Jan, 2021
A circle is a simple shape consisting of all the points in the plane that are equidistant from a point known as the center of the circle. In this article, we will learn how to find the area of the circle.
Terminology:
Perimeter: A quantity of measurement or boundary of the circle. It is basically the distance around a closed figure.
Radius: The line segment from the center to any point of the circle is known as radius.
Diameter: The line segment whose endpoints lie on the circle and passed through the center is known as the diameter of the circle. It is also known as the largest distance between any two points on the circle.
Perimeter Of A Circle:
Using the radius of the circle:
Formula:
Perimeter of the circle:  P =2 *  π * r
Here, r is the radius of the circle.
Using the diameter of the circle:
Formula:
Perimeter of the circle:  A =  π * d
Note: The value of PI in java is 3.141592653589793. 
Example 1:
Java
// Java program to find// the perimeter of the circle// using radius  import java.io.*;  class GFG {      static final double PI = Math.PI;      // Function to calculate the    // perimeter of the circle    static double Perimeter(double r)     {       return 2 * PI * r;     }      // Driver code    public static void main(String[] args)    {          // Radius        double r = 5;          // Calling Perimeter function        System.out.println("Perimeter of the circle is :"                           + Perimeter(r));    }}
Perimeter of the circle is :31.41592653589793

 Example 2:
Java
// Java program to find// the area of the circle// Using Diameter  import java.io.*;  class GFG {      static final double PI = Math.PI;      // Function to calculate the    // perimeter of the circle    // using Diameter    static double Perimeter(double D)    {        return PI * D;    }      // Driver code    public static void main(String[] args)    {          // Diameter        double D = 20;          // Calling Perimeter function        System.out.println("Perimeter of the circle is :"                           + Perimeter(D));    }}
Perimeter of the circle is :62.83185307179586

Picked
Technical Scripter 2020
Java
Java Programs
Technical Scripter
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
How to Iterate HashMap in Java?
Program to print ASCII Value of a character
is_pointer Template in C++ - GeeksforGeeks

19 Nov, 2018
The std::is_pointer template of C++ STL is used to check whether the given type is pointer or not. It returns a boolean value showing the same.
Syntax:
template <class T > struct is_pointer;
Parameter: This template accepts a single parameter T (Trait class) to check whether T is a pointer or not.
Return Value: This template returns a boolean value as shown below:
True: if the type is a pointer.
False: if the type is a non-pointer.
Below programs illustrate the std::is_pointer template in C++ STL:
Program 1:
// C++ program to illustrate// is_pointer template  #include <iostream>#include <type_traits>using namespace std;  // main programclass GFG {};  int main(){    cout << boolalpha;    cout << "is_pointer:"         << endl;    cout << "GFG: "         << is_pointer<GFG>::value << '\n';    cout << "GFG*: "         << is_pointer<GFG*>::value << '\n';    cout << "GFG&: "         << is_pointer<GFG&>::value << '\n';    cout << "nullptr_t: "         << is_pointer<nullptr_t>::value << '\n';      return 0;}
is_pointer:
GFG: false
GFG*: true
GFG&: false
nullptr_t: false

Program 2:
// C++ program to illustrate// is_pointer template  #include <iostream>#include <type_traits>using namespace std;  // main programint main(){    cout << boolalpha;    cout << "is_pointer:"         << endl;    cout << "int: "         << is_pointer<int>::value << '\n';    cout << "int *: "         << is_pointer<int*>::value << '\n';    cout << "int **: "         << is_pointer<int**>::value << '\n';    cout << "int ***: "         << is_pointer<int***>::value << '\n';      return 0;}
is_pointer:
int: false
int *: true
int **: true
int ***: true

Program 3:
// C++ program to illustrate// is_pointer template  #include <iostream>#include <type_traits>using namespace std;  // main programint main(){      cout << boolalpha;    cout << "is_pointer:" << endl;    cout << "int *&: "         << is_pointer<int*&>::value << '\n';    cout << "int *[10]: "         << is_pointer<int * [10]>::value << '\n';    cout << "float *: "         << is_pointer<float*>::value << '\n';    cout << "int[10]:"         << is_pointer<int[10]>::value << '\n';      return 0;}
is_pointer:
int *&: false
int *[10]: false
float *: true
int[10]:false

cpp-pointer
cpp-template
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in C++
C++ Classes and Objects
Virtual Function in C++
Operator Overloading in C++
Constructors in C++
vector erase() and clear() in C++
Socket Programming in C/C++
Object Oriented Programming in C++
Substring in C++
Copy Constructor in C++
Python - Remove Key from Dictionary List - GeeksforGeeks

11 Jan, 2022
Sometimes, while working with Python dictionaries, we can have a problem in which we need to remove a specific key from a dictionary list. This kind of problem is very common and has application in almost all domains including day-day programming and web development domain. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using loop + delThe combination of above functions can be used to solve this problem. In this, we iterate for all the keys and delete the required key from each dictionary using del.
Python3
# Python3 code to demonstrate working of # Remove Key from Dictionary List# Using loop + del  # initializing listtest_list = [{'Gfg' :  1, 'id' : 2, 'best' : 8 },              {'Gfg' :  4, 'id' : 4, 'best':  10},              {'Gfg' :  4, 'id' : 8, 'best':  11}]  # printing original listprint("The original list is : " + str(test_list))  # initializing key del_key = 'id'  # Remove Key from Dictionary List# Using loop + delfor items in test_list:    if del_key in items:        del items[del_key]  # printing result print("The modified list : " + str(test_list)) 
The original list is : [{'best': 8, 'id': 2, 'Gfg': 1}, {'best': 10, 'id': 4, 'Gfg': 4}, {'best': 11, 'id': 8, 'Gfg': 4}]
The modified list : [{'best': 8, 'Gfg': 1}, {'best': 10, 'Gfg': 4}, {'best': 11, 'Gfg': 4}]

 
Method #2 : Using list comprehension + dictionary comprehensionThis is yet another way in which this task can be performed. In this, we reconstruct each dictionary removing out the specific key from it.
Python3
# Python3 code to demonstrate working of # Remove Key from Dictionary List# Using list comprehension + dictionary comprehension  # initializing listtest_list = [{'Gfg' :  1, 'id' : 2, 'best' : 8 },              {'Gfg' :  4, 'id' : 4, 'best':  10},              {'Gfg' :  4, 'id' : 8, 'best':  11}]  # printing original listprint("The original list is : " + str(test_list))  # initializing key del_key = 'id'  # Remove Key from Dictionary List# Using list comprehension + dictionary comprehensionres = [{key : val for key, val in sub.items() if key != del_key} for sub in test_list]  # printing result print("The modified list : " + str(res)) 
The original list is : [{'best': 8, 'id': 2, 'Gfg': 1}, {'best': 10, 'id': 4, 'Gfg': 4}, {'best': 11, 'id': 8, 'Gfg': 4}]
The modified list : [{'best': 8, 'Gfg': 1}, {'best': 10, 'Gfg': 4}, {'best': 11, 'Gfg': 4}]

gulshankumarar231
Python list-programs
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
How to Install Eclipse For PHP on Linux? - GeeksforGeeks

10 Feb, 2022
Eclipse is a free open source platform, Integrated Development Environment (IDE) with the help of which applications are made using the Java programming languages and other programming languages are also used such as C/C++, PERL, Python, Ruby, etc. It is composed of many plug-ins and is designed to be extensible using additional plug-ins.
Follow the below steps to install Eclipse for PHP on Linux:
Step 1: Browse to this link & click on Linux x86_64.
Step 2: Click on the download button.
Step 3: Open terminal & execute the following commands:
cd downloads/
ls
tar xvfz eclipse-inst-linux64.tar.gz
Step 4: Then again execute the following commands:
ls
cd eclipse-installer/
ls
./eclipse-inst
Then the installation will start.
Step 5: Then select Eclipse IDE for PHP Developers.
Step 6: Click on install.
Now, wait for the installation to be completed.
Then the installation will be complete.
Then it will launch.
Hence, your installation is successful.
sagar0719kumar
how-to-install
Picked
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install FFmpeg on Windows?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Set Git Username and Password in GitBash?
How to Install Jupyter Notebook on MacOS?
How to Create and Setup Spring Boot Project in Eclipse IDE?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?
What is the difference between "char a" and "char a[1]"? - GeeksforGeeks

08 May, 2017
Question Source: Aricent Interview
Although both expressions can be used to create a variable to store one character, there are following differences.
1) “char a” represents a character variable and “char a[1]” represents a char array of size 1.
2) If we print value of char a, we get ASCII value of the character (if %d is used). And if we print value of char a[1], we get address of the only element in array.
#include <stdio.h>  int main (){  char a1 = 'A';  char a2[1] = {'A'};  printf("%d  %d", a1, a2);  return 0;}
Output:
65
An address

This article is contributed by Abhishek. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
cpp-array
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Exception Handling in C++
Multithreading in C
'this' pointer in C++
Arrow operator -> in C/C++ with Examples
Smart Pointers in C++ and How to Use Them
Understanding "extern" keyword in C
Multiple Inheritance in C++
Ways to copy a vector in C++
How to split a string in C/C++, Python and Java?
C++ Functions

A function is a block of code which only runs when it is called.
You can pass data, known as parameters, into a function.
Functions are used to perform certain actions, and they are 
important for reusing code: Define the code once, and use it many times.
C++ provides some pre-defined 
functions, such as main(), which is used to 
execute code. But you can also 
create your own functions to perform certain actions. 
To create (often referred to as declare) a function, specify the name of the function, followed by parentheses (): 
myFunction() is the name of the function
void means that the function does not have a 
return value. You will learn more about return values later in the next chapter
inside the function (the body), add code that defines what the function should do
Declared functions are not executed immediately. They are "saved for later 
use", and will be executed later, when they are called.
To call a function, write the function's name followed by two parentheses () 
and a semicolon ;
In the following example, myFunction() is used to print a text (the action), when it is called:
Inside main, 
call 
myFunction():
A function can be called multiple times:
A C++ function consist of two parts:
Declaration: the return type, the name of the function, and parameters (if any)
Definition: the body of the function (code to be executed)
Note: If a user-defined function, such as myFunction() is declared after the main() function, 
an error will occur:
However, it is possible to separate the declaration and the definition of the function - for code optimization.
You will often see C++ programs that have function declaration above main(), 
and function definition below main(). This will make the code 
better organized and easier to read:
Create a function named myFunction and call it inside main().
void () {
  cout << "I just got executed!";
}

int main() {  
  ;
  return 0;
}

Start the Exercise
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.
Character class: Negation - Java regular expressions

The character classes in Java regular expression is defined using the square brackets "[ ]", this subexpression matches a single character from the specified or, set of possible characters.
For example the regular expression [abc] matches a single character a or, b or, c. Similarly, "[a-z]" matches a single character from a to z.
Similarly, the negation variant of the character class is defined as "[^ ]" (with ^ within the square braces), it matches a single character which is not in the specified or set of possible characters.
For example the regular expression [^abc] matches a single character except a or, b or, c. Similarly, "[^a-z]" matches a character excepts alphabets from a to z.
 Live Demo
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexExample1 {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter input text: ");
      String input = sc.nextLine();
      String regex = "[^aeiou]";
      //Creating a pattern object
      Pattern pattern = Pattern.compile(regex);
      //Matching the compiled pattern in the String
      Matcher matcher = pattern.matcher(input);
      int count =0;
      while (matcher.find()) {
         count++;
      }
      System.out.println("Number of non-vowel characters : "+count);
   }
}
Enter input text:
sample data
Number of non-vowel characters : 7