code-rag-bench/online-tutorials huggingface dataset:
HTML | <th> scope Attribute - GeeksforGeeks

26 Jun, 2019
The HTML <th> scope Attribute is used to specify the header cell is used for header row, column, colgroup or rowgroup. This attribute does not display any visual effect on the browser but it is used for screen readers.
Syntax:
<th scope="col | row | colgroup | rowgroup">
Attribute Values:
col: It specifies that the header cell is used for column.
row: It specifies that the header cell is used for row.
colgroup: It specifies that the header cell is used for group of column.
rowgroup: It specifies that the header cell is used for group of row.
Example:
<!DOCTYPE html><html>  <head>    <title>        HTML th scope Attribute    </title></head>  <body>    <h1>GeeksforGeeks</h1>      <h2>HTML th scope Attribute</h2>      <table border="1" width="500">        <tr>            <th scope="col">NAME</th>            <th scope="col">AGE</th>            <th scope="col">BRANCH</th>        </tr>          <tr>            <td>BITTU</td>            <td>22</td>            <td>CSE</td>        </tr>          <tr>            <td>RAKESH</td>            <td>25</td>            <td>EC</td>        </tr>    </table></body>  </html>
Output:
Supported Browsers: The browser supported by HTML <th> scope attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
Form validation using HTML and JavaScript
Types of CSS (Cascading Style Sheet)
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
How to calculate the number of days between two dates in javascript?
How to create a 100% stacked Area Chart with Matplotlib?

To create a 100% stacked Area Chart with Matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Set the figure size and adjust the padding between and around the subplots.
Create a list of years.
Create a list of years.
Make a dictionary, with list of population in respective years.
Make a dictionary, with list of population in respective years.
Create a figure and a set of subplots.
Create a figure and a set of subplots.
Draw a stacked Area Plot.
Draw a stacked Area Plot.
Place a legend on the figure, at the location ''upper left''.
Place a legend on the figure, at the location ''upper left''.
Set the title, xlabel and ylabel.
Set the title, xlabel and ylabel.
To display the figure, use show() method.
To display the figure, use show() method.
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

year = [1950, 1960, 1970, 1980, 1990, 2000, 2010, 2018]

population_by_continent = {
   'africa': [228, 284, 365, 477, 631, 814, 1044, 1275],
   'americas': [340, 425, 519, 619, 727, 840, 943, 1006],
   'asia': [1394, 1686, 2120, 2625, 3202, 3714, 4169, 4560],
   'europe': [220, 253, 276, 295, 310, 303, 294, 293],
   'oceania': [12, 15, 19, 22, 26, 31, 36, 39],
}

fig, ax = plt.subplots()
ax.stackplot(year, population_by_continent.values(), labels=population_by_continent.keys())

ax.legend(loc='upper left')
ax.set_title('World population')

ax.set_xlabel('Year')
ax.set_ylabel('Number of people (millions)')

plt.show()
What happens when a function is called before its declaration in C? - GeeksforGeeks

24 Dec, 2021
In C, if a function is called before its declaration, the compiler assumes the return type of the function as int.For example, the following program fails in the compilation.
C
#include <stdio.h>int main(void){    // Note that fun() is not declared    printf("%c\n", fun());    return 0;} char fun(){   return 'G';}
if the function char fun() in the above code is defined later to main() and the calling statement, then it will not compile successfully.  Because the compiler assumes the return type as “int” by default. And at declaration, if the return type is not matching with int then the compiler will give an error.
The following program compiles and run fine because function is defined before main().
C
#include <stdio.h> int fun(){   return 10;} int main(void){    // Note the function fun() is declared    printf("%d\n", fun());    return 0;}
What about parameters? compiler assumes nothing about parameters. Therefore, the compiler will not be able to perform compile-time checking of argument types and arity when the function is applied to some arguments. This can cause problems. For example, the following program compiled fine in GCC and produced garbage value as output. 
C
#include <stdio.h> int main (void){    printf("%d", sum(10, 5));    return 0;}int sum (int b, int c, int a){    return (a+b+c);}
There is this misconception that the compiler assumes input parameters also int. Had compiler assumed input parameters int, the above program would have failed in compilation.It is always recommended to declare a function before its use so that we don’t see any surprises when the program is run (See this for more details).Source: http://en.wikipedia.org/wiki/Function_prototype#UsesPlease write comments if you find anything incorrect, or you want to share more information about the topic discussed above
aanuj0110
azrielstephen
pss14
kaushalmistry2611
samybhai111
C-Functions
cpp-puzzle
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Multidimensional Arrays in C / C++
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++
Function Pointer in C
Substring in C++
Enumeration (or enum) in C
How to format JavaScript date into yyyy-mm-dd format?

To format a JavaScript date into “yyyy-mm-dd” format, use the toISOString() method. It converts using ISO standard i.e.
YYYY-MM-DDTHH:mm:ss.sss
You can try to run the following code to format a date.
 Live Demo
