code-rag-bench/online-tutorials huggingface dataset:
Macro & Preprocessor in C - GeeksQuiz

05 Nov, 2020
C
What is the output of the above program? 
3 
5 
3 or 5 depending on value of X 
Compile time error 
In the first look, the output seems to be compile-time error because macro X has not been defined. In C, if a macro is not defined, the pre-processor assigns 0 to it by default. Hence, the control goes to the conditional else part and 5 is printed. See the next question for better understanding. 
printf("Quiz");
int main()
{
        return 0;
}

#include 
#define X 3

int main()
{
#if !X
    printf("Geeks");
#else
    printf("Quiz");

#endif
    return 0;
}

#define square(x) ((x)*(x))  

int main() 
{ 
   int var12 = 100; 
   printf("%d", var12); 
   return 0; 
}
Which file is generated after pre-processing of a C program? 
.p 
.i 
.o 
.m 
After the pre-processing of a C program, a .i file is generated which is passed to the compiler for compilation.  
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Comments
Old Comments
Must Do Coding Questions for Product Based Companies
Microsoft Interview Experience for Internship (Via Engage)
Difference between var, let and const keywords in JavaScript
Find number of rectangles that can be formed from a given set of coordinates
Array of Objects in C++ with Examples
How to Replace Values in Column Based on Condition in Pandas?
C Program to read contents of Whole File
How to Replace Values in a List in Python?
How to Read Text Files with Pandas?
Infosys DSE Interview Experience | On-Campus 2021
Display a blue shadow on image hover with CSS

To display a shadow on image hover, use the CSS box-shadow property
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         img {
            border: 2px solid orange;
            border-radius: 3px;
            padding: 7px;
         }
         img:hover {
            box-shadow: 0 0 2px 2px blue;
         }
      </style>
   </head>
   <body>
      <img src = "https://www.tutorialspoint.com/videotutorials/images/coding_ground_home.jpg" alt="Online Compiler" width="300" height="300">
   </body>
</html>
How to make a resizable element in React JS

In this article, we will see how to make a resizable element in
React JS. We always create resizable textarea in HTML, but when it
comes to creating other elements resizable, it seems impossible. In
React, we can create resizable elements easily using a simple library.
First install the following package −
npm install --save re-resizable
re-resizable is used to import a resizable container which will be used to add Resizable functionality to any DOM element.
Add the following lines of code in App.js −
import React, { useState } from "react";
import { Resizable } from "re-resizable";
export default function App() {
   const [state, setState] = useState({ width: 320, height: 200 });
   return (
      <Resizable
         style={{ marginLeft: 500, marginTop: 200, border: "1px solid black" }}
         size={{ width: state.width, height: state.height }}
         onResizeStop={(e, direction, ref, d) => {
            setState({
               width: state.width + d.width, height: state.height + d.height,});
            }}>
         Sample with size
      </Resizable>
   );
}
Adding any element inside <Resizable> makes it resizable.
Adding any element inside <Resizable> makes it resizable.
The size attribute defines the size of the resizable component.
The size attribute defines the size of the resizable component.
onResizeStop defines what to do when the user tries to resize the element. Here we change width and height of the element in State which makes the required changes in the size attribute.
onResizeStop defines what to do when the user tries to resize the element. Here we change width and height of the element in State which makes the required changes in the size attribute.
Arguments like d.width and d.height define how much the width or height should increase or decrease.
Arguments like d.width and d.height define how much the width or height should increase or decrease.
On execution, it will produce the following output −
Your browser does not support HTML5 video.
How to find the size of a list in C#?

Declare and initialize a list.
var products = new List <string>();
products.Add("Accessories");
products.Add("Clothing");
products.Add("Footwear");
To get the size, use the Capacity property.
products.Capacity
Now let us see the complete code to find the size of a list.
 Live Demo
using System;
using System.Collections.Generic;
public class Demo {
   public static void Main(string[] args) {
      var products = new List <string>();
      products.Add("Accessories");
      products.Add("Clothing");
      products.Add("Footwear");
      Console.WriteLine("Our list....");
      foreach(var p in products) {
         Console.WriteLine(p);
      }
      Console.WriteLine("Size of list = " + products.Capacity);
   }
}
Our list....
Accessories
Clothing
Footwear
Size of list = 4
WAScan - web application security scanner in Kali Linux - GeeksforGeeks

