code-rag-bench/online-tutorials huggingface dataset:
How to Create a Range From a Specified Start in C#? - GeeksforGeeks

28 Nov, 2019
The Range Structure is introduced in C# 8.0. It represents a range that has a start and end indexes. You are allowed to create a Range object starting from the specified starting index to the end of the given collection or sequence with the help of the StartAt() Method provided by the Range structure. Or in other words, StartAt() Method returns a range that starts from the specified start index to the end of the given collection or sequence.
Syntax:
public static Range StartAt(Index start);
Here, the Index start represents the start index.
Example 1:
// C# program to illustrate // how to create a range using// StartAt() method of Range structusing System;  namespace range_example {  class GFG {      // Main Method    static void Main(string[] args)    {        // Creating range        // using Range constructor        var r1 = new Range(2, 4);          // Creating range        // using Range operator        Range r2 = 1..10;          // Creating a range        // using StartAt() method        var r3 = Range.StartAt(4);          // Displaying all the ranges        Console.WriteLine("Range_1: " + r1);        Console.WriteLine("Range_2: " + r2);        Console.WriteLine("Range_3: " + r3);    }}}
Output:
Range_1: 2..4
Range_2: 1..10
Range_3: 4..^0

Example 2:
// C# program to illustrate how // to create a range using// StartAt() method of Range structusing System;   namespace range_example {   class GFG {       // Main Method    static void Main(string[] args)    {        // Creating and initializing an array        int[] arr = new int[8] {100, 200, 300,                     400, 500, 600, 700, 800};           // Creating a range        // using StartAt() method        var r = Range.StartAt(2);        var new_arr = arr[r];           // Displaying the range        // and the elements        Console.WriteLine("Range: " + r);        Console.Write("Numbers: ");           foreach(var i in new_arr)            Console.Write($" [{i}]");    }}}
Output:
Range: 2..^0
Numbers:  [300] [400] [500] [600] [700] [800]

CSharp-8.0
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Extension Method in C#
HashSet in C# with Examples
C# | Inheritance
Partial Classes in C#
C# | Generics - Introduction
Top 50 C# Interview Questions & Answers
Switch Statement in C#
C# | How to insert an element in an Array?
Convert String to Character Array in C#
Linked List Implementation in C#
Replace the column contains the values 'yes' and 'no' with True and False In Python-Pandas - GeeksforGeeks

28 Jul, 2020
Let’s discuss a program To change the values from a column that contains the values ‘YES’ and ‘NO’ with TRUE and FALSE.  
First, Let’s see a dataset.
Code:
Python3
# import pandas libraryimport pandas as pd   # load csv filedf = pd.read_csv("supermarkets.csv")   # show the dataframedf
Output : 
For downloading the used csv file Click Here.
Now, Let’s see the multiple ways to do this task:
Method 1: Using Series.map(). This method is used to map values from two series having one column the same. 
Syntax: Series.map(arg, na_action=None). Return type: Pandas Series with the same as an index as a caller. 
Example: Replace the ‘commissioned’ column contains the values ‘yes’ and ‘no’ with True and False.Code:
Python3
# import pandas libraryimport pandas as pd   # load csv filedf = pd.read_csv("supermarkets.csv")   # replace the ‘commissioned' column contains# the values 'yes' and 'no'  with # True and  False:df['commissioned'] = df['commissioned'].map(                   {'yes':True ,'no':False})  # show the dataframedf
Output : 
Method 2: Using DataFrame.replace(). This method is used to replace a string, regex, list, dictionary, series, number, etc. from a data frame. 
Syntax: DataFrame.replace(to_replace=None, value=None, inplace=False, limit=None, regex=False, method=’pad’, axis=None) Return type: Updated Data frame 
Example: Replace the ‘commissioned’ column contains the values ‘yes’ and ‘no’ with True and False.Code:
Python3
# import pandas libraryimport pandas as pd  # load csv filedf = pd.read_csv("supermarkets.csv")  # replace the ‘commissioned' column # contains the values 'yes' and 'no'#  with True and  False:df = df.replace({'commissioned': {'yes': True,                                 'no': False}})  # show the dataframedf
Output: 
 
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Convert integer to string in Python
ZonedDateTime format() method in Java with Examples - GeeksforGeeks

02 May, 2019
The format() method of ZonedDateTime class in Java is used to format this date-time using the specified formatter passed as parameter.This date-time will be passed to the formatter to produce a string.
Syntax:
public String format(DateTimeFormatter formatter)

Parameters: This method accepts a single parameter formatter which represents the formatter to use. This is a mandatory parameter and should not be NULL.
Return value: This method returns a String represents the formatted date-time string.
Exception: This method throws a DateTimeException if an error occurs during printing.
Below programs illustrate the format() method:Program 1:
// Java program to demonstrate// ZonedDateTime.format() method  import java.time.*;import java.time.format.*;  public class GFG {    public static void main(String[] args)    {          // create ZonedDateTime objects        ZonedDateTime zoneddatetime            = ZonedDateTime.parse("2018-12-06T19:21:12.123+05:30[Asia/Calcutta]");          // create a formatter        DateTimeFormatter formatter = DateTimeFormatter.ISO_TIME;          // apply format()        String value = zoneddatetime.format(formatter);          // print result        System.out.println("Result: " + value);    }}
Result: 19:21:12.123+05:30