<html>
   <head>
      <title>JavaScript Dates</title>
   </head>
   <body>
      <script>
         var date, res;
         date = new Date();
         res = date.toISOString();
         document.write(res);
      </script>
   </body>
</html>
2018-12-15T08:13:47.648Z
Overlapping Elements with Z-Index using CSS

Using CSS Z-Index property developer can stack elements onto one another. Z-Index can have a positive or a negative value.
NOTE − If elements that overlap do not have z-index specified then that element will show up that is mentioned last in document.
Let’s see an example of z-index property − 
<!DOCTYPE html>
<html>
<head>
<style>
p {
   margin: 0;
   position: absolute;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
}
div{
   margin: auto;
   position: absolute;
   top:0;
   left: 0;
   right: 0;
   bottom: 0;
}
div:first-child {
   background-color: orange;
   width: 270px;
   height: 120px;
   z-index: -2;
}
div:last-child {
   width: 250px;
   height: 100px;
   z-index: -1;
   background-color: turquoise;
}
</style>
</head>
<body>
<div></div>
<p>Fortran was originally developed by a team at IBM in 1957 for scientific calculations...................</p>
<div>
</div>
</body>
</html>
Following is the output for the above code −
 Let’s see another example of z-index property − 
<!DOCTYPE html>
<html>
<head>
<style>
p {
   background: url("https://www.tutorialspoint.com/tensorflow/images/tensorflow-mini-logo.jpg");
   background-origin: content-box;
   background-repeat: no-repeat;
   background-size: cover;
   box-shadow: 0 0 3px black;
   padding: 20px;
   background-origin: border-box;
}
</style>
</head>
<h2>Demo</h2>
<body>
<p>This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text.</p>
</body>
</html>
Following is the output for the above code −
How to use $slice operator to get last element of array in MongoDB?

