Tutorialspoint

PHP array_push() function

php

<?php
$arr = array("table", "chair","pen", "pencil");
array_push($arr,"notepad", "paperclip");
print_r($arr);
?>

Html Dropping the Object Program

<html>
   <head>
      <style type="text/css">
         #boxA, #boxB {
            float:left;padding:10px;margin:10px;-moz-user-select:none;
         }
         #boxA { background-color: #6633FF; width:75px; height:75px;  }
         #boxB { background-color: #FF6699; width:150px; height:150px; }
      </style>
      <script type="text/javascript">
         function dragStart(ev) {
            ev.dataTransfer.effectAllowed='move';
            ev.dataTransfer.setData("Text", ev.target.getAttribute('id'));
            ev.dataTransfer.setDragImage(ev.target,0,0);
            return true;
         }
         function dragEnter(ev) {
            event.preventDefault();
            return true;
         }
         function dragOver(ev) {
            return false;
         }
         function dragDrop(ev) {
            var src = ev.dataTransfer.getData("Text");
            ev.target.appendChild(document.getElementById(src));
            ev.stopPropagation();
            return false;
         }
      </script>
   </head>
   <body>
      <center>
         <h2>Drag and drop HTML5 demo</h2>
         <div>Try to move the purple box into the pink box.</div>
         <div id="boxA" draggable="true" ondragstart="return dragStart(event)">
            <p>Drag Me</p>
         </div>
         <div id="boxB" ondragenter="return dragEnter(event)" ondrop="return dragDrop(event)" ondragover="return dragOver(event)">Dustbin</div>
      </center>
   </body>
</html>

MomentJS Using Locale in Browser

<html>
   <head>
      <title>MomentJS - Adding locale</title>
      <script type="text/JavaScript" src="https://MomentJS.com/downloads/moment.js"></script>
      <script type="text/JavaScript" src="https://MomentJS.com/downloads/moment-with-locales.js"></script>
      <style>
         div {
            border: solid 1px #ccc;
            padding:10px;
            font-family: "Segoe UI",Arial,sans-serif;
            width: 40%;
         }
      </style>
   </head>
   <body>
      <h1>MomentJS - Adding locale</h1>
      <div style="font-size:25px" id="currentdate"></div>
      <br/>
      <br/>
      <div style="font-size:25px" id="changeddate"></div>
      <script type="text/JavaScript">
         moment.locale("pt");
         var a = moment().format('LLLL');
         moment.locale("hi");
         var b = moment().format('LLLL');
         document.getElementById("currentdate").innerHTML = "Output locale: " + a;
         document.getElementById("changeddate").innerHTML = "Output in hindi locale: " + b;
      </script>
   </body>
</html>

MomentJS Subtract

<html>
   <head>
      <title>MomentJS - Subtract Method</title>
      <script type="text/JavaScript"    src="https://MomentJS.com/downloads/moment.js"></script>
      <style>
         div {
            border: solid 1px #ccc;
            padding:10px;
            font-family: "Segoe UI",Arial,sans-serif;
            width: 75%;
         }
      </style>
   </head>
   <body>
      <h1>MomentJS - Subtract Method</h1>
      <div style="font-size:25px" id="currentdate"></div>
      <br/>
      <br/>
      <div style="font-size:25px" id="changeddate"></div>
      <br/>
      <br/>
      <div style="font-size:25px" id="changeddate1"></div>
      <br/>
      <br/>
      <div style="font-size:25px" id="changeddate2"v</div>
      <script type="text/JavaScript">
         var day = moment();
         document.getElementById("currentdate").innerHTML = "Current Date: " + day._d;
         var changeddate = moment().subtract(5, 'days').subtract(2, 'months');
         document.getElementById("changeddate").innerHTML = "Subtracting 5 days and 2 month using chaining method: " + changeddate._d;
         var changeddate1 = moment().subtract({ days: 5, months: 2 });
         document.getElementById("changeddate1").innerHTML = "Subtracting 5 days and 2 month using object method: " + changeddate1._d;
         var duration = moment.duration({ 'days': 10 });
         var changeddate2 = moment([2017, 10, 15]).subtract(duration);
         document.getElementById("changeddate2").innerHTML = "Subtracting 10 days from given date using duration method: " + changeddate2._d;
      </script>
   </body>
</html>

srand() in C language

c

#include <stdio.h>
#include<stdlib.h>
#include<time.h>
int main() {
   srand(time(NULL));
   printf("%d\n", rand());
   srand(12);
   printf("%d", rand());
   return 0;
}

strndup() in C language

c

#include <stdio.h>
#include<string.h>
int main() {
   char *str = "Helloworld";
   char *result;
   result = strndup(str, 3);
   printf("The string : %s", result);
   return 0;
}

rand() in C language

c

#include <stdio.h>
#include<stdlib.h>
int main() {
   printf("%d\n", rand());
   printf("%d", rand());
   return 0;
}

strdup() in C language

c

#include <stdio.h>
#include<string.h>
int main() {
   char *str = "Helloworld";
   char *result;
   result = strdup(str);
   printf("The string : %s", result);
   return 0;
}

fflush(stdin) in C language

c

#include <stdio.h>
#include<stdlib.h>
int main() {
   char s[20] = "Helloworld";
   printf("The string : %s", s);
   fflush(stdin);
   return 0;
}

ispunct() in C language

c

#include <stdio.h>
#include<ctype.h>
int main() {
   int a = '!';
   int b = 'a';
    
   if(ispunct(a))
      printf("The character is a punctuation.");
   else
      printf("\nThe character is not a punctuation.");
         
   if(ispunct(b))
      printf("\nThe character is a punctuation.");
   else
      printf("\nThe character is not a punctuation.");
   return 0;
}

Advertisements
Loading...