Program 2:
// Java program to demonstrate// ZonedDateTime.format() method  import java.time.*;import java.time.format.*;  public class GFG {    public static void main(String[] args)    {          // create ZonedDateTime objects        ZonedDateTime zoneddatetime            = ZonedDateTime.parse("2018-10-25T23:12:31.123+02:00[Europe/Paris]");          // create a formatter        DateTimeFormatter formatter = DateTimeFormatter.BASIC_ISO_DATE;          // apply format()        String value = zoneddatetime.format(formatter);          // print result        System.out.println("Result: " + value);    }}
Result: 20181025+0200

Reference:https://docs.oracle.com/javase/10/docs/api/java/time/ZonedDateTime.html#format(java.time.format.DateTimeFormatter)
Akanksha_Rai
Java-Functions
Java-time package
Java-ZonedDateTime
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
HTTP headers | Access-Control-Allow-Origin - GeeksforGeeks

22 Nov, 2019
The Access-Control-Allow-Origin is a response header that is used to indicates whether the response can be shared with requesting code from the given origin.
Syntax:
Access-Control-Allow-Origin: * | <origin> | null
Directives: Access-Control-Allow-Origin accepts there types of directives mentioned above and described below:
*: This directive tells the browsers to allow requesting code from any origin to access the resource. Used as a wildcard.
<origin>: This directive defines any single origin.
null: This directive defines null that should not be used due to any origin can create a hostile document with a “null” Origin. The “null” value for the ACAO(Access-Control-Allow-Origin) header should therefore, be avoided.”
Example:
This example tells the browser to allow code from any origin to access a resource.access-control-allow-origin: *
access-control-allow-origin: *
A response that tells the browser to allow requesting code from the origin https://www.geeksforgeeks.org to access a resource will include the following:access-control-allow-origin:https://www.geeksforgeeks.orgHere the value of the Origin request header is compared with the list of allowed origins, and if the response header origin value is present in that compared list. Then set the Access-Control-Allow-Origin value to the same value as the Origin value.
access-control-allow-origin:https://www.geeksforgeeks.org
Here the value of the Origin request header is compared with the list of allowed origins, and if the response header origin value is present in that compared list. Then set the Access-Control-Allow-Origin value to the same value as the Origin value.
To check this Access-Control-Allow-Origin in action go to Inspect Element -> Network check the response header for Access-Control-Allow-Origin like below, Access-Control-Allow-Origin is highlighted you can see.Supported browsers: The browsers compatible with HTTP headers Access-Control-Allow-Origin are listed below:
Google Chrome 4.0
Internet Explorer 10.0
Firefox 3.5
Safari 4.0
Opera 12.0
HTTP-headers
Picked
Web Technologies
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
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
How to create footer to stay at the bottom of a Web page?
Differences between Functional Components and Class Components in React
Node.js fs.readFileSync() Method
How to apply style to parent if it has child with CSS?
How to Open URL in New Tab using JavaScript ?
How to execute PHP code using command line ?
Tryit Editor v3.7

Tryit: Text shadow with red neon glow
CodeIgniter - Common Functions

CodeIgniter library functions and helper functions need to be initialized before they are used but there are some common functions, which do not need to be initialized.
These common functions and their descriptions are given below.
$version (string) − Version number
$file (string) − File path
$key (string) − Config item key
$code (int) − HTTP Response status code
$text (string) − A custom message to set with the status code
$str (string) − Input string
$url_encoded (bool) − Whether to remove URLencoded characters as well
$var (mixed) − Variable to escape (string or array)
$function_name (string) − Function name
Given below is an example, which demonstrates all of the above functions.
Here we have created only one controller in which we will use the above functions. Copy the below given code and save it at  application/controller/CommonFun_Controller.php.
<?php 
   class CommonFun_Controller extends CI_Controller { 
	
      public function index() {
         set_status_header(200); 
         echo is_php('5.3')."<br>"; 
         var_dump(is_really_writable('./Form.php')); 
			
         echo config_item('language')."<br>"; 
         echo remove_invisible_characters('This is a ‌test','UTF8')."<br>"; 
			
         $str = '< This > is \' a " test & string'; 
         echo html_escape($str)."<br>"; 
         echo "is_https():".var_dump(is_https())."<br>"; 
         echo "is_cli():".var_dump(is_cli())."<br>"; 
			
         var_dump(function_usable('test'))."<br>"; 
         echo "get_mimes():".print_r(get_mimes())."<br>"; 
      } 
  
      public function test() { 
         echo "Test function"; 
      } 
		
   } 
?>
Change the routes.php file at application/config/routes.php to add route for the above controller and add the following line at the end of the file.
$route['commonfunctions'] = 'CommonFun_Controller';

Type the following URL in the address bar of your browser to execute the example.
http://yoursite.com/index.php/commonfunctions

 Print
 Add Notes
 Bookmark this page
How to configure XAMPP to send mail from localhost using PHP ?

