HTML - DiV Tag
<html> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <head><title>Day 3</title> <style> .k { padding: 30px; margin:19px; background-color: black; color: white; height: 45px; text-align: center; } </style></head> <body> <div class="k"> Hello world </div> <span style="background-color:seagreen;color:yellow;font-family: cursive">hey</span> </body> </html>
Java If Else Condition
class Condition { public static void main(String[] args) { boolean learning = true; if (learning) { System.out.println("Java programmer"); } else { System.out.println("What are you doing here?"); } } }
Java program to check if number is even or odd
import java.util.Scanner; class OddOrEven { public static void main(String args[]) { int x; System.out.println("Enter an integer to check if it is odd or even"); Scanner in = new Scanner(System.in); x = in.nextInt(); if (x % 2 == 0) System.out.println("The number is even."); else System.out.println("The number is odd."); } }
Linked List Length Using C Program
#include<stdio.h> struct node { int data; struct node* next; }; void getlength(struct node** head_ref) { struct node *temp=*head_ref; int count=0; while(temp!=NULL) { temp=temp->next; count++; } printf("total number of nodes are %d",count); } void push(struct node **head_ref,int x) { struct node* new1; new1=(struct node*)malloc(sizeof(struct node)); new1->data=x; new1->next=*head_ref; *head_ref=new1; } void delete1(struct node** head_ref,int key) { struct node* temp=*head_ref; struct node *prev; while(temp!=NULL) { prev=temp; temp=temp->next; if(temp->data==key) { break; } } prev->next=temp->next; free(temp); } int main() { struct node* head=NULL; push(&head,89); push(&head,65); push(&head,23); delete1(&head,89); getlength(&head); }
String Operators using Shell Scripting
#!/bin/sh str1="security"; str2="hacked"; if [ $str1 = $str2 ] then echo "Both string are same"; else echo "Both string are not same"; fi
Pattern Orinting Using BASH
N=5 i=0 j=0 while [ $i -le `expr $N - 1` ] do j=0 while [ $j -le `expr $N - 1` ] do if [ `expr $N - 1` -le `expr $i + $j` ] then # Print the pattern echo -ne "#" else # Print the spaces required echo -ne " " fi j=`expr $j + 1` done # For next line echo i=`expr $i + 1` done
swap two numbers using Bash
first=52 second=130 temp=$first first=$second second=$temp echo "After swapping, numbers are:" echo "first = $first, second = $second"
Python Program To Convert Binary To Decimal
def binaryToDecimal(n): num = n; dec_value = 0; # value to 1, i.e 2^0 base = 1; temp = num; while(temp): last_digit = temp % 10; temp = int(temp / 10); dec_value += last_digit * base; base = base*2; return dec_value; num = 10101001; print(binaryToDecimal(num));
Python Program for Decimal to Binary
def decToBinary(n): binaryNum = [0] * n; i = 0; while (n > 0): binaryNum[i] = n % 2; n = int(n / 2); i += 1; for j in range(i - 1, -1, -1): print(binaryNum[j], end = ""); n = 17; decToBinary(n);
Python Program for Inserting at the End of the Linked List
class Node: def __init__(self, dataval=None): self.dataval = dataval self.nextval = None class SLinkedList: def __init__(self): self.headval = None # Function to add newnode def AtEnd(self, newdata): NewNode = Node(newdata) if self.headval is None: self.headval = NewNode return laste = self.headval while(laste.nextval): laste = laste.nextval laste.nextval=NewNode # Print the linked list def listprint(self): printval = self.headval while printval is not None: print (printval.dataval) printval = printval.nextval list = SLinkedList() list.headval = Node("Mon") e2 = Node("Tue") e3 = Node("Wed") list.headval.nextval = e2 e2.nextval = e3 list.AtEnd("Thu") list.listprint()
Numeric Array In PHP
<html> <body> <?php /* First method to create array. */ $numbers = array( 1, 2, 3, 4, 5); foreach( $numbers as $value ) { echo "Value is $value <br />"; } /* Second method to create array. */ $numbers[0] = "one"; $numbers[1] = "two"; $numbers[2] = "three"; $numbers[3] = "four"; $numbers[4] = "five"; foreach( $numbers as $value ) { echo "Value is $value <br />"; } ?> </body> </html>
Associative Arrays in PHP
<html> <body> <?php /* First method to associate create array. */ $salaries = array("mohammad" => 2000, "qadir" => 1000, "zara" => 500); echo "Salary of mohammad is ". $salaries['mohammad'] . "<br />"; echo "Salary of qadir is ". $salaries['qadir']. "<br />"; echo "Salary of zara is ". $salaries['zara']. "<br />"; /* Second method to create array. */ $salaries['mohammad'] = "high"; $salaries['qadir'] = "medium"; $salaries['zara'] = "low"; echo "Salary of mohammad is ". $salaries['mohammad'] . "<br />"; echo "Salary of qadir is ". $salaries['qadir']. "<br />"; echo "Salary of zara is ". $salaries['zara']. "<br />"; ?> </body> </html>