Posts

Showing posts from July, 2023

JAVASCRIPT #6 ( do while loop , ARRAY)

Image
  for ( let i = 0 ; i <= 10 ; i ++ ){     if ( i === 4 ){         break ;     }     console . log ( i ); } console . log ( "hello there" ); for ( let i = 0 ; i <= 10 ; i ++ ){     if ( i === 4 ){         continue ;     }     console . log ( i ); } console . log ( "hello there" ); // do while loop   let i = 10 ; // while(i<=9){ //     console.log(i); //     i++; // } do {     console . log ( i );     i ++ ; } while ( i <= 9 ); console . log ( "value of i is" , i ); let fruits = [ "mango" , "apple" , "grapes" ]; let numbers = [ 1 , 2 , 3 , 4 , 5 ]; let   mixed = [ 1 , 2 , 2.3 , "mango" , "apple" , null , undefined ]; let obj = {}; // object literal console . log ( fruits ); fruits [ 1 ] = "banana" ; console . log ( fruits ); fruits [ 4 ] = "litchi" ; console . log ( fruits ); fruits [ 3 ] = "watermalo...

JAVASCRIPT #5 ( WHILE LOOP , FOR LOOP)

Image
  // while loop let i = 0 ; while ( i <= 9 ){     console . log ( i );     i ++ ; } console . log ( `current value of i is ${ i } ` ); let num = 10 ; let total = 0 ;   i = 0 ; // total = total + 1; // total = total + 2; // total = total + 3; // total = total + 4; // total = total + 5; // total = total + 6; // total = total + 7; // total = total + 8; // console.log(total); while ( i <= 10 ) {     total = total + i ;     i ++ ;     } console . log ( total ); // intro to for loop // print 0 to 9 for ( let i = 0 ; i <= 9 ; i ++ ){     console . log ( i ); }   total = 0 ;   for ( let i = 1 ; i <= 10 ; i ++ ){     total = total + i ;  }   console . log ( total ); OUTPUT:

JAVASCRIPT #4 ( TERNARY OPERATOR, LOOP STATEMENT)

Image
  // ternary operator let age = 15 ; let drink ; if ( age >= 5 ){     drink = "coffee" ; } else {     drink = "milk" ; } console . log ( drink ); age = 8 ; drink = age >= 5 ? "coffee" : "milk" ; // condition tu true hole ? r pisor tu print hbo.. console . log ( drink );   // and or operator let firstName = "Harshit" ; age = 22 ; if ( firstName [ 0 ] === "H" ){     console . log ( "your name is start with H" ); } // and operator... if ( firstName [ 0 ] === "H" && age < 18 ){     console . log ( "inside if" ) } else {     console . log ( "inside else" ); } // or operator.. if ( firstName [ 0 ] === "H" || age < 18 ){     console . log ( "inside if" ) } else {     console . log ( "inside else" ); } // nested if statement.. let winningNumber = 19 ; let userGuess = prompt ( "Guess a number" ); con...

JAVASCRIPT #3 (BOOLEANS , CONDITION STATEMENT)

Image
  // booleans & comparison operator //booleans //true, false let num1 = 7 ; let num2 = 7 ; console . log ( num1 >= num2 ); // == vs === console . log ( num1 == num2 ); num1 = "7" ; num2 = 7 ; console . log ( num1 === num2 ); // != vs !== -> type koi ee... console . log ( num1 != num2 ); console . log ( num1 !== num2 ); // if-else condition let age = 18 ; if ( age > 18 ){     console . log ( "User can play ddlc!" ); } else {     console . log ( "User can not play Ddlc!!!" ); } let num = 12 ; if ( num % 2 === 0 ){     console . log ( "even" ); } else {     console . log ( "odd" ); } // truthy and falsy values // falsy values // false // "" // null // undefined // 0 let firstName = "" ; if ( firstName ){     console . log ( firstName ); } else {     console . log ( "firstName kinda empty" ) } //truthy values // "abc" // 1, -1 OUTPUT:

JAVASCRIPT #2 (STRINGS)

Image
// STRING CONTINUE...... let age = 22 ; let firstName = "harshit" ; console . log ( typeof age ); // number to string convert... age = age + "" ; console . log ( typeof age ); // strings to number convert... let myStr = "34" ; myStr = + "34" ; console . log ( typeof myStr ); //another method.... //to convert number to string... let aGe = 18 ; aGe = String ( aGe ); console . log ( typeof aGe ); //to convert string to number... aGe = Number ( aGe ); console . log ( typeof aGe ); // string concatenation... let string1 = "kangkana" ; let string2 = "kalita" ; let fullName = string1 + " " + string2 ; console . log ( fullName ); let str1 = "18" ; let str2 = "20" ; let newStr = + "18" + + "20" ; console . log ( newStr ); // template string let old = 22 ; let firstname = "kangkana" ; // "my name is kangkana and my ...

JAVASCRIPT #1 ( variables , strings )

Image
  // #one "use strict" ; // for strictness of variables // mane variables declare korilehe work koribo nhle nkore.. ane var declare nkorakeu jikunu namere kam solabo pari. console. log ( "hello world" ); var firstName = "kangkana" ; console. log (firstName); var firstname = "Queen" ; console. log (firstName); // variables number di start koribo nuare. // variables r majot space dibo nuari var value1 = 2 ; console. log (value1 ** 0.5 ); //constant r maan change koribo nuari const pi = 3.14 ; console. log (pi * 2 * 3 ); //strings r lenght count koriboloi .lenght use kora hoi.. let myName = "kangkana" ; console. log (myName[ 3 ]); console. log (myName. length ); console. log (myName[myName. length - 2 ]); //strings r space remove koriboloi.trim use kora hoi. let lastName = "   kalita   " ; console. log (lastName. length ); let newString = lastName. trim (); console. log (newString. length ); //upper case loi conv...

Array elements printing

  #include <stdio.h> int main (){     int arr [ 5 ];     printf ( "Enter 5 numbers: " );     for ( int i = 0 ; i < 5 ; i ++ ){         scanf ( " %d " , & arr [ i ]);     }     printf ( "Array contains: \n " );     for ( int i = 0 ; i < 5 ; i ++ ){         printf ( " %d \0 " , arr [ i ]);     }     return 0 ; }

Bubble sort pw

  #include <stdio.h> int main (){     int arr [ 5 ] = { 5 , 4 , 3 , 2 , 1 };     int n = 5 ;     for ( int i = 0 ; i < n ; i ++ ){         printf ( " %d " , arr [ i ]);     }     //bubble sort     for ( int i = 0 ; i < n - 1 ; i ++ ){         for ( int j = 0 ; j <= n - 2 ; j ++ ){             if ( arr [ j ] > arr [ j + 1 ]){                 int temp = arr [ j ];                 arr [ j ] = arr [ j + 1 ];                 arr [ j + 1 ] = temp ;             }         }     }     printf ( " \n " );     for ( int i = 0 ; i < n ; i ++ ){         printf ( " %d " , arr [ i ]);     }     return ...