15 Jul, 2019
To configure XAMPP server to send mail from localhost we have to make changes to two files sendmail.ini and php.ini. Open the xampp folder. By the name of “sendmail.ini” is present in sendmail file and “php.ini” is present in php file in the xampp folder.
Step 1:
Go to C:\xampp\sendmail: open sendmail.ini file in notepad or any text editor and make the changes as follows.change smtp_server=mail.yourdomain.com to smtp_server=smtp.gmail.com
change smtp_port to smtp_port=587
change smtp_ssl=auto to smtp_ssl=tlsuncomment ;error_logfile=error.log to error_logfile=error.log
uncomment ;debug_logfile=debug.log to debug_logfile=debug.log
write your gmail id in auth_username: auth_username=*****@gmail.com
write your gmail assword in auth_password: auth_password=*****write your gmail id in force_sender: *****@gmail.com
change hostname to hostname=localhost
change smtp_server=mail.yourdomain.com to smtp_server=smtp.gmail.com
change smtp_port to smtp_port=587
change smtp_ssl=auto to smtp_ssl=tls
uncomment ;error_logfile=error.log to error_logfile=error.log
uncomment ;debug_logfile=debug.log to debug_logfile=debug.log
write your gmail id in auth_username: auth_username=*****@gmail.com
write your gmail assword in auth_password: auth_password=*****
write your gmail id in force_sender: *****@gmail.com
change hostname to hostname=localhost
Step:2
Go to C:\xampp\php: open php.ini file in notepad or any text editor goto [mail function] part and make the changes as follows.comment SMTP=localhost by putting semicolon infront=>;SMTP=localhost
comment smtp_port=25 by putting semicolon infront=>;smtp_port=25
comment sendmail_from= by putting semicolon infront=>;sendmail_from=specify path of
 file in sendmail_path to sendmail_path=C:\xampp\sendmail\sendmail.exe

check if extension=php_openssl.dll is enabled=>If there is semicolon in front then
 un-comment it by removing that semicolon
After following the given steps if the mail is not sent by calling the mail function, then goto C:\xampp\sendmail open error.log to see thee error occurred.
comment SMTP=localhost by putting semicolon infront=>;SMTP=localhost
comment smtp_port=25 by putting semicolon infront=>;smtp_port=25
comment sendmail_from= by putting semicolon infront=>;sendmail_from=specify path of
 file in sendmail_path to sendmail_path=C:\xampp\sendmail\sendmail.exe

check if extension=php_openssl.dll is enabled=>If there is semicolon in front then
 un-comment it by removing that semicolon

After following the given steps if the mail is not sent by calling the mail function, then goto C:\xampp\sendmail open error.log to see thee error occurred.
Note: Here the procedure is shown for gmail, but it can be extended to other mails by changing the smtp server, port number. When using gmail take care to enable the option to allow access to less secure webapp.
Picked
Technical Scripter 2018
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scope Resolution Operator vs this pointer in C++

28 Nov, 2021
Scope resolution operator is for accessing static or class members and this pointer is for accessing object members when there is a local variable with the same name.
Consider below C++ program:  
CPP
// C++ program to show that local parameters hide// class members#include <iostream>using namespace std;  class Test {    int a;  public:    Test() { a = 1; }      // Local parameter 'a' hides class member 'a'    void func(int a) { cout << a; }};  // Driver Codeint main(){    Test obj;    int k = 3;    obj.func(k);    return 0;}
3
Explanation: The output for the above program is 3 since the “a” passed as an argument to the func shadows the “a” of the class .i.e 1 
Then how to output the class’s ‘a’. This is where this pointer comes in handy. A statement like cout <<this->a instead of cout << a can simply output the value 1 as this pointer points to the object from where func is called.
CPP
// C++ program to show use of this to access member when// there is a local variable with same name#include <iostream>using namespace std;class Test {    int a;  public:    Test() { a = 1; }      // Local parameter 'a' hides object's member    // 'a', but we can access it using this.    void func(int a) { cout << this->a; }};  // Driver codeint main(){    Test obj;    int k = 3;    obj.func(k);    return 0;}
1
How about Scope Resolution Operator? 
We cannot use the scope resolution operator in the above example to print the object’s member ‘a’ because the scope resolution operator can only be used for a static data member (or class members). If we use the scope resolution operator in the above program we get compiler error and if we use this pointer in the below program, then also we get a compiler error.
CPP
// C++ program to show that scope resolution operator can be// used to access static members when there is a local// variable with same name#include <iostream>using namespace std;  class Test {    static int a;  public:    // Local parameter 'a' hides class member    // 'a', but we can access it using ::    void func(int a) { cout << Test::a; }};  // In C++, static members must be explicitly defined// like thisint Test::a = 1;  // Driver codeint main(){    Test obj;    int k = 3;    obj.func(k);    return 0;}
1
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 review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Prateek Tamrakar
siva117
23620uday2021
anshikajain26
cpp-operator
cpp-pointer
C Language
C++
cpp-operator
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to convert the character values in an R data frame column to lower case?

The character values can be stored in uppercase, lowercase, or a mixture of the two. If we have values that are either in uppercase or the mixture of lower and upper then we can convert those character values to only lowercase by using tolower function. We simply need to pass the vector or column of the data frame inside the tolower function as shown in the below examples.
Consider the below data frame −
Live Demo
> x1<-sample(LETTERS[1:4],20,replace=TRUE)
> y1<-rnorm(20)
> df1<-data.frame(x1,y1)
> df1
   x1     y1
1  C  -0.1036851
2  C  -0.6176530
3  B   0.5763786
4  A   0.1943794
5  C   1.1196470
6  D  -1.4202033
7  A  -1.9147143
8  D  -1.6492836
9  B   0.2806705
10 D  -1.0246326
11 B  -0.1584948
12 A   0.8301300
13 C  -1.1100439
14 C   0.4864598
15 C   1.3461719
16 D  -2.3021691
17 D  -0.8527835
18 A  -0.0160726
19 A  -1.3944416
20 D   1.5769472
Changing the character values in x1 to lowercase −
> df1$x1<-tolower(df1$x1)
> df1
   x1    y1
