Posts

Showing posts from 2021

Java Apni Kak

For Loops: package com.company ; import java.util.* ; public class Main { public static void main (String[] args) { //Print sum of n numbers input taken by users, this code will give each step result Scanner sc = new Scanner(System. in ) ; int n = sc.nextInt() ; int sum = 0 ; /* How loops works * sum=0, 0+1, where 1= i * sum=1, 1+2, where 2= i * sum=2, 3+3, where 3(last one)= i * sum=6, 6+4, where 4= i * sum=10, 10+5, where 5= i * i Value reaches to condition * * */ for ( int i = 1 ; i <= n ; i++) { sum = sum+i ; System. out .println(sum) ; } } } public class Main { public static void main (String[] args) { //Print sum of n numbers input taken by users, this code will one result Scanner sc = new Scanner(System. in ) ; int n = sc.nextInt() ; int sum = 0 ; /* How loops works * sum=0, 0+1, where 1= i * sum=1, 1+2, where 2= i * sum=2, 3+3, where 3(la...

JS- Udemy Notes

Coercion: Change one data type into another, two types of coercion 1: Implicit data type - by default by JS  2: Explicit data type - custom change by coder

JS

  Data Types in JS We assigned data to the variable by using the assignment operator "=". Datatypes in JavaScript are: Number i.e., 11,23,45,6 Strings, i.e., "Hello World." Boolean, i.e., true, false Undefined Null Any of the complex data structures (Array and Objects) Let Block level scope, it works under block { } if call outer side of block the global let value will call console . log ( 'tut3' ) ; // Variables in js // var, let, const var name = 'harry' ; var channel ; var marks = 3454 ; marks = 0 ; channel = 'CodeWithHarry' console . log ( name , channel , marks ) ; // Rules for creating JavaScript Variables /* 1. Cannot start with numbers 2. Can start with letter, numbers, _ or $ 3. Are case sensitive */ var city = 'Delhi' ; console . log ( city ) ; const ownersName = 'Hari Ram' ; // ownersName = 'Harry'; // Cannot do this (error) console . log ( ownersName ) ; const fruit = 'Or...