To get the last element of array in MongoDB, use the following syntax
db.yourCollectionName.find({},{yourArrayFieldName:{$slice:-1}});
Let us first create a collection with documents
>db.getLastElementOfArrayDemo.insertOne({"StudentName":"James","StudentMathScore":[78,68,98]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9d2d71a629b87623db1b2e")
}
>db.getLastElementOfArrayDemo.insertOne({"StudentName":"Chris","StudentMathScore":[88,56,34]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9d2d83a629b87623db1b2f")
}
>db.getLastElementOfArrayDemo.insertOne({"StudentName":"Larry","StudentMathScore":[99]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9d2d8ea629b87623db1b30")
}
>db.getLastElementOfArrayDemo.insertOne({"StudentName":"Robert","StudentMathScore":[90,78,67,66,75,73]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9d2dada629b87623db1b31")
}
Following is the query to display all documents from a collection with the help of find() method
> db.getLastElementOfArrayDemo.find().pretty();
This will produce the following output
{
   "_id" : ObjectId("5c9d2d71a629b87623db1b2e"),
   "StudentName" : "James",
   "StudentMathScore" : [
      78,
      68,
      98
   ]
}
{
   "_id" : ObjectId("5c9d2d83a629b87623db1b2f"),
   "StudentName" : "Chris",
   "StudentMathScore" : [
      88,
      56,
      34
   ]
}
{
   "_id" : ObjectId("5c9d2d8ea629b87623db1b30"),
   "StudentName" : "Larry",
   "StudentMathScore" : [
      99
   ]
}
{
   "_id" : ObjectId("5c9d2dada629b87623db1b31"),
   "StudentName" : "Robert",
   "StudentMathScore" : [
      90,
      78,
      67,
      66,
      75,
      73
   ]
}
Following is the query to get the last element of array in MongoDB
> db.getLastElementOfArrayDemo.find({},{StudentMathScore:{$slice:-1}});
This will produce the following output
{ "_id" : ObjectId("5c9d2d71a629b87623db1b2e"), "StudentName" : "James", "StudentMathScore" : [ 98 ] }
{ "_id" : ObjectId("5c9d2d83a629b87623db1b2f"), "StudentName" : "Chris", "StudentMathScore" : [ 34 ] }
{ "_id" : ObjectId("5c9d2d8ea629b87623db1b30"), "StudentName" : "Larry", "StudentMathScore" : [ 99 ] }
{ "_id" : ObjectId("5c9d2dada629b87623db1b31"), "StudentName" : "Robert",
"StudentMathScore" : [ 73 ] }
C/C++ Pointers vs Java references


In C, C++ programming languages, a pointer is a variable that holds the address of another variable.
#include <iostream>
using namespace std;
 
int main() {
   //int variable
   int i = 8;

   //pointer variable
   int * pI;

   //assign the address of i to its pointer
   pI = &amp;i;

   //print the number
   cout<<i<<endl;

   //print the address of the number
   cout<<pI<<endl;

   //print the value pointed by pointer
   count<<*pI<<endl;

   //change the value of variable using its pointer
   *pI = 10;

   //print the number
   cout<<i<<endl;
}
8
0x7fee1ae7bc94
8
10
In java programming languages, a reference is a variable that refers to an object and using which we can utilize the properties and functions of an object.
Live Demo
public class Tester {
   public static void main(String[] args) {
      Student student = new Student();        
      student.setName("Mahesh");
      System.out.println(student.getName());    
   }
}

class Student {
   String name;

   public String getName() {
      return name;
   }

   public void setName(String name) {
      this.name = name;
   }
}
Mahesh
Following are some of the differences between C/C++ Pointers and References.
No Pointer Arithmetic in Java. Pointers are memory addresses and a pointer points to a memory address of a variable. In C/C++, a pointer can be incremented/decremented to point to a new address but in Java, arithmetic operations on references are not allowed.
No Pointer Arithmetic in Java. Pointers are memory addresses and a pointer points to a memory address of a variable. In C/C++, a pointer can be incremented/decremented to point to a new address but in Java, arithmetic operations on references are not allowed.
No Pointer Manipulation in Java Although a reference internally uses a pointer but Java does not allow any manipulation to an underlying pointer using a reference variable. It makes java more secure and robust. A reference can refer to an object or be null only.
No Pointer Manipulation in Java Although a reference internally uses a pointer but Java does not allow any manipulation to an underlying pointer using a reference variable. It makes java more secure and robust. A reference can refer to an object or be null only.
No Casting of pointers in Java In C/C++, we can cast int* to char* but in Java, only related objects can be cast e.g. object of the same hierarchy.
No Casting of pointers in Java In C/C++, we can cast int* to char* but in Java, only related objects can be cast e.g. object of the same hierarchy.
Python Pandas - Insert a new index value at a specific position

To insert a new index value at a specific position, use the index.insert() method in Pandas. At first, import the required libraries -
import pandas as pd
Creating the Pandas index −
index = pd.Index(['Car','Bike','Airplane','Ship','Truck'])

Display the index −
print("Pandas Index...\n",index)
Insert a new value at a specific position using the insert() method. The first parameter in the insert() is the location where the new index value is placed. The 2 here means the new index value gets inserted at index 2 i.e. position 3. The second parameter is the new index value to be inserted.
print("\nAfter inserting a new index value...\n", index.insert(2, 'Suburban'))

Following is the code −
import pandas as pd

# Creating the Pandas index
index = pd.Index(['Car','Bike','Airplane','Ship','Truck'])

# Display the index
print("Pandas Index...\n",index)

# Return the dtype of the data
print("\nThe dtype object...\n",index.dtype)

# Insert a new value at a specific position using the insert() method
# The first parameter in the insert() is the location where the new index value is placed.
# The 2 here means the new index value gets inserted at index 2 i.e. position 3
# The second parameter is the new index value to be inserted.
print("\nAfter inserting a new index value...\n", index.insert(2, 'Suburban'))
This will produce the following output −
Pandas Index...
Index(['Car', 'Bike', 'Airplane', 'Ship', 'Truck'], dtype='object')

The dtype object...
object

After inserting a new index value...
Index(['Car', 'Bike', 'Suburban', 'Airplane', 'Ship', 'Truck'], dtype='object')
Write a C program to demonstrate post increment and pre increment operators

It is used to increment the value of a variable by 1. There are two types of increment operators, pre-increment and post-increment.
It is used to increment the value of a variable by 1. There are two types of increment operators, pre-increment and post-increment.
The increment operator is placed before the operand in pre-increment and the value is first incremented and then the operation is performed on it.
The increment operator is placed before the operand in pre-increment and the value is first incremented and then the operation is performed on it.
For example,
z = ++a; a= a+1
z=a
The increment operator is placed after the operand in post-increment and the value is incremented after the operation is performed.
The increment operator is placed after the operand in post-increment and the value is incremented after the operation is performed.
For example,
z = a++; z=a
a= a+1
Following is an example for pre-increment operator −
 Live Demo
main ( ){
   int A= 10, Z;
   Z= ++A;
   printf ("Z= %d", Z);
   printf (" A=%d", A);
}
Z =11
A=11
Following is an example for post-increment operator −
 Live Demo
main ( ){
   int a= 10, z;
   z= a++;
   printf ("Z= %d", z);
   printf ("A=%d", a);
}
Z=10
A=11
It is used to decrement the values of a variable by 1. There are two types of increment operators, pre decrement and post decrement.
It is used to decrement the values of a variable by 1. There are two types of increment operators, pre decrement and post decrement.
The decrement operator is placed before the operand in pre decrement and the value is first decremented and then the operation is performed on it.
The decrement operator is placed before the operand in pre decrement and the value is first decremented and then the operation is performed on it.
For example,
z = - - a; a= a-1
z=a
The decrement operator is placed after the operand in post decrement and the value is decremented after the operation is performed
The decrement operator is placed after the operand in post decrement and the value is decremented after the operation is performed
For example,
z = a--; z=a
a= a-1
Following is an example for pre decrement operator −
 Live Demo
main ( ){
   int a= 10, z;
   z= --a;
   printf ("Z= %d", z);
   printf (" A=%d", a);
}
Z=9
A=9
Following is an example for post decrement operator −
 Live Demo
main ( ){
   int a= 10, z;
   z= a--;
   printf ("Z= %d", z);
   printf ("A=%d", a);
}
Z=10
A=9
PHP $_GET

$_GET  is an associative array of variables passed to the current script via query string appended to URL of HTTP request. Note that the array is populated by all requests with a query string in addition to GET requests.
$HTTP_GET_VARS contains the same initial information, but has been deprecated
By default, client browser sends a request for URL on the server by HTTP GET method. A query string attached to URL may contain key=value pairs concatenated by & symbol. The $_GET associative array stores these key value pairs
Assuming that the URL in browser is http://localhost/testscript.php?name=xyz&age=20
<?php
echo "Name : " . $_GET["name"] . "<br>";
echo "Age : " . $_GET["age"];
?>
This will produce following result −
Name : xyz
Age : 20
In following example, htmlspecialchars() function is used to convert characters in HTML entities.
Assuming that the URL in browser is http://localhost/testscript.php?name=xyz&age=20
<?php
echo "Name: " . htmlspecialchars($_GET["name"]) . "<br>";
echo "age: " . htmlspecialchars($_GET["age"]) . "<br>";
?>
This will produce following result −
Name : xyz
Age : 20
RxJS - Utility Operator timeout

This operator will throw an error if the source Observable does not emit a value after the given timeout.
timeout(timeout: number | Date): Observable

timeout − The input to it is the timeout which can be of type number or Date within which the value from the source Observable must be emitted.
An observable is returned which will stop based on the timeout given.
import { of, interval } from 'rxjs';
import { filter, timeout } from 'rxjs/operators';
let list1 = interval(1000);
let final_val = list1.pipe(timeout(new Date("October 01, 2019 10:40:00")));
final_val.subscribe(
   x => console.log(x),
   e => console.log(e),
   () => console.log("Task complete")
);
The observable interval will go on and the timeout is given as new Date ("October 01, 2019 10:40:00"), so at that time the timeout will occur and it will throw an error as shown below.

    51 Lectures 
     4 hours 

 Daniel Stern
 Print
 Add Notes
 Bookmark this page
C# Program to find number of occurrence of a character in a String

Let’s say our string is −
String s = "mynameistomhanks";
Now create a new array and pass it a new method with the string declared above. This calculates the occurrence of characters in a string.
static void calculate(String s, int[] cal) {
   for (int i = 0; i < s.Length; i++)
   cal[s[i]]++;
}
Let us see the complete code.
 Live Demo
using System;
class Demo {
   static int maxCHARS = 256;
   static void calculate(String s, int[] cal) {
      for (int i = 0; i < s.Length; i++)
      cal[s[i]]++;
   }
   public static void Main() {
      String s = "mynameistomhanks";
      int[] cal = new int[maxCHARS];
      calculate(s, cal);
      for (int i = 0; i < maxCHARS; i++) {
         if (cal[i] > 1) {
            Console.WriteLine("Character " + (char) i);
            Console.WriteLine("Occurrence = " + cal[i] + " times");
         }
         if (cal[i] == 1) {
            Console.WriteLine("Character " + (char) i);
            Console.WriteLine("Occurrence = " + cal[i] + " time");
         }
      }
   }
}
Character a
Occurrence = 2 times
Character e
Occurrence = 1 time
Character h
Occurrence = 1 time
Character i
Occurrence = 1 time
Character k
Occurrence = 1 time
Character m
Occurrence = 3 times
Character n
Occurrence = 2 times
Character o
Occurrence = 1 time
Character s
Occurrence = 2 times
Character t
Occurrence = 1 time
Character y
Occurrence = 1 time
How to increment inside the update() function in MongoDB?

You can use $inc operator to increment. Let us first create a collection with documents −
> db.addInUpdateFunctionDemo.insertOne({"PlayerName":"Chris","PlayerScore":78});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd2b3f4345990cee87fd893")
}
> db.addInUpdateFunctionDemo.insertOne({"PlayerName":"Robert","PlayerScore":88});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd2b3fc345990cee87fd894")
}
> db.addInUpdateFunctionDemo.insertOne({"PlayerName":"David","PlayerScore":99});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd2b407345990cee87fd895")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.addInUpdateFunctionDemo.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5cd2b3f4345990cee87fd893"),
   "PlayerName" : "Chris",
   "PlayerScore" : 78
}
{
   "_id" : ObjectId("5cd2b3fc345990cee87fd894"),
   "PlayerName" : "Robert",
   "PlayerScore" : 88
}
{
   "_id" : ObjectId("5cd2b407345990cee87fd895"),
   "PlayerName" : "David",
   "PlayerScore" : 99
}
Following is the query to perform addition inside the update() function in MongDB −
> db.addInUpdateFunctionDemo.update({_id : ObjectId("5cd2b407345990cee87fd895")},{$inc: {PlayerScore: 201}});
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
Let us check all the documents once again −
> db.addInUpdateFunctionDemo.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5cd2b3f4345990cee87fd893"),
   "PlayerName" : "Chris",
   "PlayerScore" : 78
}
{
   "_id" : ObjectId("5cd2b3fc345990cee87fd894"),
   "PlayerName" : "Robert",
   "PlayerScore" : 88
}
{
   "_id" : ObjectId("5cd2b407345990cee87fd895"),
   "PlayerName" : "David",
   "PlayerScore" : 300
}
VBA - Do-Until Loops