1  c  -0.1036851
2  c  -0.6176530
3  b   0.5763786
4  a   0.1943794
5  c   1.1196470
6  d  -1.4202033
7  a  -1.9147143
8  d  -1.6492836
9  b   0.2806705
10 d  -1.0246326
11 b  -0.1584948
12 a   0.8301300
13 c  -1.1100439
14 c   0.4864598
15 c   1.3461719
16 d  -2.3021691
17 d  -0.8527835
18 a  -0.0160726
19 a  -1.3944416
20 d   1.5769472
Live Demo
> x2<-sample(LETTERS[1:10],20,replace=TRUE)
> y2<-rpois(20,5)
> df2<-data.frame(x2,y2)
> df2
   x2 y2
1  G  4
2  D  3
3  G  2
4  E  3
5  B  6
6  I  2
7  A  8
8  F  6
9  A  7
10 F  5
11 C  10
12 G  5
13 I  4
14 H  7
15 F  4
16 A  3
17 J  3
18 I  3
19 D  6
20 F  8
Changing the character values in x2 to lowercase −
> df2$x2<-tolower(df2$x2)
> df2
   x2 y2
1  g  4
2  d  3
3  g  2
4  e  3
5  b  6
6  i  2
7  a  8
8  f  6
9  a  7
10 f  5
11 c  10
12 g  5
13 i  4
14 h  7
15 f  4
16 a  3
17 j  3
18 i  3
19 d  6
20 f  8
Live Demo
> x3<-sample(LETTERS[1:2],20,replace=TRUE)
> y3<-runif(20,2,5)
> df3<-data.frame(x3,y3)
> df3
   x3   y3
1  A  2.144779
2  A  4.020497
3  A  4.152795
4  A  4.579962
5  A  4.151587
6  B  3.668675
7  B  3.918459
8  B  2.326660
9  B  4.826448
10 A  4.159623
11 B  4.966475
12 B  4.159850
13 B  4.478584
14 A  2.585765
15 B  3.661653
16 B  2.836051
17 B  3.947854
18 B  3.650995
19 A  3.333785
20 A  2.147321
Changing the character values in x3 to lowercase −
> df3$x3<-tolower(df3$x3)
> df3
   x3  y3
1  a  2.144779
2  a  4.020497
3  a  4.152795
4  a  4.579962
5  a  4.151587
6  b  3.668675
7  b  3.918459
8  b  2.326660
9  b  4.826448
10 a  4.159623
11 b  4.966475
12 b  4.159850
13 b  4.478584
14 a  2.585765
15 b  3.661653
16 b  2.836051
17 b  3.947854
18 b  3.650995
19 a  3.333785
20 a  2.147321
HTML - div Tag

The HTML <div> tag is used for defining a section of your document. With the div tag, you can group large sections of HTML elements together and format them with CSS.
The difference between the div tag and the span tag is that the div tag is used with blocklevel elements whilst the span tag is used with inline elements.
<!DOCTYPE html>
<html>

   <head>
      <title>HTML div Tag</title>
      <link rel = "stylesheet" href = "style2.css">
   </head>

   <body>
      <div id = "contentinfo">
         <p>Welcome to our website. We provide tutorials on various subjects.</p>
      </div>
   </body>

</html>
Here is the csss file style2.css
#contentinfo p { 
   line-height: 20px;
   margin: 30px;
   padding-bottom: 20px; 
   text-align: justify;
   width: 140px;
   color: red; 
}
This will produce the following result −
Welcome to our website. We provide tutorials on various subjects.
This tag supports all the global attributes described in HTML Attribute Reference
The HTML <div> tag also supports the following  additional attributes −
This tag supports all the event attributes described in HTML Events Reference

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Python os.close() Method

Python method close() closes the associated with file descriptor fd.
Following is the syntax for close() method −
os.close(fd);

fd − This is the file descriptor of the file.
fd − This is the file descriptor of the file.
This method does not return any value.
The following example shows the usage of close() method.
#!/usr/bin/python

import os, sys

# Open a file
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )

# Write one string
os.write(fd, "This is test")

# Close opened file
os.close( fd )

print "Closed the file successfully!!"
When we run above program, it produces following result −
Closed the file successfully!!


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Find sum of integers in a file which contains any characters - GeeksforGeeks