23 Aug, 2021
WAScan stands for Web Application Scanner. It is an open-source web application vulnerability scanner. The tool uses the technique of black-box to find various vulnerabilities. This technique will not scan the whole source code of a web application but work like a fuzzer Which means it scans the pages of the whole website or web application. This tool extracts links and forms of the web application and scans one by one to find vulnerabilities. 
Wascan provides a powerful environment in which open source web-based reconnaissance can be conducted and you can gather all information about the target. This tool is written in python language you must have python language installed in your kali Linux operating system.
Step 1: Use the following command to install the tool in your kali Linux operating system.
git clone https://github.com/m4ll0k/WAScan.git wascan
Step 2: Now use the following command to move into the directory of the tool. You have to move in the directory in order to run the tool.
cd WAScan
Step 3: You are in the directory of the WAScan. Now you have to install a dependency of the WAScan using the following command.
pip install BeautifulSoup
Step 4: All the dependencies have been installed in your kali Linux operating system. Now use the following command to run the tool.
python wascan.py
The wascan tool has been downloaded and installed successfully. Now we will see examples to use the tool.
Example 1: Use the wascan to scan a domain for fingerprints/footprints.
python wascan.py --url <domain> --scan 0
Example 2: Use the wascan to scan a domain for attacks.
python wascan.py --url <domain> --scan 1
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
ZIP command in Linux with examples
tar command in Linux with examples
SORT command in Linux/Unix with examples
curl command in Linux with Examples
'crontab' in Linux with Examples
UDP Server-Client implementation in C
diff command in Linux with examples
Conditional Statements | Shell Script
Cat command in Linux with examples
Java Program to subtract 1 year from the calendar

Firstly, you need to import the following package for Calendar class in Java
import java.util.Calendar;
Create a Calendar object and display the current date and time
Calendar calendar = Calendar.getInstance();
System.out.println("Current Date and Time = " + calendar.getTime());
Now, let us subtract 1 year using the calendar.add() method and Calendar.YEAR constant. Set a negative value since we are decrementing here −
calendar.add(Calendar.YEAR, -1);
The following is an example
 Live Demo
import java.util.Calendar;
public class Demo {
   public static void main(String[] args) {
      Calendar calendar = Calendar.getInstance();
      System.out.println("Current Date = " + calendar.getTime());
      // Subtract 1 year from the Calendar
      calendar.add(Calendar.YEAR, -1);
      System.out.println("Updated Date = " + calendar.getTime());
   }
}
Current Date = Fri Nov 23 06:39:40 UTC 2018
Updated Date = Thu Nov 23 06:39:40 UTC 2017
Fetch all href link using selenium in python.

We can fetch href links in a page in Selenium by using the method find_elements(). All the links in the webpage are designed in a html document such that they are enclosed within the anchor tag.
To fetch all the elements having <anchor> tagname, we shall use the method find_elements_by_tag_name(). It will fetch a list of elements of anchor tag name as given in the method argument. If there is no matching tagname in the page, an empty list shall be returned.
Code Implementation.
from selenium import webdriver
driver = webdriver.Chrome (executable_path="C:\\chromedriver.exe")
driver.maximize_window()
driver.get("https://www.google.com/")
# identify elements with tagname <a>
lnks=driver.find_elements_by_tag_name("a")
# traverse list
for lnk in lnks:
   # get_attribute() to get all href
   print(lnk.get_attribute(href))
driver.quit()
How to get first N number of elements from an array using ReactJS? - GeeksforGeeks