A Do...Until loop is used when we want to repeat a set of statements as long as the condition is false. The condition may be checked at the beginning of the loop or at the end of loop.
Following is the syntax of a Do..Until loop in VBA.
Do Until condition
   [statement 1]
   [statement 2]
   ...
   [statement n]
   [Exit Do]
   [statement 1]
   [statement 2]
   ...
   [statement n]
Loop           

The following example uses Do...Until loop to check the condition at the beginning of the loop. The statements inside the loop are executed only if the condition is false. It exits out of the loop, when the condition becomes true.
Private Sub Constant_demo_Click() 
   i = 10
   Do Until i>15  'Condition is False.Hence loop will be executed
      i = i + 1
      msgbox ("The value of i is : " & i)
   Loop 
End Sub
When the above code is executed, it prints the following output in a message box.
The value of i is : 11

The value of i is : 12

The value of i is : 13

The value of i is : 14

The value of i is : 15

The value of i is : 16

There is also an alternate syntax for Do...Until loop which checks the condition at the end of the loop. The major difference between these two syntax is explained with the following example.
Do 
   [statement 1]
   [statement 2]
   ...
   [statement n]
   [Exit Do]
   [statement 1]
   [statement 2]
   ...
   [statement n]
Loop Until condition

The following example uses Do...Until loop to check the condition at the end of the loop. The statements inside the loop are executed at least once, even if the condition is True.
Private Sub Constant_demo_Click()  
   i = 10
   Do 
      i = i + 1
      msgbox "The value of i is : " & i
   Loop Until i<15 'Condition is True.Hence loop is executed once.