06 Sep, 2017
You are given a text file which contains any type of characters. You have to find the sum of integer values.
Examples:
Input : text.txt 
Let contents of test.txt be : 
:-,,$%^5313&^*1)(*(
464sz29>>///11!!!
(*HB%$#)(*0900

Output : 6727

Input : text1.txt 
Let contents of test.txt be : 
234***3r3r()
()(0)34

Output : 274

Steps :1. To open the file in only read mode we can use ifstream library2. Iterate through all rows of the file and find all integers3. If integer found then store it in temp variable because there is a chance that next character can be an integer4. Add temp value in final result if any character found except integers and set temp = 0 again5. If last element is an integer then we have to add temp after loop if it isn’t then the value of temp will already be zero. So sum will not affected.
// C++ implementation of given text file which// contains any type of characters. We have to// find the sum of integer value.#include <bits/stdc++.h>using namespace std;  // a function which return sum of all integers// find in input text fileint findSumOfIntegers(){    ifstream f; // to open the text file in read mode    f.open("text.txt");          int sum = 0, num = 0;      // One by one read strings from file. Note that    // f >> text works same as cin >> text.    string text;    while (f >> text) {          // Move in row and find all integers        for (int i = 0; text[i] != '\0'; i++) {              // Find value of current integer            if (isdigit(text[i]))                 num = 10 * num + (text[i] - '0');                          // If other character, add it to the            // result            else {                sum += num;                num = 0; // and now replace                         // previous number with 0            }        }    }    sum += num;    return sum;}  // Driver program to test above functionsint main(){    cout << findSumOfIntegers();    return 0;}
Output:
6727 (for Input 1)

This article is contributed by Harshit Agrawal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or 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-file-handling
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Operator Overloading in C++
Iterators in C++ STL
Polymorphism in C++
Friend class and function in C++
Sorting a vector in C++
Convert string to char array in C++
Inline Functions in C++
List in C++ Standard Template Library (STL)
new and delete operators in C++ for dynamic memory
std::string class in C++
VBA - For Each Loops

A For Each loop is used to execute a statement or a group of statements for each element in an array or collection.
A For Each loop is similar to For Loop; however, the loop is executed for each element in an array or group. Hence, the step counter won't exist in this type of loop. It is mostly used with arrays or used in context of the File system objects in order to operate recursively.
Following is the syntax of a For Each loop in VBA.
For Each element In Group
   [statement 1]
   [statement 2]
   ....
   [statement n]
   [Exit For]
   [statement 11]
   [statement 22]
Next

Private Sub Constant_demo_Click()  
   'fruits is an array
   fruits = Array("apple", "orange", "cherries")
   Dim fruitnames As Variant
 
   'iterating using For each loop.
   For Each Item In fruits
      fruitnames = fruitnames & Item & Chr(10)
   Next
   
   MsgBox fruitnames
End Sub
When the above code is executed, it prints all the fruit names with one item in each line.
apple
orange
cherries


    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
Adding multiple constraints in a single table - GeeksforGeeks

17 Dec, 2020
Prerequisite – SQL Constraints
We can create a table with more than one constraint in its columns. Following example shows how we can define different constraints on a table.
Adding constraints in Create command :
Sr_no is a Primary Key.
Branch_no is the foreign key referencing Branch table.
Company type will hold either of the values : ‘1C’, ’2C’, ’3C’
Syntax :
Create table Fd_master(Sr_no varchar2(10), 
Branch_no varchar2(10), account_no varchar2(20),
company_type varchar2(20), constraint pk primary key(Sr_no),  
constraint fk foreign key (Branch_no) references Branch,
constraint chk check(company_type in (‘1C’, ’2C’, ’3C’)));
Primary Key constraint –Sr_no in Fd_master where pk is userdefined name given to Primary key.Foreign Key constraint –Branch_no in Fd_master where fk is name of foreign key that references branch table.Check constraint –company_type in Fd_master where chk is name that will check the given values i.e ‘1C’, ‘2C’, ‘3C’
Primary Key constraint –Sr_no in Fd_master where pk is userdefined name given to Primary key.
Foreign Key constraint –Branch_no in Fd_master where fk is name of foreign key that references branch table.
Check constraint –company_type in Fd_master where chk is name that will check the given values i.e ‘1C’, ‘2C’, ‘3C’
Adding constraints in Alter command :Multiple columns level constraints can be added via alter command. It can be added in parent-child table in a serial order.
Constraint 1 (Default) :Create two tables –
Parent having default constraint on ID with the default value 1. Name given to constraint is DF_ParentTable.
Foreign table with ID column.
ID in both the table is made ‘NOT NULL’.
Syntax :
CREATE TABLE ParentTable (ID int not null constraint DF_ParentTable default (1), 
name varchar2(5));
CREATE TABLE ForeignTable (ID int not null, Col2 VARCHAR(5));
Constraint 2 (Check) :
ALTER TABLE ParentTable ADD CONSTRAINT CK_ParentTable_ID CHECK(ID<100);
Constraint 3 (Foreign Key) :Foreign Key
ALTER TABLE ParentTable 
ADD CONSTRAINT FK_parent_foreign FOREIGN KEY (ID) REFERENCES ForeignTable(ID);
DBMS-SQL
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?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
SQL | Subquery
SQL Query to Convert VARCHAR to INT
How to Write a SQL Query For a Specific Date Range and Date Time?
How to Select Data Between Two Dates and Times in SQL Server?
SQL - SELECT from Multiple Tables with MS SQL Server
SQL Query to Delete Duplicate Rows
Java constructor return a value but, what?

No. Java constructor cannot return a value. If required, just create a method which calls the required constructor and returns the required value. See the example below.
public class Tester {
   public Tester(){}
   public static Tester getInstance(){
      Tester tester = new Tester();
       return tester;
   }
}
How to find the sum based on a categorical variable in an R data frame?

Finding group-wise mean is a common thing but if we go for step-by-step analysis then sum of values are also required when we have a categorical variable in our data set. This can be easily done with the help of group_by and summarise_each function of dplyr package.
Consider the below data frame:
Live Demo
> Group<-sample(LETTERS[1:4],20,replace=TRUE)
> Salary<-sample(21000:50000,20)
> Emp<-data.frame(Group,Salary)
> Emp
Group Salary
1 D 28256
2 B 31092
3 A 23147
4 C 28209
5 B 37676
6 C 33374
7 D 44864
8 B 40152
9 A 25843
10 A 40946
11 D 23321
12 A 42854
13 C 36960
14 A 35285
15 B 44478
16 B 36173
17 C 35077
18 A 39319
19 D 49204
20 A 41597
Loading dplyr package:
> library(dplyr)
Finding the sum of salaries in each group:
> Emp %>% group_by(Group) %>% summarise_each(funs(sum))
# A tibble: 4 x 2
Group Salary
1 A 248991
2 B 189571
3 C 133620
4 D 145645
Warning message:
`...` is not empty.
We detected these problematic arguments:
* `needs_dots`
These dots only exist to allow future extensions and should be empty.
Did you misspecify an argument?
Do not worry about the warning message here, it occurred due to the version of dplyr. Our output is correct. If you want to ignore this warning then we need to install the latest version of tibble from CRAN. We are showing this here because you are likely to face the same problem but not necessarily.
Let’s have a look at another example:
Live Demo
> x<-sample(c("India","USA","China","Canada"),20,replace=TRUE)
> y<-rpois(20,5)
> df<-data.frame(x,y)
> df
x y
1 India 5
2 India 3
3 India 4
4 China 5
5 Canada 3
6 USA 5
7 Canada 7
8 China 6
9 China 4
10 USA 7
11 China 5
12 India 8
13 Canada 3
14 India 6
15 Canada 5
16 Canada 3
17 Canada 7
18 USA 12
19 China 2
20 India 5
> df %>% group_by(x) %>% summarise_each(funs(sum))
# A tibble: 4 x 2
x y
1 Canada 28
2 China 22
3 India 31
4 USA 24
Warning message:
`...` is not empty.
We detected these problematic arguments:
* `needs_dots`
These dots only exist to allow future extensions and should be empty.
Did you misspecify an argument?
Pascal - Operators Precedence

Operator precedence determines the grouping of terms in an expression. This affects how an expression is evaluated. Certain operators have higher precedence than others; for example, the multiplication operator has higher precedence than the addition operator.
For example x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has higher precedence than +, so it first gets multiplied with 3*2 and then adds into 7.
Here, operators with the highest precedence appear at the top of the table, those with the lowest appear at the bottom. Within an expression, higher precedence operators will be evaluated first. The following table expresses the Pascal operator precedence −
Try the following example to understand the operator precedence available in Pascal −
program opPrecedence;
var
a, b, c, d : integer;
e: real;

begin
   a := 20;
   b := 10;
   c := 15;
   d := 5;
   e := (a + b) * c / d;      (* ( 30 * 15 ) / 5 *)
   writeln('Value of (a + b) * c / d is : ',  e:3:1 );

   e := ((a + b) * c) / d;    (* (30 * 15 ) / 5  *)
   writeln('Value of ((a + b) * c) / d is  : ' ,  e:3:1 );

   e := (a + b) * (c / d);   (*  (30) * (15/5)  *)
   writeln('Value of (a + b) * (c / d) is  : ',  e:3:1);

   e := a + (b * c) / d;     (*  20 + (150/5)  *)
   writeln('Value of a + (b * c) / d is  : ' ,  e:3:1 );
end.
When the above code is compiled and executed, it produces the following result:
Value of (a + b) * c / d is : 90.0
Value of ((a + b) * c) / d is  : 90.0
Value of (a + b) * (c / d) is  : 90.0
Value of a + (b * c) / d is  : 50.0


    94 Lectures 
     8.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
Align flex items at the end of the container with CSS

Use the justify-content property with value flex-end to align the flex-items at the end.
You can try to run the following code to implement the flex-end value −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         .mycontainer {
            display: flex;
            background-color: red;
            justify-content: flex-end;
         }
         .mycontainer > div {
            background-color: #E6B0AA;
            text-align: center;
            line-height: 60px;
            font-size: 30px;
            width: 100px;
            margin: 5px;
         }
      </style>
   </head>
   <body>
      <h1>Score</h1>
      <div class = "mycontainer">
         <div>20</div>
         <div>35</div>
         <div>88</div>
         <div>62</div>
      </div>
   </body>
</html>
QlikView - IntervalMatch

QlikView IntervalMatch is a powerful function used to match distinct numeric values to numeric intervals. It is useful in analyzing how the events actually happened versus the planned events. The example of a scenario where it is used is in the assembly lines of the production houses where the belts are planned to run at certain times and for certain duration. However, the actual run can happen at different points in time because of breakdown etc.
Consider an assembly line where there are three belts named A, B and C. They are planned to start & stop at specific times of a day. In a given day, we study the actual start and end time and analyze what all happened in that day. For this, we consider two sets of observations as shown below.
# Data Set for AssembilyLine.
StartTime,EndTime, BeltNo
00:05,4:20, A
1:50,2:45,B
3:15,10:30,C
	
# Data set for the events happened.
ActualTime,Product
1:10,Start Belt A
2:24,Stop Belt A
3:25,Restart Belt A
4:35,Stop Belt A
2:20,Start Belt B
3:11, Stop Belt B
3:15,Start Belt C
11:20, Stop Belt C
We open the script editor in a new QlikView document using Control+E. The following code creates the required tables as inline data. After creating this script, press control+R to reload the data into the QlikView document.
Let us create a Table Box sheet object to show the data generated by the IntervalMatch
function. Go to the menu item Layout → New Sheet Object → Table Box. The following window appears in which we mention the Title of the table and select the required fields to be displayed.
On clicking OK in the above window, a table appears showing the field ActualTime matched to the intervals StartTime and EndTime.

    70 Lectures 
     5 hours 

 Arthur Fong
 Print
 Add Notes
 Bookmark this page
Python - Filter Strings within ASCII range - GeeksforGeeks

12 Nov, 2020
Given ASCII or alphabetical range, filter strings found in particular range.
Input : test_list = [“gfg”, “is”, “best”, “for”, “geeks”], strt_asc, end_asc = 105, 115 Output : [‘is’] Explanation : i has 105, and s has 115, which is in range ASCII values.Input : test_list = [“gfg”, “is”, “best”, “for”, “geeks”], strt_asc, end_asc = 100, 115 Output : [‘gfg’, ‘is’, ‘for’, ‘geeks’] Explanation : Strings with range characters included.  
Method #1 : Using list comprehension + all() + ord()
In this, we check for all characters to be in given ASCII range, computed using ord(), and accordingly, strings are filtered.
Python3
# Python3 code to demonstrate working of# Filter Strings within ASCII range# Using list comprehension + ord() + all()  # initializing listtest_list = ["gfg", "is", "best", "for", "geeks"]  # printing original listprint("The original list is : " + str(test_list))  # initializing ASCII rangestrt_asc, end_asc = 105, 115  # checking for all characters to be in ASCII rangeres = [sub for sub in test_list if all(    ord(ele) >= strt_asc and ord(ele) <= end_asc for ele in sub)]  # printing resultprint("Filtered Strings : " + str(res))
The original list is : ['gfg', 'is', 'best', 'for', 'geeks']
Filtered Strings : ['is']

Method #2 : Using filter() + lambda + all() + ord()
In this, we perform task of filtering using filter() and lambda function, ord() and all() is used in similar way as above method.
Python3
# Python3 code to demonstrate working of# Filter Strings within ASCII range# Using filter() + lambda + all() + ord()  # initializing listtest_list = ["gfg", "is", "best", "for", "geeks"]  # printing original listprint("The original list is : " + str(test_list))  # initializing ASCII rangestrt_asc, end_asc = 105, 115  # checking for all characters to be in ASCII rangeres = list(filter(lambda sub: all(ord(ele) >= strt_asc and ord(    ele) <= end_asc for ele in sub), test_list))  # printing resultprint("Filtered Strings : " + str(res))
The original list is : ['gfg', 'is', 'best', 'for', 'geeks']
Filtered Strings : ['is']

Python list-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 ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Selecting rows in pandas DataFrame based on conditions
Check if element exists in list in Python
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
Operations on struct variables in C - GeeksforGeeks

16 Jan, 2019
In C, the only operation that can be applied to struct variables is assignment. Any other operation (e.g. equality check) is not allowed on struct variables.For example, program 1 works without any error and program 2 fails in compilation.
Program 1
#include <stdio.h>  struct Point {  int x;  int y;};  int main(){  struct Point p1 = {10, 20};  struct Point p2 = p1; // works: contents of p1 are copied to p2  printf(" p2.x = %d, p2.y = %d", p2.x, p2.y);  getchar();  return 0;}
Program 2
#include <stdio.h>  struct Point {  int x;  int y;};  int main(){  struct Point p1 = {10, 20};  struct Point p2 = p1; // works: contents of p1 are copied to p2  if (p1 == p2)  // compiler error: cannot do equality check for                           // whole structures  {    printf("p1 and p2 are same ");  }  getchar();  return 0;}
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Kaalan
C-Struct-Union-Enum
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
rand() and srand() in C/C++
fork() in C
Core Dump (Segmentation fault) in C/C++
Left Shift and Right Shift Operators in C/C++
Command line arguments in C/C++
Different methods to reverse a string in C/C++
Substring in C++
Function Pointer in C
TCP Server-Client implementation in C
Enumeration (or enum) in C
Go - Strings

Strings, which are widely used in Go programming, are a readonly slice of bytes. In the Go programming language, strings are slices. The Go platform provides various libraries to manipulate strings.
unicode
regexp
strings
The most direct way to create a string is to write −
var greeting = "Hello world!"

Whenever it encounters a string literal in your code, the compiler creates a string object with its value in this case, "Hello world!'.
A string literal holds a valid UTF-8 sequences called runes. A String holds arbitrary bytes.
package main

import "fmt"

func main() {
   var greeting =  "Hello world!"
   
   fmt.Printf("normal string: ")
   fmt.Printf("%s", greeting)
   fmt.Printf("\n")
   fmt.Printf("hex bytes: ")
   
   for i := 0; i < len(greeting); i++ {
       fmt.Printf("%x ", greeting[i])
   }
   
   fmt.Printf("\n")
   const sampleText = "\xbd\xb2\x3d\xbc\x20\xe2\x8c\x98" 
   
   /*q flag escapes unprintable characters, with + flag it escapses non-ascii 
   characters as well to make output unambigous */
   fmt.Printf("quoted string: ")
   fmt.Printf("%+q", sampleText)
   fmt.Printf("\n")  
}
This would produce the following result −
normal string: Hello world!
hex bytes: 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 
quoted string: "\xbd\xb2=\xbc \u2318"

Note − The string literal is immutable, so that once it is created a string literal cannot be changed.
len(str) method returns the number of bytes contained in the string literal.
package main

import "fmt"

func main() {
   var greeting =  "Hello world!"
   
   fmt.Printf("String Length is: ")
   fmt.Println(len(greeting))  
}
This would produce the following result −
String Length is : 12

The strings package includes a method join for concatenating multiple strings −
strings.Join(sample, " ")

Join concatenates the elements of an array to create a single string. Second parameter is seperator which is placed between element of the array.
Let us look at the following example −
package main

import ("fmt" "math" )"fmt" "strings")

func main() {
   greetings :=  []string{"Hello","world!"}   
   fmt.Println(strings.Join(greetings, " "))
}
This would produce the following result −
Hello world!


    64 Lectures 
     6.5 hours 

 Ridhi Arora

    20 Lectures 
     2.5 hours 

 Asif Hussain

    22 Lectures 
     4 hours 

 Dilip Padmanabhan

    48 Lectures 
     6 hours 

 Arnab Chakraborty

    7 Lectures 
     1 hours 

 Aditya Kulkarni

    44 Lectures 
     3 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
What is the difference between HTML tags <div> and <span>?

Both <div> and <span> is used to define parts of a web page. The <span> element shows the inline portion of a document. The <div> elements show a block-level portion of a document.
A div is a block-level element and a span is an inline element.
The div should be used to wrap sections of a document, while use spans to wrap small portions of text, images, etc.
Here’s an example:
<div>Demo Text, with <span>some other</span> text.</div>
The <div> element is used while creating CSS based layouts in html, whereas <span> element is used to stylize texts.
C/C++ Program to the Count Inversions in an array using Merge Sort?

The Count of inversions that take place to Sort the given array is known as inversion count. the inversion problem is a classical problem that can be solved using the merge sort Algorithm. in this problem v we will count all elements more than it to its left and add the count to output. ThisLogic is done inside merge function of merge sort.
For understanding the topic better let us take an example. Let us consider two sub-arrays involved in merge process -
 
 
Input: arr[] = { 1, 9, 6, 4, 5}
Output: Inversion count is 5
Inversion count of an array
Given an array, find the number of inversions of it. If (i < j) and (A[i] > A[j]) then the pair (i, j) is called an inversion of an array A. We need to count all such pairs in the arr
For example,
There are 5 inversions in the array
(9,6), (9,4), (9,5), (6,4), (6,5)
1. Compare the values of the element with each other.
2. Increment the counter if the value at lower index is higher.
3. Display the result.
#include <stdio.h>
int Merge(int arr[], int aux[], int low, int mid, int high) {
   int k = low, i = low, j = mid + 1;
   int inversionCount = 0;
   while (i <= mid && j <= high) {
      if (arr[i] <= arr[j]) {
         aux[k++] = arr[i++];
      } else {
         aux[k++] = arr[j++];
         inversionCount += (mid - i + 1); // NOTE
      }
   }
   while (i <= mid)
   aux[k++] = arr[i++];
   for (int i = low; i <= high; i++)
      arr[i] = aux[i];
   return inversionCount;
}
int MergeSort(int arr[], int aux[], int low, int high) {
   if (high == low) // if run size == 1
      return 0;
   int mid = (low + ((high - low) >> 1));
   int inversionCount = 0;
   inversionCount += MergeSort(arr, aux, low, mid);
   inversionCount += MergeSort(arr, aux, mid + 1, high);
   inversionCount += Merge(arr, aux, low, mid, high);
   return inversionCount;
}
int main() {
   int arr[] = { 1, 9, 6, 4, 5 };
   int N = 5;
   int aux[N];
   for (int i = 0; i < N; i++)
      aux[i] = arr[i];
   printf("Inversion count is %d", MergeSort(arr, aux, 0, N - 1));
   return 0;
}
Swing Examples - Show Warning message Dialog

Following example showcase how to show a warning message alert in swing based application.
We are using the following APIs.
JOptionPane − To create a standard dialog box.
JOptionPane − To create a standard dialog box.
JOptionPane.showMessageDialog() − To show the message alert.
JOptionPane.showMessageDialog() − To show the message alert.
JOptionPane.WARNING_MESSAGE − To mark the alert message as warning.
JOptionPane.WARNING_MESSAGE − To mark the alert message as warning.
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class SwingTester {
   public static void main(String[] args) {
      createWindow();
   }

   private static void createWindow() {    
      JFrame frame = new JFrame("Swing Tester");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      createUI(frame);
      frame.setSize(560, 200);      
      frame.setLocationRelativeTo(null);  
      frame.setVisible(true);
   }

   private static void createUI(final JFrame frame){  
      JPanel panel = new JPanel();
      LayoutManager layout = new FlowLayout();  
      panel.setLayout(layout);       
      JButton button = new JButton("Click Me!");
      button.addActionListener(new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(frame, "Please ensure compliance!",
               "Swing Tester", JOptionPane.WARNING_MESSAGE);
         }
      });

      panel.add(button);
      frame.getContentPane().add(panel, BorderLayout.CENTER);    
   }  
}
 Print
 Add Notes
 Bookmark this page