code-rag-bench/online-tutorials huggingface dataset:
Calendar getTimeInMillis() Method in Java with Examples - GeeksforGeeks

26 Jul, 2021
The getTimeInMillis() method in Calendar class is used to return the current time of this Calendar in Milliseconds.Syntax:  
public long getTimeInMillis()
Parameters: The method does not take any parameters.Return Value: The method returns the current time of this Calendar in millisecond.Below programs illustrate the working of getTimeInMillis() Method of Calendar class: Example 1: 
Java
// Java code to illustrate// getTimeInMillis() method import java.util.*; public class Calendar_Demo {     public static void main(String args[])        throws InterruptedException    {         // Creating a calendar        Calendar calndr1 = Calendar.getInstance();         // Displaying the current time        System.out.println("The Current Time"                           + " is: "                           + calndr1.getTimeInMillis());         // Adding few delay        Thread.sleep(10000);         // Creating another calendar        Calendar calndr2 = Calendar.getInstance();         // Displaying the upcoming time        System.out.println("The Upcoming Time"                           + " is: "                           + calndr2.getTimeInMillis());    }}
The Current Time is: 1550725664034
The Upcoming Time is: 1550725674053
 
Example 2:  
Java
// Java code to illustrate// getTimeInMillis() method import java.util.*; public class Calendar_Demo {     public static void main(String args[])        throws InterruptedException    {         // Creating a calendar        Calendar calndr1 = Calendar.getInstance();         // Displaying the current time        System.out.println("The Current Time"                           + " is: "                           + calndr1.getTimeInMillis());         // Adding few delay        Thread.sleep(5000);         // Creating another calendar        Calendar calndr2 = Calendar.getInstance();         // Displaying the upcoming time        System.out.println("The Upcoming Time"                           + " is: "                           + calndr2.getTimeInMillis());    }}
The Current Time is: 1550725683182
The Upcoming Time is: 1550725688208
 
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#getTimeInMillis– 
manikarora059
Java - util package
Java-Calendar
Java-Functions
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
Python | Extract digits from given string - GeeksforGeeks

08 Feb, 2022
While programming, sometimes, we just require a certain type of data and need to discard other. This type of problem is quite common in Data Science domain, and since Data Science uses Python worldwide, its important to know how to extract specific elements. This article discusses certain ways in which only digit can be extracted. Let’s discuss the same.Method #1 : Using join() + isdigit() + filter()This task can be performed using the combination of above functions. The filter function filters the digits detected by the isdigit function and join function performs the task of reconstruction of join function.  
Python3
# Python3 code to demonstrate# Extract digit string# using join() + isdigit() + filter() # initializing stringtest_string = 'g1eeks4geeks5' # printing original strings print("The original string : " + test_string) # using join() + isdigit() + filter()# Extract digit stringres = ''.join(filter(lambda i: i.isdigit(), test_string))     # print resultprint("The digits string is : " + str(res))
The original string : g1eeks4geeks5
The digits string is : 145
 
 Method #2 : Using re The regular expressions can also be used to perform this particular task. We can define the digit type requirement, using “\D”, and only digits are extracted from the string. 
Python3
# Python3 code to demonstrate# Extract digit string# using reimport re # initializing stringtest_string = 'g1eeks4geeks5' # printing original strings print("The original string : " + test_string) # using re# Extract digit stringres = re.sub("\D", "", test_string)     # print resultprint("The digits string is : " + str(res))
The original string : g1eeks4geeks5
The digits string is : 145
 
Method 3: Using loops:
This task is done by using for loop.
Python3
# Python3 code to demonstrate# Extract digit strings="g1eeks4geeks5"#using for loopfor i in s:  # using isdigit() function  if(i.isdigit()):    print(i,end="")
Output:
The original string : g1eeks4geeks5
The digits string is : 145
vaibhavkumar303
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Month getValue() method in Java - GeeksforGeeks

22 Mar, 2019
The getValue() method is a built-in method of the Month ENUM which is used to get the value of the month-of-year from this Month instance as an integer.
The value returned by this method is in the range of 1-12, representing months from January to December.
Syntax:
public int getValue()