End Sub
When the above code is executed, it prints the following output in a message box.
The value of i is : 11


    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
Change input type value attribute in jQuery

Let’s say the following is our input type with value, “John Smith” −
<input type = 'text' value = 'John Smith' id = 'changeTheName' />
To change, use the attr() method −
$('#changeTheName').attr('value', 'Please enter your name.......');
You need to use the concept of attr(). Following is the code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>Document</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<input type = 'text' value = 'John Smith' id = 'changeTheName' />
<script>
   $('#changeTheName').attr('value', 'Please enter your name.......');
</script>
</body>
</html>
To run the above program, save the file name “anyName.html(index.html)” and right click on the
file. Select the option “Open with Live Server” in VS Code editor.
This will produce the following output −
Function call by value in Objective-C

The call by value method of passing arguments to a function copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.
By default, Objective-C programming language uses call by value method to pass arguments. In general, this means that code within a function cannot alter the arguments used to call the function. Consider the function swap() definition as follows −
/* function definition to swap the values */
- (void)swap:(int)num1 andNum2:(int)num2 {
   int temp;

   temp = num1;   /* save the value of num1 */
   num1 = num2;   /* put num2 into num1 */
   num2 = temp;   /* put temp into num2 */
  
   return;
}
Now, let us call the function swap() by passing actual values as in the following example −
#import <Foundation/Foundation.h>

@interface SampleClass:NSObject
/* method declaration */
- (void)swap:(int)num1 andNum2:(int)num2;
@end

@implementation SampleClass

- (void)swap:(int)num1 andNum2:(int)num2 {
   int temp;

   temp = num1;   /* save the value of num1 */
   num1 = num2;   /* put num2 into num1 */
   num2 = temp;   /* put temp into num2 */
   
}

@end

int main () {
   
   /* local variable definition */
   int a = 100;
   int b = 200;
   
   SampleClass *sampleClass = [[SampleClass alloc]init];

   NSLog(@"Before swap, value of a : %d\n", a );
   NSLog(@"Before swap, value of b : %d\n", b );
 
   /* calling a function to swap the values */
   [sampleClass swap:a andNum2:b];
 
   NSLog(@"After swap, value of a : %d\n", a );
   NSLog(@"After swap, value of b : %d\n", b );
 
   return 0;
}
Let us compile and execute it, it will produce the following result −
2013-09-09 12:12:42.011 demo[13488] Before swap, value of a : 100
2013-09-09 12:12:42.011 demo[13488] Before swap, value of b : 200
2013-09-09 12:12:42.011 demo[13488] After swap, value of a : 100
2013-09-09 12:12:42.011 demo[13488] After swap, value of b : 200

Which shows that there is no change in the values though they had been changed inside the function.

    18 Lectures 
     1 hours 

 PARTHA MAJUMDAR

    6 Lectures 
     25 mins

 Ken Burke
 Print
 Add Notes
 Bookmark this page