18 Jan, 2021
We can use the slice() method to get the first N number of elements from an array.
Syntax:
array.slice(0, n);
Example:
var num = [1, 2, 3, 4, 5];
var myBest = num.slice(0, 3);
Output:
[1,2,3]
Note: The slice function on arrays returns a shallow copy of the array, and does not modify the original array. And if N is larger than the size of the array then it won’t through any error and returns the whole array itself.
Creating React Application:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Project Structure: It will look like the following.
Project Structure
App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import { React, Component } from "react";class App extends Component {    render() {    // Numbers list    const list = [1, 2, 3, 4, 5, 6, 7]      // Defining our N    var n = 4;      // Slice function call    var items = list.slice(0, n).map(i => {      return <button style={{ margin: 10 }}        type="button" class="btn btn-primary">{i}</button>    })      return (      <div>{items}</div>    )  }}  export default App
Note: You can apply your own styling to the application. Here we have used bootstrap CSS, to include it in your project, just add the following <link> to our index.html file.
<linkrel=”stylesheet”href=”https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css”integrity=”sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk”crossorigin=”anonymous”/>
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output:  Since the value of n is four, so four-button will be created. If increase the value of n the number of buttons will increase and vice-versa. 
Picked
JavaScript
ReactJS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
How to get character array from string in JavaScript?
How to get selected value in dropdown list using JavaScript ?
How to remove duplicate elements from JavaScript Array ?
How to fetch data from an API in ReactJS ?
How to redirect to another page in ReactJS ?
How to pass data from child component to its parent in ReactJS ?
ReactJS Functional Components
How to pass data from one component to other component in ReactJS ?
C# program to convert binary string to Integer

Use the Convert.ToInt32 class to fulfill your purpose of converting a binary string to an integer.
Let’s say our binary string is −
string str = "1001";
Now each char is parsed −
try {
   //Parse each char of the passed string
   val = Int32.Parse(str1[i].ToString());
   if (val == 1)
      result += (int) Math.Pow(2, str1.Length - 1 - i);
   else if (val > 1)
      throw new Exception("Invalid!");
} catch {
   throw new Exception("Invalid!");
}
Check the above for each character in the passed string i.e. “100” using a for a loop. Find the length of the string using the length() method −
str1.Length
You can try to run the following code to convert a binary string to an integer in C#.
Live Demo
using System;
class Program {
   static void Main() {
      string str = "1001";
      Console.WriteLine("Integer:"+ConvertClass.Convert(str));
   }
}
public static class ConvertClass {
   public static int Convert(string str1) {
      if (str1 == "")
         throw new Exception("Invalid input");
      int val = 0, res = 0;
      for (int i = 0; i < str1.Length; i++) {
         try {
            val = Int32.Parse(str1[i].ToString());
            if (val == 1)
               res += (int)Math.Pow(2, str1.Length - 1 - i);
            else if (val > 1)
               throw new Exception("Invalid!");
         } catch {
            throw new Exception("Invalid!");
         }
      }
      return res;
   }
}
Integer:9
Java Math log() method with example - GeeksforGeeks

23 Mar, 2018
The java.lang.Math.log() method returns the natural logarithm (base e) of a double value as a parameter. There are various cases :
If the argument is NaN or less than zero, then the result is NaN.
If the argument is positive infinity, then the result is positive infinity.
If the argument is positive zero or negative zero, then the result is negative infinity.
Syntax :
public static double log(double a)
Parameter :
a : User input
Return :
This method returns the value ln a.
Example :To show working of java.lang.Math.log() method.
// Java program to demonstrate working// of java.lang.Math.log() methodimport java.lang.Math;  class Gfg {          // driver code    public static void main(String args[])    {          double a = -2.55;        double b = 1.0 / 0;        double c = 0, d = 145.256;                    // negative integer as argument, output NAN        System.out.println(Math.log(a));          // positive infinity as argument, output Infinity        System.out.println(Math.log(b));          // positive zero as argument, output -Infinity        System.out.println(Math.log(c));                  // positive double as argument        System.out.println(Math.log(d));              }}
NaN
Infinity
-Infinity
4.978497702968366

java-math
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Singleton Class in Java
Multithreading in Java
Draw rectangle on an image using OpenCV

In this program, we will draw a rectangle using the OpenCV function rectangle(). This function takes some parameters like starting coordinates, ending coordinates, color and thickness and the image itself.
Step 1: Import cv2.
Step 2: Read the image using imread().
Step 3: Define the starting coordinates.
Step 5: Define the ending coordinates.
Step 6: Define the color and the thickness.
Step 7: Draw the rectangle using the cv2.reactangle() function.
Step 8: Display the rectangle.
import cv2

image = cv2.imread('testimage.jpg')
height, width, channels = image.shape
start_point = (0,0)
end_point = (width, height)
color = (0,0,255)
thickness = 5

image = cv2.rectangle(image, start_point, end_point, color, thickness)
cv2.imshow('Rectangle',image)
Get only the date from datetime in MySQL?

To get only the date from DateTime, use the date format specifiers −
%d for day
%m for month
%Y for year
Let us first create a table −
mysql> create table DemoTable
(
   AdmissionDate datetime
);
Query OK, 0 rows affected (0.52 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-07-21 12:34:56');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values('2016-08-18 10:00:02');
Query OK, 1 row affected (0.51 sec)
mysql> insert into DemoTable values('2018-01-03 11:02:20');
Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------------------+
| AdmissionDate       |
+---------------------+
| 2019-07-21 12:34:56 |
| 2016-08-18 10:00:02 |
| 2018-01-03 11:02:20 |
+---------------------+
3 rows in set (0.00 sec)
Here is the query to get only the date −
mysql> select date_format(AdmissionDate,'%d.%m.%Y') AS Date from DemoTable;
This will produce the following output −
+------------+
| Date       |
+------------+
| 21.07.2019 |
| 18.08.2016 |
| 03.01.2018 |
+------------+
3 rows in set (0.00 sec)
How do I give focus to a python Tkinter text widget?

In various applications, tkinter widgets are required to be focused to make them active. Widgets can also grab focus and prevent the other events outside the bounds. To manage and give focus to a particular widget, we generally use the focus_set() method. It focuses the widget and makes them active until the termination of the program.
In the following example, we have created two widgets: an Entry widget and a text widget in the same window. By using the focus_set() method, we will activate the focus on the text widget.
#Import tkinter library
from tkinter import *
from PIL import Image,ImageTk
#Create an instance of tkinter frame
win = Tk()
#Set the geometry
win.geometry("750x250")
#Create a Text WIdget
text= Text(win, width= 30, height= 10)
text.insert(INSERT, "Hello World!")
#Activate the focus
text.focus_set()
text.pack()
#Create an Entry Widget
entry=Entry(win,width= 30)
entry.pack()
win.mainloop()
Running the above code will display a window that contains the focus on the text widget.
Tryit Editor v3.7

CSS Grid Intro
Tryit: The row-gap property
Current Date and Time in Perl

Let's start with localtime() function in Perl, which returns values for the current date and time if given no arguments. Following is the 9-element list returned by the localtime function while using in list context −
sec, # seconds of minutes from 0 to 61
min, # minutes of hour from 0 to 59
hour, # hours of day from 0 to 24
mday, # day of month from 1 to 31
mon, # month of year from 0 to 11
year, # year since 1900
wday, # days since sunday
yday, # days since January 1st
isdst # hours of daylight savings time
Try the following example to print different elements returned by localtime() function −
 Live Demo
#!/usr/local/bin/perl
@months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
@days = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
print "$mday $months[$mon] $days[$wday]\n";
When the above code is executed, it produces the following result −
16 Feb Sat
If you will use localtime() function in the scalar context, then it will return date and time from the current time zone set in the system. Try the following example to print the current date and time in full format −
 Live Demo
#!/usr/local/bin/perl
$datestring = localtime();
print "Local date and time $datestring\n";
When the above code is executed, it produces the following result −
Local date and time Sat Feb 16 06:50:45 2013
id command in Linux with examples - GeeksforGeeks

22 May, 2019
id command in Linux is used to find out user and group names and numeric ID’s (UID or group ID) of the current user or any other user in the server. This command is useful to find out the following information as listed below:
User name and real user id.
Find out the specific Users UID.
Show the UID and all groups associated with a user.
List out all the groups a user belongs to.
Display security context of the current user.
Synopsis:
id [OPTION]... [USER]
Options:
-g : Print only the effective group id.
-G : Print all Group ID’s.
-n : Prints name instead of number.
-r : Prints real ID instead of numbers.
-u : Prints only the effective user ID.
–help : Display help messages and exit.
–version : Display the version information and exit.
Note: Without any OPTION it prints every set of identified information i.e. numeric ID’s.
Examples:
To print your own id without any Options:idThe output shows the ID of current user UID and GID.
id
The output shows the ID of current user UID and GID.
To find a specific users id: Now assume that we have a user named master, to find his UID we will use the command:id -u master
id -u master
To find a specific users GID: Again assuming to find GID of master, we will use the command:id -g master
id -g master
To find out UID and all groups associated with a username: In this case we will use the user “master” to find UID and all groups associated with it, use command:id master
id master
To find out all the groups a user belongs to: Displaying the UID and all groups a user “master” belongs to:id -G master
id -G master
To display a name instead of numbers: By default the id command shows us the UDI and GID in numbers which a user may not understand, with use of -n option with -u, -g and -G, use command(s)id -ng master 
or
id -nu master
or
id -nG master

id -ng master 
or
id -nu master
or
id -nG master

To display real id instead of effective id: To show the real id with the use of -r option with -g, -u and -G, use command(s):id -r -g master
id -r -u master
id -r -G master

id -r -g master
id -r -u master
id -r -G master

linux-command
Linux-misc-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
TCP Server-Client implementation in C
ZIP command in Linux with examples
tar command in Linux with examples
SORT command in Linux/Unix with examples
UDP Server-Client implementation in C
curl command in Linux with Examples
'crontab' in Linux with Examples
Conditional Statements | Shell Script
diff command in Linux with examples
Cat command in Linux with examples
C Library - <limits.h>

The limits.h header determines various properties of the various variable types. The macros defined in this header, limits the values of various variable types like char, int and long.
These limits specify that a variable cannot store any value beyond these limits, for example an unsigned character can store up to a maximum value of 255.
The following values are implementation-specific and defined with the #define directive, but these values may not be any lower than what is given here.
The following example shows the usage of few of the constants defined in limits.h file.
#include <stdio.h>
#include <limits.h>

int main() {

   printf("The number of bits in a byte %d\n", CHAR_BIT);

   printf("The minimum value of SIGNED CHAR = %d\n", SCHAR_MIN);
   printf("The maximum value of SIGNED CHAR = %d\n", SCHAR_MAX);
   printf("The maximum value of UNSIGNED CHAR = %d\n", UCHAR_MAX);

   printf("The minimum value of SHORT INT = %d\n", SHRT_MIN);
   printf("The maximum value of SHORT INT = %d\n", SHRT_MAX); 

   printf("The minimum value of INT = %d\n", INT_MIN);
   printf("The maximum value of INT = %d\n", INT_MAX);

   printf("The minimum value of CHAR = %d\n", CHAR_MIN);
   printf("The maximum value of CHAR = %d\n", CHAR_MAX);

   printf("The minimum value of LONG = %ld\n", LONG_MIN);
   printf("The maximum value of LONG = %ld\n", LONG_MAX);
  
   return(0);
}
Let us compile and run the above program that will produce the following result −
The number of bits in a byte 8
The minimum value of SIGNED CHAR = -128
The maximum value of SIGNED CHAR = 127
The maximum value of UNSIGNED CHAR = 255
The minimum value of SHORT INT = -32768
The maximum value of SHORT INT = 32767
The minimum value of INT = -2147483648
The maximum value of INT = 2147483647
The minimum value of CHAR = -128
The maximum value of CHAR = 127
The minimum value of LONG = -9223372036854775808
The maximum value of LONG = 9223372036854775807


    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
DAX Other - VAR function

Stores the result of an expression as a named variable, which can then be passed as a parameter to other calculated field expressions. Once the resultant values have been calculated for a variable expression, those values do not change, even if the variable is referenced in another expression.
DAX VAR function is new in Excel 2016.
VAR <name> = <expression> 

name
The name of the variable (identifier).
Delimiters are not supported. For e.g. ‘varName’ or [varName] will result in an error.
Delimiters are not supported. For e.g. ‘varName’ or [varName] will result in an error.
Supported character set: a-z, A-Z, 0-9.

0-9 are not valid as first character.
__ (double underscore) is allowed as a prefix to the identifier name. No other special characters are supported.


Supported character set: a-z, A-Z, 0-9.
0-9 are not valid as first character.
0-9 are not valid as first character.
__ (double underscore) is allowed as a prefix to the identifier name. No other special characters are supported.
__ (double underscore) is allowed as a prefix to the identifier name. No other special characters are supported.
Reserved keywords not allowed.
Reserved keywords not allowed.
Names of the existing tables are not allowed.
Names of the existing tables are not allowed.
Empty spaces are not allowed.
Empty spaces are not allowed.
expression
A DAX expression which returns a scalar or table value.
A named variable containing the result of the expression parameter.
An expression passed as a parameter to VAR can contain another VAR declaration.
When referencing a variable −
Calculated fields cannot refer to variables defined outside the calculated field expression, but can refer to functional scope variables defined within the expression.
Calculated fields cannot refer to variables defined outside the calculated field expression, but can refer to functional scope variables defined within the expression.
Variables can refer to calculated fields.
Variables can refer to calculated fields.
Variables can refer to previously defined variables.
Variables can refer to previously defined variables.
Columns in table variables cannot be referenced via TableName[ColumnName] syntax.
Columns in table variables cannot be referenced via TableName[ColumnName] syntax.
= Var SouthSales = SUMX(FILTER(Sales,Sales[Region]="South")
,Sales[Sales Amount]) Var EastSales = SUMX(FILTER(Sales,Sales[Region]="East")
,Sales[Sales Amount]) return SouthSales+EastSales 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
Difference between Structure and Union in C

Structure is a user defined datatype. It is used to combine different types of data into a single type. It can have multiple members and structure variables. The keyword “struct” is used to define structures in C language. Structure members can be accessed by using dot(.) operator.
Here is the syntax of structures in C language,
struct structure_name {
   member definition;
} structure_variables;
Here,
structure_name − Any name given to the structure.
structure_name − Any name given to the structure.
member definition − Set of member variables.
member definition − Set of member variables.
structure_variable − This is the object of structure.
structure_variable − This is the object of structure.
Here is an example of structures in C language,
 Live Demo
#include <stdio.h>
#include <string.h>

struct Data {
   int i;
   long int f;
} data, data1;

int main( ) {
   data.i = 28;
   printf("The value of i : %d\n", (data.i));
   printf( "Memory size occupied by data : %d\t%d", sizeof(data), sizeof(data1));
   return 0;
}
Here is the output
The value of i : 28
Memory size occupied by data : 16 16
Union is also a user defined datatype. All the members of union share the same memory location. Size of union is decided by the size of largest member of union. If you want to use same memory location for two or more members, union is the best for that.
Unions are similar to the structure. Union variables are created in same manner as structure variables. The keyword “union” is used to define unions in C language.
Here is the syntax of unions in C language,
union union_name {
   member definition;
} union_variables;
Here,
union_name − Any name given to the union.
union_name − Any name given to the union.
member definition − Set of member variables.
member definition − Set of member variables.
union_variable − This is the object of union.
union_variable − This is the object of union.
Here is an example of unions in C language,
 Live Demo
#include <stdio.h>
#include <string.h>

union Data {
   int i;
   float f;
} data, data1;

int main( ) {
   printf( "Memory size occupied by data : %d\t%d", sizeof(data), sizeof(data1));
   return 0;
}
Here is the output
Memory size occupied by data : 4 4
Python - scipy.fft.dst() method - GeeksforGeeks

01 Oct, 2020
With the help of scipy.fft.dst() method, we can compute the discrete sine transform by selecting different types of sequences and return the transformed array by using this method.
Syntax :
scipy.fft.dst(x, type=2)

Return value: It will return the transformed array.
Example #1: In this example, we can see that by using scipy.fft.dst() method, we are able to get the discrete sine transform by selecting different types of sequences by default it’s 2.
Python3
# import scipyfrom scipy import fft  # Using scipy.fft.dst() methodgfg = fft.dst([1, 2, 3, 4])  print(gfg)
Output :
[13.06562965 -5.65685425  5.41196100 -4.00000000]

Example #2 :
Python3
# import scipyfrom scipy import fft  # Using scipy.fft.dst() methodgfg = fft.dst([-6, 5, -4, 3, -2, 1], 3)  print(gfg)
Output :
[ -1.43023367  -2.3137085   -6.16568427  -7.77337942 -20.3137085
 -23.82253852]

Python-scipy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
How to calculate the number of words in a string using JQuery? - GeeksforGeeks

06 Sep, 2019
In order to calculate the number of words in a string, we can Use the JQuery split() method along with or without trim() method..split() method simply split a string into an array of substrings by a specified character and .trim() method to remove the leading and trailing white spaces.
Syntax:
string.split(separator, limit)
Get the string from the HTML element.
Split the string into substring on the basis of whitespaces.
Count the number of substrings.
Example 1: Along with trim() method, removing starting and ending spaces from the string
<!DOCTYPE html><html>  <head>    <title>How to calculate the number       of words in a string using Javascript?</title>    <script src="https://code.jquery.com/jquery-1.12.4.min.js">  </script></head>  <body style="text-align:center;">    <h1 style="color:green;">         GeeksForGeeks     </h1>    <h3>How to calculate the number of words      in a string using Javascript?</h3>    <textarea> Geeks For GEEKS </textarea>    <br>    <button type="button">Click</button>    <script type="text/javascript">        $(document).ready(function() {            $("button").click(function() {                // reduce the whitespace from both sides of a string.                 var geeks1 = $.trim($("textarea").val());                //split a string into an array of substrings                var geek = geeks1.split(" ")                    // count number of elements                alert(geek.length);            });        });    </script></body>  </html>
Output:
Before Click on button:
After Click on button:
Example 2: Without trim() method
<!DOCTYPE html><html>  <head>    <title>Calculate the number      of Words in a String</title>  </head>  <body style="text-align:center;">    <h1 style="color:green;">         GeeksForGeeks     </h1>    <h3>How to calculate the number of      words in a string using Javascript?</h3>    <p id="geeks1"></p>    <br>    <button onclick="myFunction()">Click</button>    <p id="geeks"></p>      <script>        var str = "Geeks For Geeks";        document.getElementById("geeks1").innerHTML = str;          function myFunction() {            var res = str.split(" ");            document.getElementById(              "geeks").innerHTML = res.length;        }    </script></body>  </html>
Output:
Before Click on button:
After Click on button:
jQuery-Misc
JQuery
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Form validation using jQuery
How to Dynamically Add/Remove Table Rows using jQuery ?
Scroll to the top of the page using JavaScript/jQuery
jQuery | children() with Examples
How to Show and Hide div elements using radio buttons?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
C# | Getting the type of the current instance - GeeksforGeeks

01 Feb, 2019
Object.GetType Method is used to find the type of the current instance. This method returns the instances of the Type class that are used for consideration.
Syntax:
public Type GetType ();
Return Value: This method return the exact runtime type of the current instance.
Below given are some examples to understand the implementation in a better way:
Example 1:
// C# program to illustrate the // GetType() methodusing System;  class GFG {      // Main method    static public void Main()    {          // string type        string str1 = "GFG";        string str2 = "5";          // using GetType() method        Console.WriteLine("Type of str1: " +str1.GetType());        Console.WriteLine("Type of str2: " +str2.GetType());    }}
Output:
Type of str1: System.String
Type of str2: System.String

Example 2:
// C# program to illustrate the // GetType() methodusing System;  class GFG {          // Main method    static public void Main()    {          // Variables        string str1 = "C#";        string str2 = "DSA";        int str3 = 43;          // Display the given string and their type        // using GetType() method        Console.WriteLine("Str 1 is : {0}", str1);        Console.WriteLine("Str 2 is : {0}", str2);        Console.WriteLine("Str 3 is : {0}", str3);          // Check the given str1, str2,        // and str3 are of same type or not        // using GetType() method        Console.WriteLine("Is Str 1 and Str 2 of same type? : {0}",             Object.ReferenceEquals(str1.GetType(), str2.GetType()));                      Console.WriteLine("Is Str 2 and Str 3 of same type? : {0}",           Object.ReferenceEquals(str2.GetType(), str3.GetType()));                     Console.WriteLine("Is Str 3 and Str 2 of same type? : {0}",            Object.ReferenceEquals(str3.GetType(), str2.GetType()));    }}
Output:
Str 1 is : C#
Str 2 is : DSA
Str 3 is : 43
Is Str 1 and Str 2 of same type? : True
Is Str 2 and Str 3 of same type? : False
Is Str 3 and Str 2 of same type? : False

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.object.gettype?view=netframework-4.7.2
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Delegates
C# | Method Overriding
C# | Abstract Classes
Difference between Ref and Out keywords in C#
Extension Method in C#
Introduction to .NET Framework
C# | String.IndexOf( ) Method | Set - 1
C# | Replace() Method
C# | Arrays
C program to Insert an element in an Array - GeeksforGeeks

15 Oct, 2020
An array is a collection of items stored at contiguous memory locations. In this article, we will see how to insert an element in an array in C.Given an array arr of size n, this article tells how to insert an element x in this array arr at a specific position pos. 
Approach: Here’s how to do it. 
First get the element to be inserted, say xThen get the position at which this element is to be inserted, say posThen shift the array elements from this position to one position forward, and do this for all the other elements next to pos.Insert the element x now at the position pos, as this is now empty.
First get the element to be inserted, say x
Then get the position at which this element is to be inserted, say pos
Then shift the array elements from this position to one position forward, and do this for all the other elements next to pos.
Insert the element x now at the position pos, as this is now empty.
Below is the implementation of the above approach: 
C
// C Program to Insert an element// at a specific position in an Array #include <stdio.h> int main(){    int arr[100] = { 0 };    int i, x, pos, n = 10;     // initial array of size 10    for (i = 0; i < 10; i++)        arr[i] = i + 1;     // print the original array    for (i = 0; i < n; i++)        printf("%d ", arr[i]);    printf("\n");     // element to be inserted    x = 50;     // position at which element    // is to be inserted    pos = 5;     // increase the size by 1    n++;     // shift elements forward    for (i = n-1; i >= pos; i--)        arr[i] = arr[i - 1];     // insert x at pos    arr[pos - 1] = x;     // print the updated array    for (i = 0; i < n; i++)        printf("%d ", arr[i]);    printf("\n");     return 0;}
1 2 3 4 5 6 7 8 9 10 
1 2 3 4 50 5 6 7 8 9 10


 
aniket_lodh
c-array
C-Arrays
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Multidimensional Arrays in C / C++
Left Shift and Right Shift Operators in C/C++
Converting Strings to Numbers in C/C++
rand() and srand() in C/C++
std::string class in C++
fork() in C
Different methods to reverse a string in C/C++
Enumeration (or enum) in C
Command line arguments in C/C++
Batch Script - DRIVERQUERY

This batch command shows all installed device drivers and their properties.
driverquery

@echo off 
driverquery
The above command will display the information of all the device drivers installed on the current system. Following is an example of a subset of the information displayed.
WacomPen      Wacom Serial Pen HID D Kernel        8/22/2013 4:39:15 AM 
Wanarp        Remote Access IP ARP D Kernel        8/22/2013 4:35:45 AM 
Wanarpv6      Remote Access IPv6 ARP Kernel        8/22/2013 4:35:45 AM 
Wdf01000      Kernel Mode Driver Fra Kernel        8/22/2013 4:38:56 AM 
WFPLWFS       Microsoft Windows Filt Kernel        11/9/2014 6:57:28 PM 
WIMMount      WIMMount               File System   8/22/2013 4:39:34 AM
WinMad        WinMad Service         Kernel        5/9/2013  9:14:27 AM 
WinNat        Windows NAT Driver     Kernel        1/22/2014 1:10:49 AM 
WinUsb        WinUsb Driver          Kernel        8/22/2013 4:37:55 AM 
WinVerbs      WinVerbs Service       Kernel        5/9/2013 9:14:30 AM 
WmiAcpi       Microsoft Windows Mana Kernel        8/22/2013 4:40:04 AM 
WpdUpFltr     WPD Upper Class Filter Kernel        8/22/2013 4:38:45 AM 
ws2ifsl       Windows Socket 2.0 Non Kernel        8/22/2013 4:40:03 AM
wtlmdrv       Microsoft iSCSI Target Kernel        8/22/2013 4:39:19 AM 
WudfPf        User Mode Driver Frame Kernel        8/22/2013 4:37:21 AM 
WUDFWpdFs     WUDFWpdFs              Kernel        8/22/2013 4:36:50 AM 
WUDFWpdMtp    WUDFWpdMtp             Kernel        8/22/2013 4:36:50 AM

 Print
 Add Notes
 Bookmark this page
Should I store a field PRICE as an int or as a float in the database?

You do not need to store a field PRICE as an int or as float in the database. For this, you can set the DECIMAL()..
Most of the time integers can be used to represent the float point numbers and these integers are internally cast into DECIMAL() data type. Therefore, if you have field PRICE then always use DECIMAL() data type. The syntax is as follows −
DECIMAL(M,D);
Here, M represents the ‘TotalNumberOfDigit’ and D represents the ‘Number OfDigitAfterDecimalPoint’.
To understand the above concept, let us create a table with field PRICE as DECIMAL data type. The query is as follows −
mysql> create table Decimal_Demo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,
   -> PRICE DECIMAL(18,2),
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (1.63 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into Decimal_Demo(PRICE) values(99999999999999.99);
Query OK, 1 row affected (0.11 sec)
mysql> insert into Decimal_Demo(PRICE) values(10000000000000.99);
Query OK, 1 row affected (0.36 sec)
Now you can display all records from the table using a select statement. The query is as follows −
mysql> select *from Decimal_Demo;
The following is the output −
+----+-------------------+
| Id | PRICE             |
+----+-------------------+
|  1 | 99999999999999.99 |
|  2 | 10000000000000.99 |
+----+-------------------+
2 rows in set (0.00 sec)
HTML | <option> selected Attribute - GeeksforGeeks

31 Mar, 2021
The HTML <option> selected Attribute is used to specify which option should be by default selected when the page loads. This is a boolean attribute. The option that is having the selected attribute will be displayed by default.Syntax:  
<option selected> 
Example-1: This Example illustrates the use of selected attribute in option Element.  
html
<!-- HTML program to illustrate selected Attribute --> <!DOCTYPE html><html> <head>    <title>HTML selected Attribute</title></head> <body style="text-align: center;">    <h1 style="color: green;">GeeksforGeeks</h1>    <h2>HTML Option selected Attribute</h2>     <!-- List of Options -->    <select>        <option value="merge">Merge Sort</option>        <option value="bubble">Bubble Sort</option>        <option value="insertion">Insertion Sort</option>         <!-- Option element with selected attribute -->        <option value="quick" selected>Quick Sort</option>    </select></body> </html>
Output:  
Example-2:  
html
<!-- HTML program to illustrate selected Attribute --> <!DOCTYPE html><html> <head>    <title>HTML selected Attribute</title></head> <body style="text-align: center;">    <h1 style="color: green;">GeeksforGeeks</h1>    <h2>HTML Option selected Attribute</h2>     <!-- List of Options -->    <select>        <option value="c">C</option>        <option value="cpp">C++</option><!-- Option element with selected attribute -->        <option value="python" selected>Python</option>        <option value="java" >JAVA</option>    </select></body> </html>                   
Output:  
Supported Browsers: The browser supported by HTML Option Selected Attribute are listed below:  
Google Chrome
Internet Explorer
Firefox
Opera
Safari
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
simranarora5sos
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
Design a web page using HTML and CSS
Form validation using jQuery
How to place text on image using HTML and CSS?
How to auto-resize an image to fit a div container using CSS?
Top 10 Front End Developer Skills That You Need 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
Convert a string to an integer in JavaScript
How To Create a Countdown Timer Using Python? - GeeksforGeeks

29 Jul, 2020
In this article, we will see how to create a countdown timer using Python. The code will take input from the user regarding the length of the countdown in seconds. After that, a countdown will begin on the screen of the format ‘minutes: seconds’. We will use the time module here.
In this project, we will be using the time module and its sleep() function. Follow the below steps to create a countdown timer:
Step 1: Import the time module.
Step 2: Then ask the user to input the length of the countdown in seconds.
Step 3: This value is sent as a parameter ‘t’ to the user-defined function countdown(). Any variable read using the input function is a string. So, convert this parameter to ‘int’ as it is of string type.
Step 4: In this function, a while loop runs until time becomes 0.
Step 5: Use divmod() to calculate the number of minutes and seconds. You can read more about it here.
Step 6: Now print the minutes and seconds on the screen using the variable timeformat.
Step 7: Using end = ‘\r’ we force the cursor to go back to the start of the screen (carriage return) so that the next line printed will overwrite the previous one.
Step 8: The time.sleep() is used to make the code wait for one sec.
Step 9: Now decrement time so that the while loop can converge.
Step 10: After the completion of the loop, we will print “Fire in the hole” to signify the end of the countdown.
Below is the implementation of the above approach
Python3
# import the time moduleimport time  # define the countdown func.def countdown(t):        while t:        mins, secs = divmod(t, 60)        timer = '{:02d}:{:02d}'.format(mins, secs)        print(timer, end="\r")        time.sleep(1)        t -= 1          print('Fire in the hole!!')    # input time in secondst = input("Enter the time in seconds: ")  # function callcountdown(int(t))
Output:  
 
Python time-module
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
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 program to convert a list to string
Python String | replace()
Reading and Writing to text files in Python
sum() function in Python