Parameters: This method does not accepts any parameters.
Return Value: This method returns the value of month-of-year from this Month instance as an integer.
Below programs illustrate the above method:
Program 1:
import java.time.*;import java.time.Month;import java.time.temporal.ChronoField;  class monthEnum {    public static void main(String[] args)    {        // Create a month instance        Month month = Month.MARCH;          // Get the value of month-of-year as int        System.out.println(month.getValue());    }}
3

Program 2:
import java.time.*;import java.time.Month;import java.time.temporal.ChronoField;  class monthEnum {    public static void main(String[] args)    {        // Create a month instance        Month month = Month.DECEMBER;          // Get the value of month-of-year as int        System.out.println(month.getValue());    }}
12

Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Month.html#getValue–
Java-Functions
Java-Month
Java-time package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Interfaces in Java
Stream In Java
ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
Multithreading in Java
Collections in Java
Queue Interface In Java
LinkedList in Java
How to delete a property of an object in JavaScript?

To delete a property of an object, delete key word should be used. Delete key word can be used with both the methods such as Dot method and Bracket method.
delete object.property;
In the following example initially when the property "country" is executed its value "England" is displayed in the output. But when that property is deleted using delete keyword,instead of "England", undefined is displayed as shown in the output.
Live Demo
<html>
<body>
<script>
   var txt = "";
   var person = {
      "name":"Ram",
      "age":27,
      "address": {
         "houseno" : 123,
         "streetname" : "Baker street",
         "country": "England"
      }
   }
   document.write("Before deletion :" + " "+ person.address.country);
   delete person.address.country;
   document.write("</br>");
   document.write("After deletion :" + " "+ person.address.country);
</script>
</body>
</html>
Before deletion : England
After deletion : undefined
Java Program to sort Integer list in reversed order

Following is our integer array:
Integer[] arr = {20, 50, 100, 150, 200, 250, 300, 350, 400, 500};
Now convert the above Integer array to List:
List<Integer> list = new ArrayList<>(Arrays.asList(arr));
Now, to sort the above Integer list in reversed order:
Comparator<Integer> initialComp = Integer::compare;
Comparator<Integer> revComp = initialComp.reversed();
Collections.sort(list, revComp);
The following is an example to sort Integer list in reversed order:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class Demo {
   public static void main(String[] args) {
      Integer[] arr = {20, 50, 100, 150, 200, 250, 300, 350, 400, 500};
      List<Integer> list = new ArrayList<>(Arrays.asList(arr));
      System.out.println("Integer List = "+list);
      Comparator<Integer> initialComp = Integer::compare;
      Comparator<Integer> revComp = initialComp.reversed();
      Collections.sort(list, revComp);
      System.out.println("Integer in reversed order...");
      list
         .stream()
         .forEach(c -> System.out.print(c + "\n"));
   }
}
Integer List = [20, 50, 100, 150, 200, 250, 300, 350, 400, 500]
Integer in reversed order...
500
400
350
300
250
200
150
100
50
20
Delete alternate nodes of a Linked List in C++

In this tutorial, we are going to learn how to delete all prime nodes from a singly linked list.
Let's see the steps to solve the problem.
Write struct with data and next pointer.
Write struct with data and next pointer.
Write a function to insert the node into the singly linked list.
Write a function to insert the node into the singly linked list.
Initialize the singly linked list with dummy data.
Initialize the singly linked list with dummy data.
Iterate over the singly linked list.
Iterate over the singly linked list.
Delete alternate node by maintaining the previous node.
Delete alternate node by maintaining the previous node.
Write a function to delete the node. Consider the following three cases while deleting the node.If the node is head node, then move the head to next node.If the node is middle node, then link the next node to the previous nodeIf the node is end node, then remove the previous node link.
Let's see the code.
Write a function to delete the node. Consider the following three cases while deleting the node.
If the node is head node, then move the head to next node.
If the node is head node, then move the head to next node.
If the node is middle node, then link the next node to the previous node
If the node is middle node, then link the next node to the previous node
If the node is end node, then remove the previous node link.
Let's see the code.
If the node is end node, then remove the previous node link.
Let's see the code.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
struct Node {
   int data;
   Node *next;
};
void deleteAlternateNodes(Node *head) {
   if (head == NULL)
      return;
   Node *prev = head;
   Node *node = head->next;
   while (prev != NULL && node != NULL) {
      prev->next = node->next;
      free(node);
      prev = prev->next;
      if (prev != NULL) {
         node = prev->next;
      }
   }
}
void insertNode(Node** head_ref, int new_data) {
   Node* new_node = new Node();
   new_node->data = new_data;
   new_node->next = (*head_ref);
   (*head_ref) = new_node;
}
void printLinkedList(Node *node) {
   while (node != NULL) {
      cout << node->data << " -> ";
      node = node->next;
   }
}
int main() {
   Node* head = NULL;
   insertNode(&head, 1);
   insertNode(&head, 2);
   insertNode(&head, 3);
   insertNode(&head, 4);
   insertNode(&head, 5);
   insertNode(&head, 6);
   cout << "Linked List before deletion:" << endl;
   printLinkedList(head);
   deleteAlternateNodes(head);
   cout << "\nLinked List after deletion:" << endl;
   printLinkedList(head);
   return 0;
}
If you execute the above program, then you will get the following result.
Linked List before deletion:
6 -> 5 -> 4 -> 3 -> 2 -> 1 ->
Linked List after deletion:
6 -> 4 -> 2 ->
If you have any queries in the tutorial, mention them in the comment section.
Goto in Arduino

goto is a control structure in Arduino, like in C, and it is used to transfer the program flow to another point in the program. It is highly discouraged, as many programmers agree that you can write every algorithm you want without the use of goto.
Excessive use of goto makes it very difficult to debug programs, or, in some cases, creates program flows which are impossible to debug. It is assumed that you will read further only if you absolutely have to use goto.
The syntax for using goto is −
goto label;

label:
   //statements
The following example demonstrates this −
void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println();
   int x = random(5);

   Serial.print("Value of x is ");Serial.println(x);

   if (x % 2 == 0) {
      goto even_print;
   } else {
      goto odd_print;
   }

   Serial.println("End of setup");

   even_print:
      Serial.println("x is even");
   odd_print:
      Serial.println("x is odd");
}

void loop() {
   // put your main code here, to run repeatedly:
   Serial.println("Looping...");
   delay(1000);
}
The Serial Monitor output is shown below. Note that I reset the Arduino a couple of times to get different values of x.
See that when x is even, "x is odd" also gets printed, because the odd_print label follows the even_print label. So, the next print statement follows the first one. This shows that even_print and odd_print are just markers; they don’t stop program execution.
The goto statement just changes the program flow using labels, but after the statements of one label are executed, the program proceeds linearly and executes the next line (odd_print statements in this case).
Also, note that "End of setup" never gets printed. This is because both the goto statements make the program flow skip that line. This illustrates that the program won’t come back to the original line once the statements within the label are executed. It moves forward linearly unless, of course, it encounters another goto statement. This example would have given you an idea why use of goto is discouraged.
How to calculate the difference between neighboring elements in an array using NumPy - GeeksforGeeks

02 Sep, 2020
Let’s see how to calculate the difference between neighboring elements in an array using NumPy library.
So, We can find out the difference between neighboring elements using numpy.diff() function of NumPy library.
Syntax: numpy.diff(arr, n, axis)
Now, let’s see an example:
Example 1:
Python3
# import libraryimport numpy as np  # create a numpy 1d-arrayarr = np.array([1, 12, 3, 14, 5,              16, 7, 18, 9, 110])  # finding the difference between# neighboring elementsresult = np.diff(arr)  print(result)
Output:
[ 11  -9  11  -9  11  -9  11  -9 101]
Example 2:
Python3
# import libraryimport numpy as np  # create a numpy 2d-arrayarr = np.array([[10, 12, 14],                 [25, 35, 45],                [12, 18, 20]])  # finding the difference between# neighboring elements along rowresult = np.diff(arr, axis = 1)  print(result)
Output:
[[ 2  2]
[10 10]
[ 6  2]]
Example 3:
Python3
# import libraryimport numpy as np  # create a numpy 2d-arrayarr = np.array([[10, 12, 14],                 [25, 35, 45],                [12, 18, 20]])  # finding the difference between# neighboring elements along columnresult = np.diff(arr, axis = 0)  print(result)
Output:
[[ 15  23  31]
[-13 -17 -25]]
Python numpy-Mathematical Function
Python numpy-program
Python-numpy
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
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Python program to convert a list to string
Reading and Writing to text files in Python
std::basic_istream::getline in C++ with Examples - GeeksforGeeks

06 Jan, 2022
The std::basic_istream::getline is used to extract the characters from stream until end of line or the extracted character is the delimiting character. The delimiting character is the new line character i.e ‘\n’. This function will also stop extracting characters if the end-of-file is reached if input is taken using file.Header File: 
#include <iostream>
Syntax: 
basic_istream& getline (char_type* a, 
                            streamsize n )

basic_istream& getline (char_type* a, 
                            streamsize n, 
                             char_type delim);
Parameters: It accepts the following parameters:  
N: It represent maximum number of character pointed by a.
a: It is the pointer to string to store the characters.
stream: It is an explicit delimiting character.
Return Value: It returns the basic_istream object.Below are the program to demonstrate basic_istream::getline():Program 1: 
CPP
// C++ program to demonstrate// basic_istream::getline #include <iostream>using namespace std; // Driver Codeint main(){    // Given string    istringstream gfg("123|aef|5h");     // Array to store the above string    // after streaming    vector<array<char, 4> > v;     // Use function getline() to stream    // the given string with delimiter '|'    for (array<char, 4> a;         gfg.getline(&a[0], 4, '|');) {        v.push_back(a);    }     // Print the strings after streaming    for (auto& it : v) {        cout << &it[0] << endl;    }     return 0;}
123
aef
5h
 
Program 2: 
CPP
// C++ program to demonstrate// basic_istream::getline #include <iostream>using namespace std; // Driver Codeint main(){    // Given string    istringstream gfg("GeeksforGeeks, "                      " A, Computer, Science, "                      "Portal, For, Geeks");     // Array to store the above string    // after streaming    vector<array<char, 40> > v;     // Use function getline() to stream    // the given string with delimiter ', '    for (array<char, 40> a;         gfg.getline(&a[0], 40, ', ');) {        v.push_back(a);    }     // Print the strings after streaming    for (auto& it : v) {        cout << &it[0] << endl;    }     return 0;}
GeeksforGeeks
A
Computer
Science
Portal
For
Geeks
 
Reference: http://www.cplusplus.com/reference/istream/basic_istream/getline/
akshaysingh98088
adnanirshad158
CPP-Functions
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
Friend class and function in C++
Polymorphism in C++
Sorting a vector in C++
Convert string to char array in C++
List in C++ Standard Template Library (STL)
Inline Functions in C++
std::string class in C++
Destructors in C++
How to store a 2d Array in another 2d Array in java?

Create an array to which you want to store the existing array with the same length. A 2d array is an array of one dimensional arrays therefore, to copy (or, to perform any operation on) the elements of the 2d array you need two loops one nested within the other. Where, the outer loop is to traverse through the array of one dimensional arrays and, the inner loop is to traverse through the elements of a particular one dimensional array.
public class Copying2DArray {
   public static void main(String args[]) {
      int[][] myArray = {{41, 52, 63}, {74, 85, 96}, {93, 82, 71} };
      int[][] copyArray =new int[myArray.length][];
      for (int i = 0; i < copyArray.length; ++i) {
         copyArray[i] = new int[myArray[i].length];
         for (int j = 0; j < copyArray[i].length; ++j) {
            copyArray[i][j] = myArray[i][j];
         }
      }
      System.out.println(Arrays.deepToString(copyArray));
   }
}
[[41, 52, 63], [74, 85, 96], [93, 82, 71]]
PyQt5 QSpinBox - Checking if the character is UTF-32 format - GeeksforGeeks

26 May, 2020
In this article we will see how we can check if the given character in the font of the spin box is in UTF-32 format. UTF-32 is a fixed-length encoding used to encode Unicode code points that uses exactly 32 bits per code point. UTF-32 is a fixed-length encoding, in contrast to all other Unicode transformation formats, which are variable-length encodings.
In order to do this we use inFontUcs4 method with the spin box’s QFontMetrics object.
Syntax : font_metrics.inFontUcs4(unit_character)
Argument : It takes integer as argument
Return : It returns bool.
Below is the implementation
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()          # method for widgets    def UiComponents(self):        # creating spin box        self.spin = QSpinBox(self)          # setting geometry to spin box        self.spin.setGeometry(100, 100, 250, 40)          # setting range to the spin box        self.spin.setRange(0, 999999)          # setting prefix to spin        self.spin.setPrefix("PREFIX ")          # setting suffix to spin        self.spin.setSuffix(" SUFFIX")          # creating a label        label = QLabel(self)          # making label multi line        label.setWordWrap(True)          # setting geometry to the label        label.setGeometry(100, 200, 300, 60)          # getting font metrics        f_metrics = self.spin.fontMetrics()          # checking if the character is in the font        check = f_metrics.inFontUcs4(1)          # setting text to the label        label.setText(" UTF Format  : " + str(check))    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt-SpinBox
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
How to Install PIP on Windows ?
Read a file line by line in Python
Enumerate() in Python
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Create a Pandas DataFrame from Lists
Python String | replace()
Reading and Writing to text files in Python
Convert string to a number in Java

To convert a string to a number in Java, use the Integer.parseInt() method. First, let use create a String and set value.
String str = "45";
Now, take an Integer and use the Integer.parseInt() method.
Integer i = Integer.parseInt(str);
Let us see the complete example.
 Live Demo
public class Demo {
   public static void main( String args[] ) {
      String str = "45";
      Integer i = Integer.parseInt(str);
      System.out.println("Num: " + i);
   }
}
Num: 45
cout in C++ - GeeksforGeeks

27 Aug, 2021
The cout object in C++ is an object of class ostream. It is defined in iostream header file. It is used to display the output to the standard output device i.e. monitor. It is associated with the standard C output stream stdout. The data needed to be displayed on the screen is inserted in the standard output stream (cout) using the insertion operator(<<).
Program 1:
Below is the C++ program to implement cout object:
C++
// C++ program to illustrate the use// of cout object#include <iostream>using namespace std; // Driver Codeint main(){    // Print standard output    // on the screen    cout << "Welcome to GFG";     return 0;}
Welcome to GFG
 
Note: More than one variable can be printed using the insertion operator(<<) with cout.
Program 2:
Below is the C++ program to implement the above approach:
C++
// C++ program to illustrate printing// of more than one statement in a// single cout statement#include <iostream>using namespace std; // Driver Codeint main(){    string name = "Akshay";    int age = 18;     // Print multiple variable on    // screen using cout    cout << "Name : " << name << endl         << "Age : " << age << endl;     return 0;}
Name : Akshay
Age : 18
 
The cout statement can also be used with some member functions:
cout.write(char *str, int n): Print the first N character reading from str.
cout.put(char &ch): Print the character stored in character ch.
cout.precision(int n): Sets the decimal precision to N, when using float values.
Program 3:
Below is the implementation of the member functions of the cout.write() and cout.put():
C++
// C++ program to illustrate the use// of cout.write() and cout.put()#include <iostream>using namespace std; // Driver Codeint main(){    char gfg[] = "Welcome at GFG";    char ch = 'e';     // Print first 6 characters    cout.write(gfg, 6);     // Print the character ch    cout.put(ch);    return 0;}
Welcome
 
Program 4:
Below is the C++ program to illustrate the use of cout.precision():
C++
// C++ program toillustrate the use// of cout.precision()#include <iostream>using namespace std; // Driver Codeint main(){    double pi = 3.14159783;     // Set precision to 5    cout.precision(5);     // Print pi    cout << pi << endl;     // Set precision to 7    cout.precision(7);     // Print pi    cout << pi << endl;     return 0;}
3.1416
3.141598
 
Code_Mech
anikaseth98
cpp-input-output
Input and Output
Input Output Systems
Picked
C++
C++ Programs
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Iterators in C++ STL
Socket Programming in C/C++
Operator Overloading in C++
Constructors in C++
C++ Classes and Objects
Header files in C/C++ and its uses
C++ Program for QuickSort
How to return multiple values from a function in C or C++?
C++ program for hashing with chaining
cin in C++
Is finally block always get executed in Java?

Yes, the finally block is always get executed unless there is an abnormal program termination either resulting from a JVM crash or from a call to System.exit().
A finally block is always get executed whether the exception has occurred or not.
If an exception occurs like closing a file or DB connection, then the finally block is used to clean up the code.
We cannot say the finally block is always executes because sometimes if any statement like System.exit() or some similar code is written into try block then program will automatically terminate and the finally block will not be executed in this case.
A finally block will not execute due to other conditions like when JVM runs out of memory when our java process is killed forcefully from task manager or console when our machine shuts down due to power failure and deadlock condition in our try block.
public class FinallyBlock {
   public static void main(String args[]){
      try {
         int a=10,b=30;
         int c = b/a;
         System.out.println(c);
      } catch(ArithmeticException ae){
         System.out.println(ae);
      } finally {
         System.out.println("finally block is always executed");
      }
   }
}
In the above example, the finally block always get executed if the exception has occurred or not.
3
finally block is always executed
public class FinallyBlock {
   public static void main(String args[]) {
      try {
         System.out.println("I am in try block");
         System.exit(1);
      } catch(Exception ex){
         ex.printStackTrace();
      } finally {
         System.out.println("I am in finally block");
      }
   }
}
In the above example, the finally block will not execute due to the System.exit(1) condition in the try block.
I am in try block
How to print a one-month calendar of user choice using for loop in C?

The logic to print a one-month calendar is as follows −
for(i=1;i<first;i++)
   printf(" ");
for(i=1;i<=noofdays;i++){
   printf("%3d",i);
   if((first+i-1)%7==0)
      printf("\n");
}
 Live Demo
Following example accepts number of days and first day in a month from the user and prints the calendar of a month accordingly −
#include<stdio.h>
int main(){
   int i,noofdays;
   int first;
   printf("enter no of days in a month:\n");
   scanf("%d",&noofdays);
   printf("enter first day in a month:\n");
   scanf("%d",&first);
   for(i=1;i<first;i++)
      printf(" ");
   for(i=1;i<=noofdays;i++){
      printf("%3d",i);
      if((first+i-1)%7==0)
         printf("\n");
   }
   return 0;
}
enter no of days in a month:
30
enter first day in a month:
4
             1 2 3 4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
Converting string to MORSE code in JavaScript

Morse code is a method used in telecommunications to encode text characters as standardized sequences of two different signal durations, called dots and dashes.
To have a function that converts a particular string to Morse code, we will need an object that
maps all the characters (English alphabets) to Morse code equivalents. Once we have that we
can simply iterate over the string and construct a new string.
Here is the object that maps alphabets to Morse codes −
Morse Code Map
const morseCode = {
   "A": ".-",
   "B": "-...",
   "C": "-.-.",
   "D": "-..",
   "E": ".",
   "F": "..-.",
   "G": "--.",
   "H": "....",
   "I": "..",
   "J": ".---",
   "K": "-.-",
   "L": ".-..",
   "M": "--",
   "N": "-.",
   "O": "---",
   "P": ".--.",
   "Q": "--.-",
   "R": ".-.",
   "S": "...",
   "T": "-",
   "U": "..-",
   "W": ".--",
   "X": "-..-",
   "Y": "-.--",
   "Z": "--.."
}
Now the function that converts string to Morse code will be −
const morseCode = {
   "A": ".-",
   "B": "-...",
   "C": "-.-.",
   "D": "-..",
   "E": ".",
   "F": "..-.",
   "G": "--.",
   "H": "....",
   "I": "..",
   "J": ".---",
   "K": "-.-",
   "L": ".-..",
   "M": "--",
   "N": "-.",
   "O": "---",
   "P": ".--.",
   "Q": "--.-",
   "R": ".-.",
   "S": "...",
   "T": "-",
   "U": "..-",
   "W": ".--",
   "X": "-..-",
   "Y": "-.--",
   "Z": "--.."
}
const convertToMorse = (str) => {
   return str.toUpperCase().split("").map(el => {
      return morseCode[el] ? morseCode[el] : el;
   }).join("");
};
console.log(convertToMorse('Disaster management'));
console.log(convertToMorse('hey there!'));
The output in the console will be −
-........-...-..-. --.--..---..--.-.-
.....-.-- -......-..!
Windows Server 2012 R2 Stuck at "Updating Your System” - GeeksforGeeks

11 Dec, 2018
This tutorial describes an unusual problem that may occur during Windows Server 2012 R2 Updates. This issue generally occurs while performing scheduled Windows Updates. Failure of one single update may keep you stuck you at the screen that says Updating your system, but will not move a single inch, even after hours of waiting with no progress. To overcome this challenge you can follow one of the methods popular among the system administrators. Here, we will see one of them.
Troubleshooting:
1. Boot your server from Windows Server 2012 > click on Troubleshoot to enter in recovery mode console.
2. Run the following command to get a list of available drives:
wmic logicaldisk get name
3. The next step is to locate the drive that contains the windows directory. The easiest way to confirm is to check each drive for Windows directory by using “dir” command. Generally, Windows directory exists in the “C:” drive, however, if it’s located under different drive then simply replace “C:” with respective drive.
4. Navigate D:\Windows\WinSxS directory by using >> “cd Windows\Winsxs”
5. Check “pending.xml” file >> run “dir pending*” command
6. Now rename the “Pending” files to “_old” at the end of the file name >> enter “ren Pending.xml Pending_old.xml” command
7. Once you rename the “pending.xml” >> the next step is to create a new blank “Pending.xml” file by using: echo > pending.xml
8. Now navigate Windows directory
9. Create a new directory within Windows >> run “mkdir directoryname” where directory name can be a random choice by you. We will name the directory as scratch.
10. Use DISM (deployment image servicing and management) command. It will remove or revert all pending actions from the damaged image >> run below command:
DISM /Image: D:\ / Cleanup-Image / RevertPendingActions 
                          / scratchdir: D:\Windows\ scratch
11. Now rename the “SoftwareDistribution” folder to “SoftwareDistributionOLD” >> run below command:
Ren SoftwareDistribution SoftwareDistributionOLD
12. Run a system file checker tool to repair missing or corrupt kernel files by using the following command:
sfc /SCANNOW /OFFBOOTDIR=D:\  /OFFWINDIR=D:\Windows
13. Reboot the server
Note: If it is a virtual machine, make sure to take backup of “vhd” before making any changes on the server.
GBlog
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
DSA Sheet by Love Babbar
How to Start Learning DSA?
12 pip Commands For Python Developers
What is web socket and how it is different from the HTTP?
ML | Underfitting and Overfitting
How to Find the Wi-Fi Password Using CMD in Windows?
Docker - COPY Instruction
How to Run a Python Script using Docker?
Setting up the environment in Java
How to Add External JAR File to an IntelliJ IDEA Project?
How to merge data frames by row names in R?

Mostly, we merge the data frames by columns because column names are considered prominent in data sets but it is also possible to merge two data frames by using rows. Merging by rows is likely to result in more uncleaned data as compared to the merging by columns. This can be done with the help of merge function and its by argument.
Consider the below data frames −
df1<-data.frame(x1=rnorm(10),x2=rpois(10,5))
df1
   x1    x2
1  -0.47030794 0
2   0.86338465 8
3  -2.05770293 5
4   1.95479596 9
5  -0.06913421 5
6   0.64897263 5
7  -1.79859382 8
8   0.31247699 6
9  -0.36808285 7
10 -0.79578938 3
df2 <-data.frame(x1=rnorm(10,1.5))
df2
x1
1 -0.01317184
2  0.01687606
3 -0.71685289
4  1.75961121
5  2.49024285
6  2.92183374
7  0.10276216
8  1.39703966
9  1.41001339
10 0.98221783
df3 <-data.frame(x1=rnorm(5,0.5),x2=runif(5,2,3),x3=runif(5,2,5))
df3
      x1       x2       x3
1 -0.4926244 2.697937 3.961118
2  1.9863263 2.861944 3.659564
3 -0.2266537 2.383499 3.208741
4  0.5966503 2.511485 3.230795
5  0.7148641 2.362419 4.582841
Merging df1 with df2, df1 with df3, and df2 with df3 −
df_1_2 <-merge(df1,df2,by='row.names',all=TRUE)
df_1_2
Row.names x1.x x2 x1.y
1  1 -0.47030794 0 -0.01317184
2 10 -0.79578938 3  0.98221783
3  2 0.86338465  8  0.01687606
4  3 -2.05770293 5 -0.71685289
5  4 1.95479596  9  1.75961121
6  5 -0.06913421 5  2.49024285
7  6 0.64897263  5  2.92183374
8  7 -1.79859382 8  0.10276216
9  8 0.31247699  6  1.39703966
10 9 -0.36808285 7  1.41001339
df_1_3 <-merge(df1,df3,by='row.names',all=TRUE)
df_1_3
Row.names x1.x x2.x x1.y x2.y x3
1 1 -0.47030794 0 -0.4926244 2.697937 3.961118
2 10 -0.79578938 3 NA NA NA
3 2 0.86338465 8 1.9863263 2.861944 3.659564
4 3 -2.05770293 5 -0.2266537 2.383499 3.208741
5 4 1.95479596 9 0.5966503 2.511485 3.230795
6 5 -0.06913421 5 0.7148641 2.362419 4.582841
7 6 0.64897263 5 NA NA NA
8 7 -1.79859382 8 NA NA NA
9 8 0.31247699 6 NA NA NA
10 9 -0.36808285 7 NA NA NA
df_2_3 <-merge(df2,df3,by='row.names',all=TRUE)
df_2_3
Row.names x1.x x1.y x2 x3
1 1 -0.01317184 -0.4926244 2.697937 3.961118
2 10 0.98221783 NA NA NA
3 2 0.01687606 1.9863263 2.861944 3.659564
4 3 -0.71685289 -0.2266537 2.383499 3.208741
5 4 1.75961121 0.5966503 2.511485 3.230795
6 5 2.49024285 0.7148641 2.362419 4.582841
7 6 2.92183374 NA NA NA
8 7 0.10276216 NA NA NA
9 8 1.39703966 NA NA NA
10 9 1.41001339 NA NA NA
Display three letter-month value with SimpleDateFormat('MMM') in Java

Using the SimpleDateFormat(“MMM”) to display three-letter month −
Format f = new SimpleDateFormat("MMM");
String strMonth = f.format(new Date());
System.out.println("Month (Three-letter format) = "+strMonth);
Since, we have used the Format and SimpleDateFormat class above, therefore import the following packages. With that, we have also used the Date −
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
The following is an example −
 Live Demo
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
public class Demo {
   public static void main(String[] args) throws Exception {
      // displaying current date and time
      Calendar cal = Calendar.getInstance();
      SimpleDateFormat simpleformat = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");
      System.out.println("Today's date and time = "+simpleformat.format(cal.getTime()));
      // displaying date
      Format f = new SimpleDateFormat("dd/MMMM/yyyy");
      String strDate = f.format(new Date());
      System.out.println("Current Date = "+strDate);
      // displaying year
      f = new SimpleDateFormat("yyyy");
      String strYear = f.format(new Date());
      System.out.println("Year = "+strYear);
      // displaying three-letter month
      f = new SimpleDateFormat("MMM");
      String strMonth = f.format(new Date());
      System.out.println("Month (Three-letter format) = "+strMonth);
      // current time
      f = new SimpleDateFormat("HH.mm.ss Z");
      String strTime = f.format(new Date());
      System.out.println("Current Time = "+strTime);
      // displaying hour
      f = new SimpleDateFormat("H");
      String strHour = f.format(new Date());
      System.out.println("Current Hour = "+strHour);
      // displaying minutes
      f = new SimpleDateFormat("mm");
      String strMinute = f.format(new Date());
      System.out.println("Current Minutes = "+strMinute);
      // displaying seconds
      f = new SimpleDateFormat("ss");
      String strSeconds = f.format(new Date());
      System.out.println("Current Seconds = "+strSeconds);
   }
}
Today's date and time = Mon, 26 Nov 2018 09:29:58 +0000
Current Date = 26/November/2018
Year = 2018
Month (Three-letter format) = Nov
Current Time = 09.29.58 +0000
Current Hour = 9
Current Minutes = 29
Current Seconds = 58
Why is NullPointerException in Java?

NullPointerException is a runtime exception and it is thrown when the application try to use an object reference which has a null value.
For example, using a method on a null reference.
Object ref = null;
ref.toString(); // this will throw a NullPointerException
How to scroll automatically to the Bottom of the Page using jQuery?

03 Aug, 2021
To auto scroll a page from top to bottom we can use scrollTop() and height() method in jquery.In this method pass the document’s height in scrollTop method to scroll.
Example-1: Scroll without animation.
<!DOCTYPE html><html>  <head>    <title>Scroll Automatically</title>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>      <!-- jQuery code to show the working of this method -->    <script>        $(document).ready(function() {            $("button").click(function() {                $(document).scrollTop($(document).height());            });        });    </script>    <style>        h1 {            color: green;        }    </style></head>  <body>    <center>        <div>            <!-- click on this button              and see the change -->            <button>Click Here!</button>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>        </div>    </center></body>  </html>
Output:
Before:
After:
Example-2: Scroll with animation.
<!DOCTYPE html><html>  <head>    <title>Scroll Automatically</title>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>      <!-- jQuery code to show       the working of this method -->    <script>        $(document).ready(function() {            $("button").click(function() {                $("html, body").animate({                    scrollTop: $(                      'html, body').get(0).scrollHeight                }, 2000);            });        });    </script>    <style>        h1 {            color: green;        }    </style></head>  <body>    <center>        <div>            <!-- click on this button               and see the change -->            <button>Click Here!</button>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>            <h1>GeeksforGeeks</h1>        </div>    </center></body>  </html>
Output:
Before:
After:
jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous with it’s philosophy of “Write less, do more”.You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples.
jQuery-Misc
Picked
JQuery
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to get multiple rows in a single MySQL query?

Let us first create a table −
mysql> create table DemoTable
(
   Id int,
   Name varchar(100)
);
Query OK, 0 rows affected (0.60 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(100,'Chris');
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable values(110,'David');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values(120,'Robert');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable values(130,'Mike');
Query OK, 1 row affected (0.13 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+--------+
|   Id | Name   |
+------+--------+
|  100 | Chris  |
|  110 | David  |
|  120 | Robert |
|  130 | Mike   |
+------+--------+
4 rows in set (0.00 sec)
Following is the query to get multiple rows in a single MySQL query −
mysql> select *from DemoTable where Id IN(100,120,130):
This will produce the following output −
+------+--------+
|   Id | Name   |
+------+--------+
|  100 | Chris  |
|  120 | Robert |
|  130 | Mike   |
+------+--------+
3 rows in set (0.02 sec)
Difference Between Forward List and List in C++

08 Dec, 2021
Forward List is a sequence container that allows unidirectional sequential access to its data. It contains data of the same type. In STL, it has been implemented using Singly Linked List, which requires constant time for insertion and deletion. Elements of the forward list are scattered in the memory and the ordering is maintained by associating every element of the list by the next element of the list via a link. Thus, it makes efficient use of memory. It has been introduced from the C++11 version.
Implementation of Forward List: 
C++
// CPP Program to demonstrate forward list#include <bits/stdc++.h>using namespace std; // Driver Codeint main(){    // Declaring forward list    forward_list<int> flist1;     // Assigning values using assign()    flist1.assign({ 10, 12, 13, 15 });     // Displaying forward list    cout << "The elements of forward list are : ";    for (auto a : flist1)        cout << a << " ";    return 0;}
The elements of forward list are : 10 12 13 15
 
List is also a sequence container that allows bidirectional sequential access to its data. It contains data of the same type. In STL, it has been implemented using Doubly Linked List and it requires constant time for insertion and deletion. It allows non-contiguous memory allocation. Each element of the list is associated with a link to the element following it and preceding it. It is extensively used in sorting algorithm because of its constant insertion and deletion time and bidirectional sequential access.
Implementation of List:  
C++
// CPP Program to demonstrate list#include <bits/stdc++.h>using namespace std; // Driver Codeint main(){    // Declaring a list    list<int> list1;     // Assigning values using assign()    list1.assign({ 1, 2, 10, 15 });     // Displaying list    cout << "The elements of list are : ";    for (auto a : list1)        cout << a << " ";    return 0;}
The elements of list are : 1 2 10 15
 
Forward List
List
sooda367
anshikajain26
CPP-forward-list
cpp-list
C++
Difference Between
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
Pair in C++ Standard Template Library (STL)
Friend class and function in C++
std::string class in C++
Class method vs Static method in Python
Difference between BFS and DFS
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Differences between JDK, JRE and JVM
Python PIL | Image.thumbnail() Method

19 Jul, 2019
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images.
Image.thumbnail() Make this image into a thumbnail. This method modifies the image to contain a thumbnail version of itself, no larger than the given size. This method calculates an appropriate thumbnail size to preserve the aspect of the image, calls the draft() method to configure the file reader (where applicable), and finally resizes the image.
Note that this function modifies the Image object in place. If you need to use the full resolution image as well, apply this method to a copy() of the original image.
Syntax: Image.thumbnail(size, resample=3)
Parameters:size – Requested size.resample – Optional resampling filter.
Returns Type: An Image object.
Image Used:
     # importing Image class from PIL package from PIL import Image   # creating a object image = Image.open(r"C:\Users\System-Pc\Desktop\python.png")MAX_SIZE = (100, 100)  image.thumbnail(MAX_SIZE)  # creating thumbnailimage.save('pythonthumb.png')image.show()
Output:
Another Example:Here used another image.
Image Used:
     # importing Image class from PIL package from PIL import Image   # creating a object image = Image.open(r"C:\Users\System-Pc\Desktop\house.jpg")MAX_SIZE = (500, 500)  image.thumbnail(MAX_SIZE)  # creating thumbnailimage.save('pythonthumb2.jpg')image.show()
Output:
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.