How to extract the last n characters from a string using Java?

To extract last n characters, simply print (length-n)th character to nth character using the charAt() method.
Live Demo
public class ExtractingCharactersFromStrings {
   public static void main(String args[]) {
   
      String str = "Hi welcome to tutorialspoint";
      int n = 5;
      int initial = str.length()-5;
      for(int i=initial; i<str.length(); i++) {
         System.out.println(str.charAt(i));
      }
   }
}
p
o
i
n
t
C library function - feof()

The C library function int feof(FILE *stream) tests the end-of-file indicator for the given stream.
Following is the declaration for feof() function.
int feof(FILE *stream)
stream − This is the pointer to a FILE object that identifies the stream.
stream − This is the pointer to a FILE object that identifies the stream.
This function returns a non-zero value when End-of-File indicator associated with the stream is set, else zero is returned.
The following example shows the usage of feof() function.
#include <stdio.h>

int main () {
   FILE *fp;
   int c;
  
   fp = fopen("file.txt","r");
   if(fp == NULL) {
      perror("Error in opening file");
      return(-1);
   }
   
   while(1) {
      c = fgetc(fp);
      if( feof(fp) ) { 
         break ;
      }
      printf("%c", c);
   }
   fclose(fp);
   
   return(0);
}
Assuming we have a text file file.txt, which has the following content. This file will be used as an input for our example program −
This is tutorialspoint.com

Let us compile and run the above program, this will produce the following result −
This is tutorialspoint.com


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
What is pointer operator & in C++?

C++ provides two pointer operators, which are Address of Operator (&) and Indirection Operator (*). A pointer is a variable that contains the address of another variable or you can say that a variable that contains the address of another variable is said to "point to" the other variable. A variable can be any data type including an object, structure or again pointer itself.
The address of Operator (&), and it is the complement of *. It is a unary operator that returns the address of the variable(r-value) specified by its operand. For example,
#include <iostream>
using namespace std;
int main () {
   int  var;
   int  *ptr;
   int  val;
   var = 3000;
   ptr = &var;     // take the address of var
   val = *ptr;     // take the value available at ptr
   cout << "Value of var :" << var << endl;
   cout << "Value of ptr :" << ptr << endl;
   cout << "Value of val :" << val << endl;
   return 0;
}
When the above code is compiled and executed, it produces the following result −
Value of var : 3000
Value of ptr : 0xbff64494
Value of val : 3000
Apostrophe replacement in MySQL query?

To replace apostrophe, you can use replace(). Following is the syntax −
update yourTableName set yourColumnName=replace(yourColumnName,'\'','');
Let us first create a table −
mysql> create table DemoTable
   (
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   Sentence varchar(100)
   );
Query OK, 0 rows affected (0.17 sec)
Insert some records in the table using insert command. Apostrophe is added for the sentence −
mysql> insert into DemoTable(Sentence) values('Chris\'s Father');
Query OK, 1 row affected (0.07 sec)

mysql> insert into DemoTable(Sentence) values('Larry\'s Mother');
Query OK, 1 row affected (0.06 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----+----------------+
| Id | Sentence       |
+----+----------------+
| 1  | Chris's Father |
| 2  | Larry's Mother |
+----+----------------+
2 rows in set (0.00 sec)
Following is the query to replace apostrophe −
mysql> update DemoTable set Sentence=replace(Sentence,'\'','');
Query OK, 2 rows affected (0.07 sec)
Rows matched: 2 Changed: 2 Warnings: 0
Let us display records from the table to check apostrophe have been replaced or not.
mysql> select *from DemoTable;
This will produce the following output −
+----+---------------+
| Id | Sentence      |
+----+---------------+
| 1  | Chriss Father |
| 2  | Larrys Mother |
+----+---------------+
2 rows in set (0.00 sec)
Difference between var and let in JavaScript

As we know in order to declare a variable in javascript we have two options either declare with var or declare with let. Now the question is when to use var and when to use let i.e what are the major difference between both.
In the following text we come to know the major difference between var and let in javascript.
The main difference between let and var is that scope of a variable defined with let is limited to the block in which it is declared while variable declared with var has the global scope. So we can say that var is rather a keyword which defines a variable globally regardless of block scope.
The scope of let not only limited to the block in which it is defined but variable with let also do not get added with global window object even if it get declared outside of any block. But we can access variable with var from window object if it is defined globally.
Due to limited scope let variables are usually used when there is limited use of those variables such as in for loops, while loops or inside the scope of if conditions etc while var variable is used when value of variable need to be less change and used to accessed globally.
Also, one difference between var and let is variable with var can be redeclared to some other value while variable could not be redeclared if it is defined with let.
let a = 'hello'; // globally scoped
var b = 'world'; // globally scoped
console.log(window.a); // undefined
console.log(window.b); // 'world'
var a = 'hello';
var a = 'world'; // No problem, 'hello' is replaced.
let b = 'hello';
let b = 'world'; // SyntaxError: Identifier 'b' has already been declared
CSS | block-size Property - GeeksforGeeks

21 May, 2021
The block-size property in CSS is used to define the horizontal or vertical size of an element’s block. It coincides with the width or the height property, depending on the value of the writing-mode property. it leaves the space below are left of the element text.Syntax:  
block-size: length|percentage|auto|inherit|initial|unset
Property values:  
length: It sets a fixed value defined in px, cm, pt etc. Negative values are allowed. Its default value is 0px.
percentage: It is same as length but it sets in terms of percentage of the window size.
auto: It is used when it is desired that the browser determines the block-size.
initial: It is used to set the value of the block-size property to its default value.
inherit: It is used when it is desired that the element inherit theblock-size property of its parent as its own.
unset: It is used unset the default block-size.
Below examples illustrate the block-size property in CSS:Example 1:  
html
<!DOCTYPE html><html> <head>    <title>CSS | block-size Property</title>    <style>        h1 {            color: green;        }                 .geek {            background-color: yellow;            block-size: 40%;            writing-mode: vertical-rl;        }    </style></head> <body>    <center>        <h1>Geeksforgeeks</h1>        <b>CSS | block-size Property</b>        <br><br>        <div>            <b class="geek">GeeksforGeeks</b>        </div>    </center></body> </html>
Output:  
Example 2:  
html
<!DOCTYPE html><html> <head>    <title>CSS | block-size Property</title>    <style>        h1 {            color: green;        }                 p.geek {                width: 200px;                height: 200px;                border: 1px solid black;                writing-mode: horizontal-tb;                color: white;                background: green;                block-size: 250px;             }    </style></head> <body>    <center>        <h1>Geeksforgeeks</h1>        <b>CSS | block-size Property</b>        <br><br>        <div>            <p class="geek">GeeksforGeeks</p>         </div>    </center></body> </html>                   
Output:  
Supported Browsers: The browsers supported by block-size property are listed below:  
Google Chrome
Edge
Mozilla Firefox
Opera
Safari
 
sumitgumber28
CSS-Properties
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Design a web page using HTML and CSS
Form validation using jQuery
How to set space between the flexbox ?
Search Bar using HTML, CSS and JavaScript
How to Create Time-Table schedule using HTML ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
p5.js | rect() Function

23 Aug, 2021
The rect() function is an inbuilt function in p5.js which is used to draw the rectangle on the screen. A rectangle contains four sides and four angles. Each angle of the rectangle is 90 degree. The length of the opposite sides of rectangles are equal.  
Syntax:  
rect( x, y, w, h, tl, tr, br, bl )
or  
rect( x, y, w, h, detailX, detailY ) 
Parameters: This function accepts many parameters as mentioned above and described below: 
x: It is used to set the x-coordinate of rectangle.
y: It is used to set the y-coordinate of rectangle.
w: It is used to set the width of rectangle.
h: It is used to set the height of rectangle.
tl: It is optional parameter and used to set the radius of top-left corner.
tr: It is optional parameter and used to set the radius of top-right corner.
br: It is optional parameter and used to set the radius of bottom-right corner.
bl: It is optional parameter and used to set the radius of bottom-left corner.
detailX: It is used to set the number of segment in x-direction.
detailY: It is used to set the number of segment in y-direction.
Example 1: 
javascript
function setup() {          // Create Canvas of given size    createCanvas(400, 300);  }  function draw() {          background(220);          // Use color() function    let c = color('green');      // Use fill() function to fill color    fill(c);        // Draw a rectangle    rect(50, 50, 300, 200);    }
Output:  
Example 2: 
javascript
function setup() {          // Create Canvas of given size    createCanvas(400, 300);  }  function draw() {          background(220);          // Use color() function    let c = color('green');      // Use fill() function to fill color    fill(c);        // Draw a rectangle    rect(50, 50, 300, 200, 30);    }
Output:  
Example 3: 
javascript
function setup() {          // Create Canvas of given size    createCanvas(400, 300);  }  function draw() {          background(220);          // Use color() function    let c = color('green');      // Use fill() function to fill color    fill(c);        // Draw a rectangle    rect(50, 50, 300, 200, 10, 20, 30, 40);    }
Output:  
Online editor: https://editor.p5js.org/ Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/Reference: https://p5js.org/reference/#/p5/rect
sagar0719kumar
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
How to get character array from string in JavaScript?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Difference between window.onload and body.onload

10 Feb, 2021
There is a slight difference between the windows onload and the body onload, but before approaching the differences between them first we required the knowledge of what are those onloads. After, that we will know the usage in different scenarios of those where we will notice the slight differences between them.
onloads: The onloads event is fired when an object is fully loaded, there are two types of onload event one is windows onload and body onload.
Windows onload: This window’s onload event fires at the start.Body onload: This body onload event fires once all content is downloaded, if we want to find an element and update the style or content, then, body onload is the right choice to use.
Windows onload: This window’s onload event fires at the start.
Body onload: This body onload event fires once all content is downloaded, if we want to find an element and update the style or content, then, body onload is the right choice to use.
Note: If update the style and content do not bother you then it does not matter which onload you are using.
The below example illustrates the differences between windows onload and body onload:
HTML
<!DOCTYPE html><html>   <head>   </head>   <body onload="bodyLoad()">      <div id="B1">         <h1 style="color: green;">GeeksforGeeks</h1>           <p>A Computer Science Portal for Geeks</p>        </div>      <script>                  // Body onload         function bodyLoad() {             alert("Alert from body_onload");             alert("content from d1: "                   + document.getElementById("d1").innerText);         }                    // Window onload          function winLoad() {             alert("Alert from window_onload");             if (document.getElementById("B1") != null) {                 alert("Content from body: "                       + document.getElementById("B1").innerText);             }             else {                 alert("Failed to find B1");             }         }         window.onload = winLoad();      </script>   </body></html>
Output:
Window onload:
Body onload:
JavaScript-Questions
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
JavaScript | Promises
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
PYTHONPATH Environment Variable in Python

05 Sep, 2020
Python’s behavior is greatly influenced by its environment variables. One of those variables is PYTHONPATH. It is used to set the path for the user-defined modules so that it can be directly imported into a Python program. It is also responsible for handling the default search path for Python Modules. The PYTHONPATH variable holds a string with the name of various directories that need to be added to the sys.path directory list by Python. The primary use of this variable is to allow users to import modules that are not made installable yet. Let’s try to understand the concept using an example.
Suppose you defined a module as below:
Python3
# user-defined module# saved as my_module.py    def module_func():    print("You just imported the user-defined module")
Now if you attempt to import the_my_module.py in your python script as below:
Python3
# python script to# call the module  # import the moduleimport my_module  # call the module functionmy_module.module_func()
This will lead to the following error:
This is due to the reason that PYTHONPATH is not set yet. In simpler words, the Python interpreter cannot find the location of my_module.py file. So to set PYTHONPATH on a windows machine follow the below steps:
Step 1: Open your This PC (or My Computer) and write click and click on properties.
Step 2: After the properties window pop up click on to Advance System Settings:
Step 3: Now click on the environment variable button in the new popped up window as shown below:
Step 4: Now in the new Environment Variable dialog box click on New as shown below:
Step 5: Now in the variable dialog box add the name of the variable as PYTHONPATH and in value add the location to the module directory that you want python to check every time as shown below:
Step 6: Now open your command prompt and execute the my_script.py file with the below command:
python my_script.py

The behavior of python is set now so it should have no problem executing the python script by importing the my_module.py as shown below:
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Deploy a Basic Static HTML Website to Heroku?

08 Jul, 2022
Heroku is a simple and one-stop solution to host any website or server. This article revolves around how you can host your own Static HTML webpage on Heroku. To demonstrate this we are going to build a simple webpage and host it.
Git
Heroku Account
Heroku CLI
Let’s create a directory named “portfolio” for our project. We will connect this directory to our Heroku app so that whenever we update the local HTML file, changes reflect on the hosted website.
Create a directory with the name “portfolio” and change the working directory to it.
$ mkdir portfolio
$ cd portfolio

Create your own static HTML website and name it “home.html” (We are going to create a simple file with just “My portfolio” as text)
$ echo "<h1> My Portfolio </h1>" > home.html 

Heroku by default does not allow you to deploy an application that does not have a backend. So we need to create a dummy backend or dynamic PHP file. We need to use a trick and tell Heroku that our website is a PHP application. To do this simply copy and paste the following commands in your terminal. composer.json has been included to provide support for PHP application on Heroku. If an app has no composer dependencies, we must include empty composer.json  to recognize the PHP application.
$ echo '<?php include_once("home.html"); ?>' > index.php
$ echo '{}' > composer.json

Initialize the repository as a git repository.
$ git init

Create your Heroku app using the new button on the top right side of Heroku dashboard. We are going to name this app as “your-app-name-123′′
Login to your Heroku account using the Heroku CLI
$ heroku login

Now that we have created our app, we just need to connect the local git repository to the Heroku app. To do this we add the remote of the Heroku app to the git repository. (Don’t forget to replace “your-app-name-123” with your own app name)
$ heroku git:remote -a your-app-name-123

Push the changes to your Heroku app.
$ git push heroku master

Your app is now live on Heroku. To view your app, click on the link that appears at the end of the previous step, which looks like https://your-app-name-123.herokuapp.com/ . To commit and save all the changes to your home.html file, execute the following commands from your “portfolio” directory.
$ git add . 
$ git commit -m "your commit message" 
$ git push heroku master

Heroku Cloud
Git
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Git - Difference Between Git Fetch and Git Pull
How to Set Upstream Branch on Git?
How to Push Git Branch to Remote?
How to Export Eclipse projects to GitHub?
Merge Conflicts and How to handle them
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
REST API (Introduction)
Hide or show elements in HTML using display property