Snippets Collections
DATA: zvorna TYPE vorna,
      znachn TYPE nachn,
      sep(1) TYPE c,
      adres1 TYPE PAD_STRAS,
      adres2 TYPE PAD_LOCAT,
      ZCTTYP TYPE CTTYP,
      BEGDA16 TYPE DATS,
      ZCTEDT TYPE DATS,
      lv_datum_ext TYPE char25,
      lv_exdatfm   TYPE xudatfm,
      ZGESCH TYPE GESCH, " جنسيت
      ZGBDAT TYPE GBDAT, " تاريخ تولد
      ZFAMST TYPE FAMST, " وضعيت تاهل
      ZSLART TYPE SLART, " مدرک تحصيلي 22
      ZFACH TYPE FACH1, " کد رشته تحصيلي
      ZPRBZT TYPE PRBZT, " عدد مدت قرارداد
      ZPRBZTS(3) TYPE C, " کاراکتر کردن براي کانکت عدد مدت قرارداد
      ZPRBEH TYPE EINHTXT, " زمان (ماه، روز و...) قرارداد
      ZTXTD(5) TYPE C, " ماه روز سال
      ZORGEH TYPE ORGEH,
      ZTEXTPOS TYPE STEXT,
      ZSTELL TYPE STELL.
*--------------قرارداد-------- PA0016
  SELECT SINGLE CTTYP BEGDA CTEDT PRBZT PRBEH FROM PA0016 INTO ( ZCTTYP, BEGDA16, ZCTEDT, ZPRBZT, ZPRBEH ) WHERE pernr = pernr AND begda le DATE AND endda ge DATE.
    IF sy-subrc NE 0. " اگر قرارداد نداشت خارج شود
      REJECT.
    ENDIF.
    clear lv_datum_ext.
    TRY. " تاريخ شمسي شروع قرارداد
      CALL METHOD cl_abap_datfm=>conv_date_int_to_ext
        EXPORTING
          im_datint    = BEGDA16
          im_datfmdes  = 'C'
        IMPORTING
          ex_datext    = lv_datum_ext
          ex_datfmused = lv_exdatfm.
    CATCH cx_abap_datfm_format_unknown .
  ENDTRY.
ZFULL-AZMODAT = lv_datum_ext.
clear lv_datum_ext.
    TRY. " تاريخ شمسي پايان قرارداد
      CALL METHOD cl_abap_datfm=>conv_date_int_to_ext
        EXPORTING
          im_datint    = ZCTEDT
          im_datfmdes  = 'C'
        IMPORTING
          ex_datext    = lv_datum_ext
          ex_datfmused = lv_exdatfm.
    CATCH cx_abap_datfm_format_unknown .
  ENDTRY.
ZFULL-TAMODAT = lv_datum_ext.
ZFULL-ZPERNR = pernr.
*--------------------- مشخص شدن مدت قرارداد
CASE ZPRBEH.
  WHEN '010'.
   ZTXTD = 'روز'.
  WHEN '011'.
   ZTXTD = 'هفته'.
  WHEN '012'.
   ZTXTD = 'ماه'.
  WHEN '013'.
   ZTXTD = 'سال'.
  WHEN OTHERS.
   ZTXTD = '-'.
ENDCASE.
ZPRBZTS = ZPRBZT.
CONCATENATE ZTXTD '-' ZPRBZTS INTO ZFULL-MODAT SEPARATED BY sep. " مثال 6 - ماه
*-------------------------------- select infotype 0002 -------------
SELECT SINGLE vorna nachn GESCH GBDAT ANZKD FAMST
  FROM PA0002 INTO ( zvorna, znachn, ZGESCH, ZGBDAT, ZFULL-FARZANDNUM, ZFAMST )
  WHERE pernr = pernr AND begda le BEGDA16 AND endda ge BEGDA16.
CONCATENATE zvorna znachn INTO ZFULL-NAMEFAMILY SEPARATED BY sep.

*---------------- تاريخ تولد
clear lv_datum_ext.
    TRY.
      CALL METHOD cl_abap_datfm=>conv_date_int_to_ext
        EXPORTING
          im_datint    = ZGBDAT
          im_datfmdes  = 'C'
        IMPORTING
          ex_datext    = lv_datum_ext
          ex_datfmused = lv_exdatfm.
    CATCH cx_abap_datfm_format_unknown .
  ENDTRY.
ZFULL-BORNDATE = lv_datum_ext.
*  *------------ جنسيت
IF ZGESCH EQ '1'.
ZFULL-ZJENSIAT = 'آقای'.
ELSE.
ZFULL-ZJENSIAT = 'خانم'.
ENDIF.
*-------------- وضعيت تاهل
CASE ZFAMST.
  WHEN '0'.
    ZFULL-VAZIATTAHOL = 'مجرد'.
  WHEN '1'.
    ZFULL-VAZIATTAHOL = 'متاهل'.
  WHEN '2'.
    ZFULL-VAZIATTAHOL = 'معيل'.
  WHEN '3'.
    ZFULL-VAZIATTAHOL = 'مطلقه'.
  WHEN '4'.
    ZFULL-VAZIATTAHOL = 'بيوه'.
  WHEN OTHERS.
    ZFULL-VAZIATTAHOL = '-'.
ENDCASE.

*################## ------------- کد ملي و شماره شناسنامه
  SELECT SINGLE ICNUM FROM PA0185 INTO ZFULL-SHOMARESHENAS WHERE subty eq '01' AND pernr = pernr AND begda le BEGDA16 AND endda ge BEGDA16.
  SELECT SINGLE ICNUM FROM PA0185 INTO ZFULL-CODEMELI WHERE subty eq '02' AND pernr = pernr AND begda le BEGDA16 AND endda ge BEGDA16.

*################## ------------- تحصيلات
  SELECT SINGLE SLART SLTP1 FROM PA0022 INTO ( ZSLART, ZFACH ) WHERE pernr = pernr AND begda le BEGDA16 AND endda ge BEGDA16.
SELECT SINGLE STEXT FROM T517T INTO ZFULL-MADRAKTAHSIL WHERE SLART EQ ZSLART AND SPRSL EQ 'E'.
SELECT SINGLE FTEXT FROM T517X INTO ZFULL-RESHTEH WHERE FAART EQ ZFACH AND LANGU EQ 'E'.

*------------------- آدرس
    SELECT SINGLE STRAS LOCAT FROM PA0006 INTO ( adres1, adres2 ) WHERE subty eq '1' AND pernr = pernr AND begda le BEGDA16 AND endda ge BEGDA16.
   CONCATENATE adres1 ' - ' adres2 INTO ZFULL-NESHANI SEPARATED BY sep.

*   ------------- موبايل
  SELECT SINGLE USRID FROM PA0105 INTO ZFULL-MOBILE WHERE subty EQ '0002' AND pernr = pernr AND begda le BEGDA16 AND endda ge BEGDA16 .


*    ----------------- حقوق پايه ############################ ماده چهار

INFOTYPES: 0000,0001,0002,0008,0021, 0007.
         data: it0008 type table of PBWLA WITH HEADER LINE,
               ws_0008 type PBWLA,
               _JAM TYPE zamount,
               _amt TYPE zamount,
               _maskan TYPE zamount,
               _bon TYPE zamount,
               wa_pa0000       TYPE pa0000,
               itab_pa0000     TYPE TABLE OF pa0000.
    CALL FUNCTION 'RP_FILL_WAGE_TYPE_TABLE_EXT'
   EXPORTING
     APPLI                              = 'E'
    BEGDA                              = BEGDA16
    ENDDA                              = BEGDA16
     INFTY                              = '0008'
     TCLAS                              = 'A'
     PERNR                              = PERNR
     SUBTY                              = '0   '
     DLSPL                              = 'X'

     CONV_CURR                          = 'X'
   TABLES
     PP0001                             = p0001
     PP0007                             = p0007
     PP0008                             = p0008
     PPBWLA                             = it0008
   .
     clear _JAM.

    loop at it0008 into ws_0008 .
  _JAM = _JAM + ws_0008-BETRG * 100.
   ZFULL-HOGHOGHPAYE = + ws_0008-BETRG * 100.
endloop.
  clear _amt.
select single BETRG from pa0014 into _amt where LGART = '3000' and pernr = PERNR and begda le BEGDA16 and endda ge BEGDA16.
  _JAM = _JAM + _amt * 100.
  _maskan = _amt * 100.
  clear _amt.
  select single BETRG from pa0014 into _amt where LGART = '3003' and pernr = PERNR and begda le BEGDA16 and endda ge BEGDA16.
  _JAM = _JAM + _amt * 100.
  _bon = _amt * 100.
    clear _amt.
  select single BETRG from pa0014 into _amt where LGART = '3002' and pernr = PERNR and begda le BEGDA16 and endda ge BEGDA16.
  _JAM = _JAM + _amt * 100.
  ZFULL-HAGHMASOLIAT = _amt * 100.
    clear _amt.
  select single BETRG from pa0014 into _amt where LGART = '3026' and pernr = PERNR and begda le BEGDA16 and endda ge BEGDA16.
  _JAM = _JAM + _amt * 100.
  ZFULL-HAGHROTBEH = _amt * 100.
    clear _amt.
  select single BETRG from pa0014 into _amt where LGART = '3001' and pernr = PERNR and begda le BEGDA16 and endda ge BEGDA16.
  _JAM = _JAM + _amt * 100.
  ZFULL-HAGHOLAD = _amt * 100.

  ZFULL-JAMMAZAYA = _JAM.
  ZFULL-HAGHMASKANB = _maskan + _bon.



*  ------------ *--------------- واحد سازماني و عنوان شغلي
SELECT SINGLE ORGEH STELL FROM PA0001 INTO ( ZORGEH, ZSTELL ) WHERE pernr = pernr AND begda le BEGDA16 AND endda ge BEGDA16.
SELECT SINGLE ORGTX FROM T527X INTO ZFULL-ZPOSITION WHERE ORGEH EQ ZORGEH AND SPRSL EQ 'E'.
SELECT SINGLE STLTX FROM T513S INTO ZFULL-ZONVANJOB WHERE STELL EQ ZSTELL AND SPRSL EQ 'E'.

*  ------------------- تاريخ استخدام
      SELECT * FROM pa0000 INTO TABLE itab_pa0000 WHERE pernr EQ pernr
          AND ( massn EQ '01' or massn EQ '12' ) . "پيدا کردن حکم استخدام يا بازگشت به کار
    SORT itab_pa0000 BY endda DESCENDING.
    READ TABLE itab_pa0000 INTO wa_pa0000 INDEX 1.
    TRY.
        CALL METHOD cl_abap_datfm=>conv_date_int_to_ext
          EXPORTING
            im_datint    = wa_pa0000-begda
            im_datfmdes  = 'C'
          IMPORTING
            ex_datext    = lv_datum_ext
            ex_datfmused = lv_exdatfm.
      CATCH cx_abap_datfm_format_unknown .
    ENDTRY.
    ZFULL-ESTEKHDAM = lv_datum_ext.

BREAK pmohammadi.
*    -------------------------------------- barcode signiture mohr ******************
    DATA: end type dats,
barcodetext type c LENGTH 200,
    START_DATE  TYPE  CHAR10,
    END_DATE  TYPE  CHAR10,
      text type c LENGTH 20,
      _emzaDate type ZTARKHCON.
PerNum = pernr.
*------------------------------------------------------------------------ barcode
SELECT SINGLE CTEDT ZZTARIKH FROM PA0016 INTO ( end, _emzaDate ) WHERE PERNR = PERNR AND BEGDA LE DATE AND CTEDT GE DATE.
if _emzadate is not initial or _emzadate ne '00000000'.
       TRY.
      CALL METHOD cl_abap_datfm=>conv_date_int_to_ext
        EXPORTING
          im_datint    = _emzaDate
          im_datfmdes  = 'C'
        IMPORTING
          ex_datext    = emza_date.
*          ex_datfmused = lv_exdatfm.
    CATCH cx_abap_datfm_format_unknown .
  ENDTRY.
  barcodetext = 'شماره پرسنلي:'.
  CONCATENATE  barcodetext pernum into barcodetext SEPARATED BY ' '.
  text = 'تاريخ شروع قرارداد:'.
  CONCATENATE  barcodetext text START_DATE into barcodetext SEPARATED BY ' '.
  text = 'تاريخ پايان قرارداد:'.
  CONCATENATE  barcodetext text end_DATE into barcodetext SEPARATED BY ' '.
 text = 'تاریخ امضای کارمند:'.
  CONCATENATE  barcodetext text emza_DATE into barcodetext SEPARATED BY ' '.

  barcode = barcodetext.
 endif.

* --------------------------------------------------------------------------- mohr
 CONSTANTS : gc_btype TYPE tdbtype VALUE 'BCOL',
gc_id TYPE tdidgr VALUE 'BMAP',
gc_object TYPE tdobjectgr VALUE 'GRAPHICS'.
 DATA: gv_name TYPE tdobname,
        kcompany TYPE BUKRS,
        sabtnum TYPE char10,
        sabtdate TYPE char10,
        COMPANY TYPE char64,
        emptype TYPE char12,
gv_name_mohr TYPE tdobname,
gv_name_sign TYPE tdobname,
gv_logo TYPE xstring ,
gv_bmp TYPE xstring.
 SELECT SINGLE BUKRS FROM PA0001 INTO  kcompany  WHERE PERNR = PERNR AND BEGDA LE DATE AND endda GE DATE.
if kcompany eq '1200' .
  gv_name = 'MECO'.
  gv_name_mohr = 'MECOMOHR'.
  gv_name_sign = 'SIGNATURE'.
  sabtnum = '70826'.
  sabtdate = '72/10/12'.
  concatenate 'شرکت ' company into company separated by ' '.
 endif.

 CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
EXPORTING
p_object = gc_object " GRAPHICS
p_name = gv_name_MOHR " Name of the Logo
p_id = gc_id " BMAP
p_btype = gc_btype " BCOL for color, 'BMON' for Black & White
RECEIVING
p_bmp = gv_bmp
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
mohr = gv_bmp.

*------------------------------------------------------------------------ signiture
DATA: saghff type char7,
      KARKARDSA TYPE char3,
zsaghf TYPE THOUR.
SELECT SINGLE anzhl FROM pa2012 INTO zsaghf WHERE pernr EQ pernr AND begda LE DATE AND endda GE DATE AND subty EQ 'ZEMH'.
saghff = zsaghf.
KARKARDSA = saghff+0(3).
CONDENSE KARKARDSA.
*getting sinature pic
CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
EXPORTING
p_object = gc_object " GRAPHICS
p_name = gv_name_sign " Name of the Logo
p_id = gc_id " BMAP
p_btype = gc_btype " BCOL for color, 'BMON' for Black & White
RECEIVING
p_bmp = gv_bmp
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
SIGNATURE = gv_bmp.
#include <stdio.h>

enum Contains_Result
{
 ABSENT,
 PRESENT
};

enum Contains_Result contains(char* cstring, char find);

int main(void)
{
    char buffer1[] = "Hello Programming 1 Students";
    char buffer2[] = "Learn to program using arrays and pointers!";
    int found_d = contains(buffer1, 'd');
 
    if (found_d == PRESENT)
    {
        printf("buffer1 contains d\n");
    }
    else
    {
        printf("buffer1 does not contain d\n");
    }
 
    found_d = contains(buffer2, 'd');
 
    if (found_d == PRESENT)
    {
        printf("buffer2 contains d\n");
    }
    else
    {
        printf("buffer2 does not contain d\n");
    }
 
 	// The following function tests your code.
	// Do not modify the following code.
	test();
	
    return 0;
}

enum Contains_Result contains(char* cstring, char find)
{
 // TODO: Insert your code here...
 while (*cstring != '\0')
    {
        if (*cstring == find)
        {
            return PRESENT;
        }
        cstring++;
    }
    return ABSENT;
}
#include <stdio.h>

void draw_inverted_triangle(int height) {
    for (int i = 0; i < height; ++i) {
        // Print leading spaces
        for (int j = 0; j < i; ++j) {
            putchar(' ');
        }

        // Print backslash
        putchar('\\');

        // Print inner spaces
        for (int j = 0; j < 2 * (height - i - 1); ++j) {
            putchar(' ');
        }

        // Print forward slash
        putchar('/');

        // Move to the next line
        putchar('\n');
    }
}

int main() {
    int height;

    // Get the height from the user
    printf("enter height: \n");
    scanf("%d", &height);

    // Print the top line of underscores
    for (int i = 0; i < 2 * height; ++i) {
        putchar('_');
    }
    putchar('\n');

    // Draw the inverted triangle
    draw_inverted_triangle(height);

    return 0;
}
#include <stdio.h>

enum Day
{
    MONDAY,
    TUESDAY,
    WEDNESDAY,
    THURSDAY,
    FRIDAY,
    SATURDAY,
    SUNDAY
};

    
void print_day_category(enum Day day)
{
    if((day==MONDAY)||(day==TUESDAY)||(day==WEDNESDAY)||(day==THURSDAY)||(day==FRIDAY))
    {
        printf("Weekday\n");
    }
    else
    {
        printf("Weekend\n");
    }
}
void print_day_name(enum Day day)
{
    
    
        if(day==MONDAY)
        {
            printf("Monday");
            
        }
        if(day==TUESDAY)
        {
            printf("Tuesday");
           
        }
        if(day==WEDNESDAY)
        {
            printf("Wednesday");
           
        }
        if(day==THURSDAY)
        {
            printf("Thursday");
           
        }
        if(day==FRIDAY)
        {
            printf("Friday");
            
        }
        if(day==SATURDAY)
        {
            printf("Saturday");
            
        }
        if(day==SUNDAY)
        {
            printf("Sunday");
            
        }

}

int main(void)
{
    //keep this
	for (int i = 0; i < 70; i++)
	{
		print_day_name(i%7);
		printf(" is a ");
		print_day_category(i%7);
		printf("\n");
	}
	return 0;
}
#include <stdio.h>

enum Day
{
    MONDAY,
    TUESDAY,
    WEDNESDAY,
    THURSDAY,
    FRIDAY,
    SATURDAY,
    SUNDAY
};

    
void print_day_category(enum Day day)
{
    if((day==MONDAY)||(day==TUESDAY)||(day==WEDNESDAY)||(day==THURSDAY)||(day==FRIDAY))
    {
        printf("Weekday\n");
    }
    else
    {
        printf("Weekend\n");
    }
}
void print_day_name(enum Day day)
{
    
    
        if(day==MONDAY)
        {
            printf("Monday");
            
        }
        if(day==TUESDAY)
        {
            printf("Tuesday");
           
        }
        if(day==WEDNESDAY)
        {
            printf("Wednesday");
           
        }
        if(day==THURSDAY)
        {
            printf("Thursday");
           
        }
        if(day==FRIDAY)
        {
            printf("Friday");
            
        }
        if(day==SATURDAY)
        {
            printf("Saturday");
            
        }
        if(day==SUNDAY)
        {
            printf("Sunday");
            
        }

}

int main(void)
{
    //keep this
	for (int i = 0; i < 70; i++)
	{
		print_day_name(i%7);
		printf(" is a ");
		print_day_category(i%7);
		printf("\n");
	}
	return 0;
}
#include <stdio.h>

void print_array(int *p_array, int num_elements);
void zero_out_array(int *p_array, int num_elements);
int main(void)
{
	int main_array[] = { 15, 24, 33, 42, 51 };

	// TODO: Insert code here...
	int num_elements = sizeof(main_array)/sizeof(main_array[0]);
	
	print_array(main_array,num_elements);
    zero_out_array(main_array,num_elements);
    print_array(main_array,num_elements);
	return 0;
}

void print_array(int *p_array, int num_elements)
{
	printf("print_array called:\n");
	// TODO: Insert code here...
	for(int i = 0; i < num_elements; i++)
	{
	    printf("%d ",p_array[i]);
	}
	printf("\n\n");
}

void zero_out_array(int *p_array, int num_elements)
{
	printf("zero_out_array called:\n\n");
	// TODO: Insert code here...
	for(int i = 0; i < num_elements; i++)
	{
	    *(p_array+i) = 0;
	}
}
#include <stdio.h>

int find_min_index(int* numbers, int length);

int main(void)
{
    int array1[] = { 1, 3, 5, 7, 9, 11 };
    int array2[] = { 2, -4, 6, -8, 10, -12, 14, -16, 4 };
    int array3[] = { 6, 4, 1, 4, 5, 3, 2 };
 
    printf("Min's index in array1 is: %d\n", find_min_index(array1, 6));
    printf("Min's index in array2 is: %d\n", find_min_index(array2, 9));
    printf("Min's index in array3 is: %d\n", find_min_index(array3, 7));
 
    return 0;
}

int find_min_index(int* numbers, int length)
{
    // TODO: Insert your code here!
    
    int min_index = 0;
    
    for(int i = 0; i < length; i++)
    {
        if( numbers[i] < numbers[min_index] )
        {
            min_index = i;
        }
    }
    return min_index;
}
#include <stdio.h>

int count_odds(int* data_array, int size);

int main(void)
{
	int data_array_1[] = { 1, 3, 5, 7, 9, 11 };
	int data_array_2[] = { 2, -4, 6, -8, 10, -12, 14, -16 };
	int data_array_3[] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };

	int result_1 = count_odds(data_array_1, 6);
	printf("data_array_1 has %d odd numbers.\n", result_1);
	
	int result_2 = count_odds(data_array_2, 8);
	printf("data_array_2 has %d odd numbers.\n", result_2);
	
	int result_3 = count_odds(data_array_3, 11);
	printf("data_array_3 has %d odd numbers.\n", result_3);
	
	return 0;
}

// TODO: Insert your function definition here!
int count_odds(int* data_array, int size)
{
    int count = 0;
    
    
    for(int i =0; i < size ;i++)
    {
        if(data_array[i] > 0 && data_array[i] % 2 != 0)
        {
            count++;
        }
    }
    return count;
}
#include <stdio.h>

void cube(float* number);

int main(void)
{
	float x = 0.0f;

	printf("> ");
	scanf("%f", &x);

	// TODO: Call cube with x by reference...
	cube(&x);
	
	printf("x holds %f\n\n", x);

	return 0;
}

// TODO: Define cube function:
void cube(float* number)
{
    *number = (*number)*(*number)*(*number);
    
}
#include <stdio.h>
#include <math.h>

void compute_trig(float deg, float* sin_angle, float* cos_angle);

int main(void)
{
    float sin_result = 0.0f;
    float cos_result = 0.0f;
    float angle = 0.0f;
 
    printf("Angle? \n");
    scanf("%f", &angle);
    // TODO: Call compute_trig
    compute_trig(angle,&sin_result,&cos_result);
    
    printf("sin(%f) is %f\n", angle, sin_result);
    printf("cos(%f) is %f\n", angle, cos_result);
 
    return 0;
}

void compute_trig(float deg, float* sin_angle, float* cos_angle)
{
    float pi = 3.14159f;
    float radians = deg * pi / 180.0f;
    // TODO: Compute sine angle...
    *sin_angle = sinf(radians);
    
    // TODO: Compute cosine angle...
    *cos_angle = cosf(radians);
}
#include <stdio.h>

void increment(int* int_pointer);

int main(void)
{
	int x = 0;
	printf("> \n");
	scanf("%d", &x);
	// TODO: Call increment with x by reference
	increment(&x);
	printf("x holds %d\n\n", x);
	// TODO: Call increment with x by reference
	increment(&x);
	printf("x holds %d\n\n", x);
	// TODO: Call increment with x by reference
	increment(&x);
	printf("x holds %d\n\n", x);
	return 0;
}

// TODO: Define increment function:
void increment(int* int_pointer)
{
     (*int_pointer) ++;
    
}
#include <stdio.h>

struct Softdrink
{
	char name [16];
	int size;
	int energy;
	float caffeine;
	int max_daily;
};

void print_soft_drink(struct Softdrink a_soft_drink);

int main(void)
{
    struct Softdrink life_mod;

	sprintf(life_mod.name, "Life Modulus");
	life_mod.size = 250;
	life_mod.energy = 529;
	life_mod.caffeine = 80.5f;
	life_mod.max_daily = 500;

	print_soft_drink(life_mod);
	
	return 0;
}

void print_soft_drink(struct Softdrink a_soft_drink)
{
    
	printf("A soft drink...\n\n");
	printf("Name: %s\n",a_soft_drink.name);
	printf("Serving size: %d mL\n",a_soft_drink.size);
	printf("Energy content: %d kJ\n",a_soft_drink.energy);
	printf("Caffeine content: %f mg\n",a_soft_drink.caffeine);
	printf("Maximum daily intake: %d mL\n",a_soft_drink.max_daily);
}
#include <stdio.h>

// TODO: Declare Colour structure:
struct Colour
{
    unsigned char red;
    unsigned char green;
    unsigned char blue;
};

// TODO: Declare functions:
//struct Colour create_colour(...
struct Colour create_colour(unsigned char red, unsigned char green, unsigned char blue);
//void print_colour(...
void print_colour(struct Colour a_colour);

int main(void)
{
	print_colour(create_colour(255, 0, 0)); // RED
	print_colour(create_colour(0, 255, 0)); // GREEN
	print_colour(create_colour(0, 0, 255)); // BLUE
	print_colour(create_colour(255, 255, 0)); // YELLOW
	print_colour(create_colour(255, 0, 127)); // PINK

	return 0;
}

// TODO: Define functions:
struct Colour create_colour(unsigned char red, unsigned char green, unsigned char blue)
{
	struct Colour colour;
	colour.red = red;
	colour.green = green;
	colour.blue = blue;
	
	return colour;
}

void print_colour(struct Colour a_colour)
{
    printf("RGB: %u, %u, %u\n",a_colour.red,a_colour.green,a_colour.blue);
}
selector li a::before{
    opacity: 1 !important;
    position: relative;
    transform: translateY(2px);
    z-index: 2 !important;
}

selector li a{
    gap: 6px !important;
    z-index: 2 !important;
}
.nav-home a::before{
    content: url(https://ways2learn.co.il/wp-content/uploads/Mask-Group-62.svg) !important;
}
.nav-blog a::before{
    content: url(https://ways2learn.co.il/wp-content/uploads/Mask-Group-64.svg) !important;
}
.nav-courses a::before{
    content: url(https://ways2learn.co.il/wp-content/uploads/Mask-Group-71.svg) !important;
}

.nav-reco a::before{
    content: url(https://ways2learn.co.il/wp-content/uploads/v.svg) !important;
}
.nav-school a::before{
    content: url(https://ways2learn.co.il/wp-content/uploads/elearning-icon-1.svg) !important;
}

selector li:hover a:after{
    content: '';
    width: calc(100% - 4px);
    height: calc(100% - 4px);
    background-color: #fff;
    position: absolute;
    left: 2px;
    top: 2px;
    border-radius: 50px;
    z-index: -2;
}

selector li:hover, selector .elementor-item-active{
    background-image: linear-gradient(90deg, #1BC5E4, #7C19FF);
    border-radius: 50px !important;
}

selector .elementor-item-active:hover:after{
    content: none !important;
}

selector li{
    border-radius: 50px !important;
}

selector li a{
    transition: all 0s !important;
}

selector .menu-item a.elementor-item-active::before{
    filter: brightness(0) invert(1) !important;
}

selector .elementor-nav-menu{
    gap: 8px;
}

@media (max-width: 1224px){
    selector .elementor-nav-menu--dropdown{
        width: 300px !important;
        padding:10px !important;
    }
    selector .elementor-nav-menu--dropdown a{
        max-width: 300px !important;
        margin-bottom: 5px !important;
    }
class Node<T extends Comparable<T>> {
    T data;
    Node<T> next;

    public Node(T data) {
        this.data = data;
        this.next = null;
    }
}

public class SortedChain<T extends Comparable<T>> {
    private Node<T> head;

    public void insert(T data) {
        Node<T> newNode = new Node<>(data);
        
        if (head == null || head.data.compareTo(data) >= 0) {
            newNode.next = head;
            head = newNode;
        } else {
            Node<T> current = head;
            while (current.next != null && current.next.data.compareTo(data) < 0) {
                current = current.next;
            }
            newNode.next = current.next;
            current.next = newNode;
        }
    }

    public void display() {
        Node<T> current = head;
        while (current != null) {
            System.out.print(current.data + " ");
            current = current.next;
        }
        System.out.println();
    }

    public static void main(String[] args) {
        SortedChain<Integer> sortedChain = new SortedChain<>();
        sortedChain.insert(5);
        sortedChain.insert(3);
        sortedChain.insert(7);
        sortedChain.insert(1);
        sortedChain.insert(9);

        System.out.println("Sorted Chain:");
        sortedChain.display();
    }
}
import java.util.LinkedList;

class SeparateChainingHashTable {
    private static final int TABLE_SIZE = 10;
    LinkedList<String>[] hashTable;

    public SeparateChainingHashTable() {
        hashTable = new LinkedList[TABLE_SIZE];
        for (int i = 0; i < TABLE_SIZE; i++) {
            hashTable[i] = new LinkedList<>();
        }
    }

    public int hash(String key) {
        return Math.abs(key.hashCode() % TABLE_SIZE);
    }

    public void insert(String key, String value) {
        int index = hash(key);
        hashTable[index].add(value);
    }

    public boolean search(String key, String value) {
        int index = hash(key);
        return hashTable[index].contains(value);
    }

    public void display() {
        System.out.println("Hash Table Contents:");

        for (int i = 0; i < TABLE_SIZE; i++) {
            System.out.print("Index " + i + ": ");
            if (!hashTable[i].isEmpty()) {
                for (String value : hashTable[i]) {
                    System.out.print(value + " -> ");
                }
            }  
            System.out.println();
        }
        
    }

    public static void main(String[] args) {
        SeparateChainingHashTable hashTable = new SeparateChainingHashTable();

        // Insert some key-value pairs
        hashTable.insert("John", "Doe");
        hashTable.insert("Jane", "Smith");
        hashTable.insert("Alice", "Johnson");
        hashTable.insert("Smith", "Williams");

        // Display contents
        hashTable.display();

        // Search for values
        System.out.println("Searching for 'Doe': " + hashTable.search("John", "Doe"));
 
    }
}
public class LinearProbingHashTable {
    private String[] keys;
    private String[] values;
    private int size;
    private int capacity;

    // Constructor
    public LinearProbingHashTable(int capacity) {
        this.capacity = capacity;
        this.keys = new String[capacity];
        this.values = new String[capacity];
        this.size = 0;
    }

    // Hash function (simple demonstration using string length)
    private int hash(String key) {
        return key.length() % capacity;
    }

    // Insert key-value pair into the hash table
    public void put(String key, String value) {
        if (key == null || value == null) {
            throw new IllegalArgumentException("Key or value cannot be null.");
        }
        
        int index = hash(key);
        while (keys[index] != null) {
            if (keys[index].equals(key)) {
                // Update value if key already exists
                values[index] = value;
                return;
            }
            // Linear probing to find next available slot
            index = (index + 1) % capacity;
        }
        // Insert key-value pair
        keys[index] = key;
        values[index] = value;
        size++;
    }

    // Get value associated with the given key
    public String get(String key) {
        int index = hash(key);
        while (keys[index] != null) {
            if (keys[index].equals(key)) {
                return values[index];
            }
            // Linear probing to search for key
            index = (index + 1) % capacity;
        }
        return null; // Key not found
    }

    // Display hash table contents
    public void display() {
        for (int i = 0; i < capacity; i++) {
            if (keys[i] != null) {
                System.out.println("Key: " + keys[i] + ", Value: " + values[i]);
            }
        }
    }

    public static void main(String[] args) {
        LinearProbingHashTable hashTable = new LinearProbingHashTable(10);
        
        // Insert key-value pairs
        hashTable.put("John", "Doe");
        hashTable.put("Alice", "Smith");
        hashTable.put("Bob", "Johnson");
        hashTable.put("Charlie", "Brown");
        
        // Display hash table contents
        hashTable.display();
        
        // Retrieve values
        System.out.println("Value associated with 'John': " + hashTable.get("John"));
        System.out.println("Value associated with 'Alice': " + hashTable.get("Alice"));
        System.out.println("Value associated with 'Bob': " + hashTable.get("Bob"));
        System.out.println("Value associated with 'Charlie': " + hashTable.get("Charlie"));
        System.out.println("Value associated with 'Dave': " + hashTable.get("Dave")); // Not found
    }
}
import java.util.*;

public class TreeMapExample {
    public static void main(String[] args) {
        // Creating a TreeMap
        TreeMap<Integer, String> treeMap = new TreeMap<>();

        // Adding elements to the TreeMap
        treeMap.put(1, "Apple");
		 treeMap.put(4, "Mango");
        treeMap.put(5, "Grapes");
        treeMap.put(2, "Banana");
        treeMap.put(3, "Orange");
       

        // Printing the TreeMap
        System.out.println("TreeMap: " + treeMap);

        // Getting the size of the TreeMap
        System.out.println("Size of TreeMap: " + treeMap.size());

        // Checking if TreeMap is empty
        System.out.println("Is TreeMap empty? " + treeMap.isEmpty());

        // Getting value associated with a key
        System.out.println("Value associated with key 3: " + treeMap.get(3));

        // Checking if TreeMap contains a key
        System.out.println("Does TreeMap contain key 4? " + treeMap.containsKey(4));

        // Checking if TreeMap contains a value
        System.out.println("Does TreeMap contain value 'Grapes'? " + treeMap.containsValue("Grapes"));

        // Removing an element from TreeMap
        treeMap.remove(2);
        System.out.println("After removing key 2: " + treeMap);

        // Getting the first key and value
        System.out.println("First key in TreeMap: " + treeMap.firstKey());
        System.out.println("First value in TreeMap: " + treeMap.firstEntry().getValue());

        // Getting the last key and value
        System.out.println("Last key in TreeMap: " + treeMap.lastKey());
        System.out.println("Last value in TreeMap: " + treeMap.lastEntry().getValue());

        // Getting a submap from TreeMap
        SortedMap<Integer, String> subMap = treeMap.subMap(1, 4);
        System.out.println("Submap from key 1 to key 3: " + subMap);

        // Clearing the TreeMap
        treeMap.clear();
        System.out.println("TreeMap after clearing: " + treeMap);
    }
}
import java.util.LinkedHashMap;
import java.util.Map;

public class LinkedHashMapExample {
    public static void main(String[] args) {
        // Creating a LinkedHashMap
        LinkedHashMap<Integer, String> linkedHashMap = new LinkedHashMap<>();

        // Adding elements to the LinkedHashMap
        linkedHashMap.put(1, "Apple");
        linkedHashMap.put(2, "Banana");
        linkedHashMap.put(3, "Orange");
        linkedHashMap.put(4, "Grapes");
        linkedHashMap.put(5, "Mango");

        // Displaying the elements in the LinkedHashMap
        System.out.println("LinkedHashMap elements:");
        for (Map.Entry<Integer, String> entry : linkedHashMap.entrySet()) {
            System.out.println(entry.getKey() + " => " + entry.getValue());
        }

        // Removing an element from the LinkedHashMap
        String removedElement = linkedHashMap.remove(2);
        System.out.println("Removed element with key 2: " + removedElement);

        // Checking if a key exists in the LinkedHashMap
        boolean containsKey = linkedHashMap.containsKey(3);
        System.out.println("LinkedHashMap contains key 3: " + containsKey);

        // Checking if a value exists in the LinkedHashMap
        boolean containsValue = linkedHashMap.containsValue("Banana");
        System.out.println("LinkedHashMap contains value 'Banana': " + containsValue);

        // Getting a value from the LinkedHashMap
        String value = linkedHashMap.get(4);
        System.out.println("Value associated with key 4: " + value);

        // Iterating over the elements in the LinkedHashMap using an Iterator
        System.out.println("Iterating over LinkedHashMap elements using Iterator:");
        for (Map.Entry<Integer, String> entry : linkedHashMap.entrySet()) {
            System.out.println(entry.getKey() + " => " + entry.getValue());
        }

        // Clearing the LinkedHashMap
        linkedHashMap.clear();
        System.out.println("LinkedHashMap cleared. Current size: " + linkedHashMap.size());
    }
}
import java.util.*;
import java.util.Map;

public class HashMapExample {
    public static void main(String[] args) {
        // Create a new HashMap instance
        Map<String, Integer> ageMap = new LinkedHashMap<>();

        // Add key-value pairs to the map
        ageMap.put("John", 30);
        ageMap.put("Alice", 25);
        ageMap.put("Bob", 35);
        ageMap.put("Eve", 28);

        // Access values using keys
        System.out.println("Age of John: " + ageMap.get("John"));
        System.out.println("Age of Alice: " + ageMap.get("Alice"));

        // Update the value associated with a key
        ageMap.put("John", 32);
        System.out.println("Updated age of John: " + ageMap.get("John"));

        // Check if a key exists in the map
        String name = "Bob";
        if (ageMap.containsKey(name)) {
            System.out.println(name + " exists in the map.");
        } else {
            System.out.println(name + " does not exist in the map.");
        }

        // Remove a key-value pair from the map
        ageMap.remove("Eve");
        System.out.println("Map after removing Eve: " + ageMap);

        // Iterate over the map entries
        System.out.println("Iterating over map entries:");
        for (Map.Entry<String, Integer> entry : ageMap.entrySet()) {
            System.out.println(entry.getKey() + " : " + entry.getValue());
        }

        // Clear the map
        ageMap.clear();
        System.out.println("Map after clearing: " + ageMap);
    }
}
import java.util.TreeSet;
import java.util.Iterator;

public class TreeSets {
    public static void main(String[] args) {
        // Creating a TreeSet
        TreeSet<String> treeSet = new TreeSet<>();

        // Adding elements to the TreeSet
        treeSet.add("Apple");
        treeSet.add("Banana");
        treeSet.add("Orange");
        treeSet.add("Grapes");
        treeSet.add("Mango");

        // Trying to add a duplicate element
        boolean added = treeSet.add("Apple");
         
        boolean removed = treeSet.remove("Banana");
   
            System.out.println("Element 'Banana' removed from the TreeSet.");
         

        // Checking if an element exists in the TreeSet
        boolean contains = treeSet.contains("Orange");
        System.out.println("TreeSet contains 'Orange': " + contains);

        // Iterating over the elements in the TreeSet using an Iterator
        System.out.println("Iterating over TreeSet elements using Iterator:");
        Iterator<String> iterator = treeSet.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

        // Getting the first and last elements
        System.out.println("First element: " + treeSet.first());
        System.out.println("Last element: " + treeSet.last());

        // Clearing the TreeSet
        treeSet.clear();
        System.out.println("TreeSet cleared. Current size: " + treeSet.size());
    }
}
import java.util.HashSet;
import java.util.Iterator;

public class Main {
    public static void main(String[] args) {
        // Creating a HashSet
        HashSet<String> hashSet = new HashSet<>();

        // Adding elements to the HashSet
        hashSet.add("Apple");
        hashSet.add("Banana");
        hashSet.add("Orange");
        hashSet.add("Grapes");
        hashSet.add("Mango");

        
        // Removing an element from the HashSet
        boolean removed = hashSet.remove("Banana");
     
            System.out.println("Element 'Banana' removed from the HashSet.");
       

        // Checking if an element exists in the HashSet
        boolean contains = hashSet.contains("Orange");
        System.out.println("HashSet contains 'Orange': " + contains);

        // Iterating over the elements in the HashSet using an Iterator
        System.out.println("Iterating over HashSet elements using Iterator:");
        Iterator<String> iterator = hashSet.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

        // Clearing the HashSet
        hashSet.clear();
        System.out.println("HashSet cleared. Current size: " + hashSet.size());
    }
}
import java.util.LinkedHashSet;
import java.util.Iterator;

public class LinkedHashSetDemo {
    public static void main(String[] args) {
        
        LinkedHashSet<String> lhs= new LinkedHashSet<>();
        
        lhs.add("Apple");
        lhs.add("Banana");
        lhs.add("Orange");
        lhs.add("Grapes");
        lhs.add("Watermelon");
        System.out.println("LinkedHashSet: " + lhs);        
        System.out.println("Contains 'Banana'? " + lhs.contains("Banana"));        
        System.out.println("Is the LinkedHashSet empty? " + lhs.isEmpty());        
        System.out.println("Size of the LinkedHashSet: " + lhs.size());       
        lhs.remove("Orange");
        System.out.println("LinkedHashSet after removing 'Orange': " + lhs);
        lhs.clear();
        System.out.println("LinkedHashSet after clearing: " + lhs);
        lhs.add("Apple");
        lhs.add("Banana");
        lhs.add("Orange");
        System.out.println("Iteration using Iterator:");
        Iterator<String> iterator = lhs.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        Object[] array = lhs.toArray();
        System.out.print("LinkedHashSet as Array: ");
        for (Object element : array) {
            System.out.print(element + " ");
        }
        System.out.println();
        System.out.println("Hash code of the LinkedHashSet: " + lhs.hashCode());
    }
}
//GenericArrayListQueue
import java.util.ArrayList;

public class GenericArrayListQueue<T> {
    private ArrayList<T> queueList;

    public GenericArrayListQueue() {
        queueList = new ArrayList<>();
    }

    public void enqueue(T value) {
        queueList.add(value);
    }

    public T dequeue() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            return queueList.remove(0);
        }
    }

    public T peek() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            return queueList.get(0);
        }
    }

    public boolean isEmpty() {
        return queueList.isEmpty();
    }

    public int size() {
        return queueList.size();
    }
}
//Main
public class Main {
    public static void main(String[] args) {
        // Queue for Integers
        GenericArrayListQueue<Integer> intQueue = new GenericArrayListQueue<>();
        intQueue.enqueue(1);
        intQueue.enqueue(2);
        System.out.println(intQueue.dequeue());  // Output: 1
        System.out.println(intQueue.peek()); // Output: 2

        // Queue for Doubles
        GenericArrayListQueue<Double> doubleQueue = new GenericArrayListQueue<>();
        doubleQueue.enqueue(1.1);
        doubleQueue.enqueue(2.2);
        System.out.println(doubleQueue.dequeue());  // Output: 1.1
        System.out.println(doubleQueue.peek()); // Output: 2.2

        // Queue for Strings
        GenericArrayListQueue<String> stringQueue = new GenericArrayListQueue<>();
        stringQueue.enqueue("Hello");
        stringQueue.enqueue("World");
        System.out.println(stringQueue.dequeue());  // Output: Hello
        System.out.println(stringQueue.peek()); // Output: World
    }
}
//GenericLinkedListQueue
import java.util.LinkedList;

public class GenericLinkedListQueue<T> {
    private LinkedList<T> queueList;

    public GenericLinkedListQueue() {
        queueList = new LinkedList<>();
    }

    public void enqueue(T value) {
        queueList.addLast(value);
    }

    public T dequeue() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            return queueList.removeFirst();
        }
    }

    public T peek() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            return queueList.getFirst();
        }
    }

    public boolean isEmpty() {
        return queueList.isEmpty();
    }

    public int size() {
        return queueList.size();
    }
}
//Main
public class Main {
    public static void main(String[] args) {
        // Queue for Integers
        GenericLinkedListQueue<Integer> intQueue = new GenericLinkedListQueue<>();
        intQueue.enqueue(1);
        intQueue.enqueue(2);
        System.out.println(intQueue.dequeue());  // Output: 1
        System.out.println(intQueue.peek()); // Output: 2

        // Queue for Doubles
        GenericLinkedListQueue<Double> doubleQueue = new GenericLinkedListQueue<>();
        doubleQueue.enqueue(1.1);
        doubleQueue.enqueue(2.2);
        System.out.println(doubleQueue.dequeue());  // Output: 1.1
        System.out.println(doubleQueue.peek()); // Output: 2.2

        // Queue for Strings
        GenericLinkedListQueue<String> stringQueue = new GenericLinkedListQueue<>();
        stringQueue.enqueue("Hello");
        stringQueue.enqueue("World");
        System.out.println(stringQueue.dequeue());  // Output: Hello
        System.out.println(stringQueue.peek()); // Output: World
    }
}
//GenericLinkedListStack
import java.util.LinkedList;

public class GenericLinkedListStack<T> {
    private LinkedList<T> stackList;

    public GenericLinkedListStack() {
        stackList = new LinkedList<>();
    }

    public void push(T value) {
        stackList.addFirst(value);
    }

    public T pop() {
        if (isEmpty()) {
            System.out.println("Stack is empty.");
            return null;
        } else {
            return stackList.removeFirst();
        }
    }

    public T peek() {
        if (isEmpty()) {
            System.out.println("Stack is empty.");
            return null;
        } else {
            return stackList.getFirst();
        }
    }

    public boolean isEmpty() {
        return stackList.isEmpty();
    }

    public int size() {
        return stackList.size();
    }
}
//Main
public class Main {
    public static void main(String[] args) {
        // Stack for Integers
        GenericLinkedListStack<Integer> intStack = new GenericLinkedListStack<>();
        intStack.push(1);
        intStack.push(2);
        System.out.println(intStack.pop());  // Output: 2
        System.out.println(intStack.peek()); // Output: 1

        // Stack for Doubles
        GenericLinkedListStack<Double> doubleStack = new GenericLinkedListStack<>();
        doubleStack.push(1.1);
        doubleStack.push(2.2);
        System.out.println(doubleStack.pop());  // Output: 2.2
        System.out.println(doubleStack.peek()); // Output: 1.1

        // Stack for Strings
        GenericLinkedListStack<String> stringStack = new GenericLinkedListStack<>();
        stringStack.push("Hello");
        stringStack.push("World");
        System.out.println(stringStack.pop());  // Output: World
        System.out.println(stringStack.peek()); // Output: Hello
    }
}
import java.util.ArrayList;
//GenericArrayListStack
public class GenericArrayListStack<T> {
    private ArrayList<T> stackList;

    public GenericArrayListStack() {
        stackList = new ArrayList<>();
    }

    public void push(T value) {
        stackList.add(value);
    }

    public T pop() {
        if (isEmpty()) {
            System.out.println("Stack is empty.");
            return null;
        } else {
            return stackList.remove(stackList.size() - 1);
        }
    }

    public T peek() {
        if (isEmpty()) {
            System.out.println("Stack is empty.");
            return null;
        } else {
            return stackList.get(stackList.size() - 1);
        }
    }

    public boolean isEmpty() {
        return stackList.isEmpty();
    }

    public int size() {
        return stackList.size();
    }
}
//Main
public class Main {
    public static void main(String[] args) {
        // Stack for Integers
        GenericArrayListStack<Integer> intStack = new GenericArrayListStack<>();
        intStack.push(1);
        intStack.push(2);
        System.out.println(intStack.pop());  // Output: 2
        System.out.println(intStack.peek()); // Output: 1

        // Stack for Doubles
        GenericArrayListStack<Double> doubleStack = new GenericArrayListStack<>();
        doubleStack.push(1.1);
        doubleStack.push(2.2);
        System.out.println(doubleStack.pop());  // Output: 2.2
        System.out.println(doubleStack.peek()); // Output: 1.1

        // Stack for Strings
        GenericArrayListStack<String> stringStack = new GenericArrayListStack<>();
        stringStack.push("Hello");
        stringStack.push("World");
        System.out.println(stringStack.pop());  // Output: World
        System.out.println(stringStack.peek()); // Output: Hello
    }
}
//GenericArrayQueue
public class GenericArrayQueue<T> {
    private T[] queueArray;
    private int front;
    private int rear;
    private int maxSize;
    private int currentSize;

    @SuppressWarnings("unchecked")
    public GenericArrayQueue(int size) {
        maxSize = size;
        queueArray = (T[]) new Object[maxSize];
        front = 0;
        rear = -1;
        currentSize = 0;
    }

    public void enqueue(T value) {
        if (isFull()) {
            System.out.println("Queue is full.");
        } else {
            rear = (rear + 1) % maxSize;
            queueArray[rear] = value;
            currentSize++;
        }
    }

    public T dequeue() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            T temp = queueArray[front];
            front = (front + 1) % maxSize;
            currentSize--;
            return temp;
        }
    }

    public T peek() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            return queueArray[front];
        }
    }

    public boolean isEmpty() {
        return (currentSize == 0);
    }
    
    public boolean isFull() {
        return (currentSize == maxSize);
    }

    public int size() {
        return currentSize;
    }
}
//Node.java
public class Node<T> {
    T data;
    Node<T> next;

    public Node(T data) {
        this.data = data;
        this.next = null;
    }
}
//GenericLinkedListQueue
public class GenericLinkedListQueue<T> {
    private Node<T> front;
    private Node<T> rear;
    private int size;

    public GenericLinkedListQueue() {
        front = null;
        rear = null;
        size = 0;
    }

    public void enqueue(T value) {
        Node<T> newNode = new Node<>(value);
        if (isEmpty()) {
            front = newNode;
        } else {
            rear.next = newNode;
        }
        rear = newNode;
        size++;
    }

    public T dequeue() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            T value = front.data;
            front = front.next;
            if (front == null) {
                rear = null;
            }
            size--;
            return value;
        }
    }

    public T peek() {
        if (isEmpty()) {
            System.out.println("Queue is empty.");
            return null;
        } else {
            return front.data;
        }
    }

    public boolean isEmpty() {
        return (size == 0);
    }

    public int size() {
        return size;
    }
}
//Main
public class Main {
    public static void main(String[] args) {
        // Array-based queue
        GenericArrayQueue<Integer> intArrayQueue = new GenericArrayQueue<>(10);
        intArrayQueue.enqueue(1);
        intArrayQueue.enqueue(2);
        System.out.println(intArrayQueue.dequeue());  // Output: 1
        System.out.println(intArrayQueue.peek()); // Output: 2

        GenericArrayQueue<Double> doubleArrayQueue = new GenericArrayQueue<>(10);
        doubleArrayQueue.enqueue(1.1);
        doubleArrayQueue.enqueue(2.2);
        System.out.println(doubleArrayQueue.dequeue());  // Output: 1.1
        System.out.println(doubleArrayQueue.peek()); // Output: 2.2

        GenericArrayQueue<String> stringArrayQueue = new GenericArrayQueue<>(10);
        stringArrayQueue.enqueue("Hello");
        stringArrayQueue.enqueue("World");
        System.out.println(stringArrayQueue.dequeue());  // Output: Hello
        System.out.println(stringArrayQueue.peek()); // Output: World

        // Linked list-based queue
        GenericLinkedListQueue<Integer> intLinkedListQueue = new GenericLinkedListQueue<>();
        intLinkedListQueue.enqueue(1);
        intLinkedListQueue.enqueue(2);
        System.out.println(intLinkedListQueue.dequeue());  // Output: 1
        System.out.println(intLinkedListQueue.peek()); // Output: 2

        GenericLinkedListQueue<Double> doubleLinkedListQueue = new GenericLinkedListQueue<>();
        doubleLinkedListQueue.enqueue(1.1);
        doubleLinkedListQueue.enqueue(2.2);
        System.out.println(doubleLinkedListQueue.dequeue());  // Output: 1.1
        System.out.println(doubleLinkedListQueue.peek()); // Output: 2.2

        GenericLinkedListQueue<String> stringLinkedListQueue = new GenericLinkedListQueue<>();
        stringLinkedListQueue.enqueue("Hello");
        stringLinkedListQueue.enqueue("World");
        System.out.println(stringLinkedListQueue.dequeue());  // Output: Hello
        System.out.println(stringLinkedListQueue.peek()); // Output: World
    }
}
import java.util.Scanner;

class Node<T> {
    T data;
    Node<T> next;

    public Node(T data) {
        this.data = data;
        this.next = null;
    }
}

class GenericStackArray<T> {
    private T[] stackArray;
    private int top;
    private int maxSize;

    @SuppressWarnings("unchecked")
    public GenericStackArray(int size) {
        this.maxSize = size;
        this.stackArray = (T[]) new Object[maxSize];
        this.top = -1;
    }

    public void push(T item) {
        if (top < maxSize - 1) {
            stackArray[++top] = item;
        } else {
            System.out.println("Stack Overflow");
        }
    }

    public T pop() {
        if (top >= 0) {
            return stackArray[top--];
        } else {
            System.out.println("Stack Underflow");
            return null;
        }
    }
public T peek() {
        if (top == -1) {
            System.out.println("Stack is empty.");
            return null;
        } else {
            return stackArray[top];
        }
    }

    public boolean isEmpty() {
        return top == -1;
    }
}

class GenericStackLinkedList<T> {
    private Node<T> top;

    public GenericStackLinkedList() {
        this.top = null;
    }

    public void push(T item) {
        Node<T> newNode = new Node<>(item);
        newNode.next = top;
        top = newNode;
    }

    public T pop() {
        if (top == null) {
            System.out.println("Stack Underflow");
            return null;
        }
        T data = top.data;
        top = top.next;
        return data;
    }
public T peek() {
        if (top == null) {
            System.out.println("Stack is empty.");
            return null;
        } else {
            return top.data;
        }
    }
    public boolean isEmpty() {
        return top == null;
    }
}

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("ARRAY....");
        GenericStackArray<Integer> intArrayStack = new GenericStackArray<>(10);
        intArrayStack.push(1);
        intArrayStack.push(2);
        System.out.println(intArrayStack.pop());  // Output: 2
        System.out.println(intArrayStack.peek()); // Output: 1

        GenericStackArray<Double> doubleArrayStack = new GenericStackArray<>(10);
        doubleArrayStack.push(1.1);
        doubleArrayStack.push(2.2);
        System.out.println(doubleArrayStack.pop());  // Output: 2.2
        System.out.println(doubleArrayStack.peek()); // Output: 1.1

        GenericStackArray<String> stringArrayStack = new GenericStackArray<>(10);
        stringArrayStack.push("Hello");
        stringArrayStack.push("World");
        System.out.println(stringArrayStack.pop());  // Output: World
        System.out.println(stringArrayStack.peek()); // Output: Hello

System.out.println("\nLINKED LIST....");
        // Linked list-based stack
        GenericStackLinkedList<Integer> intLinkedListStack = new GenericStackLinkedList<>();
        intLinkedListStack.push(1);
        intLinkedListStack.push(2);
        System.out.println(intLinkedListStack.pop());  // Output: 2
        System.out.println(intLinkedListStack.peek()); // Output: 1

        GenericStackLinkedList<Double> doubleLinkedListStack = new GenericStackLinkedList<>();
        doubleLinkedListStack.push(1.1);
        doubleLinkedListStack.push(2.2);
        System.out.println(doubleLinkedListStack.pop());  // Output: 2.2
        System.out.println(doubleLinkedListStack.peek()); // Output: 1.1

        GenericStackLinkedList<String> stringLinkedListStack = new GenericStackLinkedList<>();
        stringLinkedListStack.push("Hello");
        stringLinkedListStack.push("World");
        System.out.println(stringLinkedListStack.pop());  // Output: World
        System.out.println(stringLinkedListStack.peek()); // Output: Hello
}
}
const saveUserData = async (req, res, next) => {
  try {
    if (!Array.isArray(req.body.users)) {
      return res.status(400).json({ message: 'Invalid input format' });
    }

    const results = [];
    const errors = [];

    for (const user of req.body.users) {
      try {
        const saveUser = new saveuser({
          email: user.email,
          password: user.password,
        });

        const savedUser = await saveUser.save();
        const userID = savedUser._id;

        const saveDetail = new saveUserDetails({
          user_id: userID,
          name: user.name,
          phone: user.phone,
          country: user.country,
          file: user.file.filename,
        });

        const savedDetail = await saveDetail.save();

        results.push({
          status: 'success',
          user: savedUser,
          details: savedDetail,
        });
      } catch (error) {
        if (user.file && user.file.path && fs.existsSync(user.file.path)) {
          fs.unlinkSync(user.file.path);
        }
        if (error.name === 'ValidationError') {
          const validationError = {};
          for (const key in error.errors) {
            validationError[key] = error.errors[key].message;
          }
          errors.push({
            user: user,
            error: validationError,
          });
        } else {
          errors.push({
            user: user,
            error: 'Server Error',
          });
        }
      }
    }

    if (errors.length > 0) {
      return res.status(207).json({ results, errors });
    }

    res.status(200).json({ results });
  } catch (error) {
    res.status(500).json({
      message: 'Server Error',
    });
  }
};
//ReverseStringLambda
public class ReverseStringLambda {
    @FunctionalInterface
    interface StringReverser {
        String reverse(String str);
    }
    public static void main(String[] args) {
        StringReverser reverser = (str) -> new StringBuilder(str).reverse().toString();
        String example = "Hello, World!";
        String reversed = reverser.reverse(example);
        System.out.println("Original: " + example);
        System.out.println("Reversed: " + reversed);
    }
}
public class PiLambdaExpression{
    @FunctionalInterface
    interface PiValue{
        double getPi();
    }
    public static void main(String[] args) {
        PiValue pi = () -> Math.PI;
        double p= pi.getPi();
        System.out.println("The value of Pi is: " + p);
    }
}
//BoundedType
public class BoundedArithematic<T extends Number> {
    public double add(T a, T b) {
        return a.doubleValue() + b.doubleValue();
    }
    public double subtract(T a, T b) {
        return a.doubleValue() - b.doubleValue();
    }
    public double multiply(T a, T b) {
        return a.doubleValue() * b.doubleValue();
    }	
   public double divide(T a, T b) {
        if (b.doubleValue() == 0) {
            throw new ArithmeticException("Division by zero is not allowed.");
        }
        return a.doubleValue() / b.doubleValue();
    }
    public static void main(String[] args) {
        BoundedArithematic<Number> calculator = new BoundedArithematic<>();
        Integer a = 10;
        Integer b = 5;
        System.out.println("Addition: " + calculator.add(a, b));
        System.out.println("Subtraction: " + calculator.subtract(a, b));
        System.out.println("Multiplication: " + calculator.multiply(a, b));
        System.out.println("Division: " + calculator.divide(a, b));
    }
}

//Wildcard Arguments
public class MagicBox<T> {
    private T item;

    public void addItem(T item) {
        this.item = item;
        System.out.println("Added item to the magic box: " + item);
    }

    public T getItem() {
                return item;
    }

    public void processBox(MagicBox<? super Integer> box) {
        System.out.println("Items in the box are processed["+box.getItem()+"]"); 
    }

    public static void main(String[] args) {
        
        MagicBox<Integer> integerBox = new MagicBox<>();
        integerBox.addItem(23);
        		
		MagicBox<String> stringBox = new MagicBox<>();
        stringBox.addItem("Shreya");
        	
		
        MagicBox<Boolean> booleanBox = new MagicBox<>();
        booleanBox.addItem(false);
        
		MagicBox<Object> dobubleBox = new MagicBox<>();
        dobubleBox.addItem(23.43);
		
		integerBox.processBox(integerBox);
		dobubleBox.processBox(dobubleBox);
		
		
		
        
    }
}
class AVLNode {
    int key;
    int height;
    AVLNode left;
    AVLNode right;

    public AVLNode(int key) {
        this.key = key;
        this.height = 1;
    }
}

public class AVLTree {
    private AVLNode root;

    public AVLTree() {
        root = null;
    }

    // Insert a key into the AVL tree
    public void insert(int key) {
        root = insertRec(root, key);
    }

    // Helper method to recursively insert a key into the AVL tree
    private AVLNode insertRec(AVLNode node, int key) {
        if (node == null)
            return new AVLNode(key);

        if (key < node.key)
            node.left = insertRec(node.left, key);
        else if (key > node.key)
            node.right = insertRec(node.right, key);
        else // Duplicate keys are not allowed
            return node;

        // Update height of this node
        node.height = 1 + Math.max(height(node.left), height(node.right));

        // Get balance factor and perform rotations if needed
        int balance = getBalance(node);

        // Left Left Case
        if (balance > 1 && key < node.left.key)
            return rightRotate(node);

        // Right Right Case
        if (balance < -1 && key > node.right.key)
            return leftRotate(node);

        // Left Right Case
        if (balance > 1 && key > node.left.key) {
            node.left = leftRotate(node.left);
            return rightRotate(node);
        }

        // Right Left Case
        if (balance < -1 && key < node.right.key) {
            node.right = rightRotate(node.right);
            return leftRotate(node);
        }

        return node;
    }

    // Perform right rotation
    private AVLNode rightRotate(AVLNode y) {
        AVLNode x = y.left;
        AVLNode T2 = x.right;

        // Perform rotation
        x.right = y;
        y.left = T2;

        // Update heights
        y.height = Math.max(height(y.left), height(y.right)) + 1;
        x.height = Math.max(height(x.left), height(x.right)) + 1;

        return x;
    }

    // Perform left rotation
    private AVLNode leftRotate(AVLNode x) {
        AVLNode y = x.right;
        AVLNode T2 = y.left;

        // Perform rotation
        y.left = x;
        x.right = T2;

        // Update heights
        x.height = Math.max(height(x.left), height(x.right)) + 1;
        y.height = Math.max(height(y.left), height(y.right)) + 1;

        return y;
    }

    // Get height of a node
    private int height(AVLNode node) {
        if (node == null)
            return 0;
        return node.height;
    }

    // Get balance factor of a node
    private int getBalance(AVLNode node) {
        if (node == null)
            return 0;
        return height(node.left) - height(node.right);
    }

    // Find the inorder successor
    private AVLNode minValueNode(AVLNode node) {
        AVLNode current = node;
        while (current.left != null)
            current = current.left;
        return current;
    }

    // Delete a key from the AVL tree
    public void delete(int key) {
        root = deleteRec(root, key);
    }

    // Helper method to recursively delete a key from the AVL tree
    private AVLNode deleteRec(AVLNode root, int key) {
        if (root == null)
            return root;

        if (key < root.key)
            root.left = deleteRec(root.left, key);
        else if (key > root.key)
            root.right = deleteRec(root.right, key);
        else {
            // Node to be deleted found

            // Case 1: Node with one child or no child
            if (root.left == null || root.right == null) {
                AVLNode temp = null;
                if (root.left != null)
                    temp = root.left;
                else
                    temp = root.right;

                // No child case
                if (temp == null) {
                    temp = root;
                    root = null;
                } else // One child case
                    root = temp; // Copy the contents of the non-empty child

                temp = null;
            } else {
                // Case 2: Node with two children
                AVLNode temp = minValueNode(root.right);
                root.key = temp.key;
                root.right = deleteRec(root.right, temp.key);
            }
        }

        // If the tree had only one node then return
        if (root == null)
            return root;

        // Update height of the current node
        root.height = 1 + Math.max(height(root.left), height(root.right));

        // Get balance factor and perform rotations if needed
        int balance = getBalance(root);

        // Left Left Case
        if (balance > 1 && getBalance(root.left) >= 0)
            return rightRotate(root);

        // Left Right Case
        if (balance > 1 && getBalance(root.left) < 0) {
            root.left = leftRotate(root.left);
            return rightRotate(root);
        }

        // Right Right Case
        if (balance < -1 && getBalance(root.right) <= 0)
            return leftRotate(root);

        // Right Left Case
        if (balance < -1 && getBalance(root.right) > 0) {
            root.right = rightRotate(root.right);
            return leftRotate(root);
        }

        return root;
    }

    // Inorder traversal of the AVL tree
    public void inorder() {
        inorderRec(root);
        System.out.println();
    }

    // Helper method to recursively perform inorder traversal of the AVL tree
    private void inorderRec(AVLNode root) {
        if (root != null) {
            inorderRec(root.left);
            System.out.print(root.key + " ");
            inorderRec(root.right);
        }
    }

    public static void main(String[] args) {
        AVLTree tree = new AVLTree();

        // Insert elements into the AVL tree
        tree.insert(9);
        tree.insert(5);
        tree.insert(10);
        tree.insert(0);
        tree.insert(6);
        tree.insert(11);
        tree.insert(-1);
        tree.insert(1);
        tree.insert(2);

        // Inorder traversal of the AVL tree
        System.out.println("Inorder traversal of AVL tree:");
        tree.inorder();

        // Delete an element from the AVL tree
        int keyToDelete = 10;
        System.out.println("Deleting key " + keyToDelete + " from AVL tree");
        tree.delete(keyToDelete);

        // Inorder traversal after deletion
        System.out.println("Inorder traversal after deletion:");
        tree.inorder();
    }
}
//ArrayList
import java.util.ArrayList;
import java.util.Iterator;

public class ArrayListIteratorExample {
    public static void main(String[] args) {
        ArrayList<String> fruits = new ArrayList<>();
        fruits.add("Apple");
        fruits.add("Banana");
        fruits.add("Cherry");
        
        Iterator<String> iterator = fruits.iterator();
        
        System.out.println("Using Iterator to traverse through the ArrayList:");
        while (iterator.hasNext()) {
            String fruit = iterator.next();
            System.out.println(fruit);
        }
        
        System.out.println("\nUsing for-each loop to traverse through the ArrayList:");
        for (String fruit : fruits) {
            System.out.println(fruit);
        }
        
        iterator = fruits.iterator(); // Reset the iterator
        while (iterator.hasNext()) {
            String fruit = iterator.next();
            if (fruit.startsWith("B")) {
                iterator.remove(); // Remove elements that start with "B"
            }
        }
        
        System.out.println("\nArrayList after removal of elements that start with 'B':");
        for (String fruit : fruits) {
            System.out.println(fruit);
        }
    }
}

//LinkedList
import java.util.LinkedList;
import java.util.Iterator;

public class LinkedListIteratorExample {
    public static void main(String[] args) {
        LinkedList<String> fruits = new LinkedList<>();
        fruits.add("Apple");
        fruits.add("Banana");
        fruits.add("Cherry");
        
        Iterator<String> iterator = fruits.iterator();
        
        System.out.println("Using Iterator to traverse through the LinkedList:");
        while (iterator.hasNext()) {
            String fruit = iterator.next();
            System.out.println(fruit);
        }
        
        System.out.println("\nUsing for-each loop to traverse through the LinkedList:");
        for (String fruit : fruits) {
            System.out.println(fruit);
        }
        
        iterator = fruits.iterator(); // Reset the iterator
        while (iterator.hasNext()) {
            String fruit = iterator.next();
            if (fruit.startsWith("B")) {
                iterator.remove(); 
            }
        }
        
        System.out.println("\nLinkedList after removal of elements that start with 'B':");
        for (String fruit : fruits) {
            System.out.println(fruit);
        }
    }
}
class TreeNode {
    int key;
    TreeNode left;
    TreeNode right;

    public TreeNode(int key) {
        this.key = key;
        this.left = null;
        this.right = null;
    }
}

public class BinarySearchTree {
    private TreeNode root;

    public BinarySearchTree() {
        root = null;
    }

    // Insert a key into the BST
    public void insert(int key) {
        root = insertRec(root, key);
    }

    // Helper method to recursively insert a key into the BST
    private TreeNode insertRec(TreeNode root, int key) {
        if (root == null) {
            root = new TreeNode(key);
            return root;
        }

        if (key < root.key)
            root.left = insertRec(root.left, key);
        else if (key > root.key)
            root.right = insertRec(root.right, key);

        return root;
    }

    // Inorder traversal of the BST
    public void inorder() {
        inorderRec(root);
        System.out.println();
    }

    // Helper method to recursively perform inorder traversal of the BST
    private void inorderRec(TreeNode root) {
        if (root != null) {
            inorderRec(root.left);
            System.out.print(root.key + " ");
            inorderRec(root.right);
        }
    }

    // Delete a key from the BST
    public void delete(int key) {
        root = deleteRec(root, key);
    }

    // Helper method to recursively delete a key from the BST
    private TreeNode deleteRec(TreeNode root, int key) {
        if (root == null)
            return root;

        // Search for the key to be deleted
        if (key < root.key)
            root.left = deleteRec(root.left, key);
        else if (key > root.key)
            root.right = deleteRec(root.right, key);
        else {
            // Key found, delete this node

            // Case 1: Node with only one child or no child
            if (root.left == null)
                return root.right;
            else if (root.right == null)
                return root.left;

            // Case 2: Node with two children
            // Get the inorder successor (smallest in the right subtree)
            root.key = minValue(root.right);

            // Delete the inorder successor
            root.right = deleteRec(root.right, root.key);
        }

        return root;
    }

    // Helper method to find the inorder successor (smallest in the right subtree)
    private int minValue(TreeNode node) {
        int minValue = node.key;
        while (node.left != null) {
            minValue = node.left.key;
            node = node.left;
        }
        return minValue;
    }

    public static void main(String[] args) {
        BinarySearchTree tree = new BinarySearchTree();

        // Insert elements into the BST
        tree.insert(50);
        tree.insert(30);
        tree.insert(20);
        tree.insert(40);
        tree.insert(70);
        tree.insert(60);
        tree.insert(80);

        // Inorder traversal of the BST
        System.out.println("Inorder traversal of BST:");
        tree.inorder();

        // Delete an element from the BST
        int keyToDelete = 30;
        System.out.println("Deleting key " + keyToDelete + " from BST");
        tree.delete(keyToDelete);

        // Inorder traversal after deletion
        System.out.println("Inorder traversal after deletion:");
        tree.inorder();
    }
}
<html>
<body>
<form action = "sucess.html">
<h1><ul>Registration</hl>
<label>uname :</label>
<input type = "Text" id = "u1"><br>

password:<input type = "password" id="pr"><br>

email:<input type = "Text"><br>

Gender:<input type="radio" id="r1">male
       <input type="radio" id="r1">female
       <input type="radio" id="r1">none

state:
 <select>
 <option value = "TS">TS
 <option value = "AP">AP
 <option value = "TN">TN
 <option value = "BHR">BHR
 </select>

course:<input type="checkbox">java
       <input type="checkbox">se
       <input type="checkbox">wt
       textarea.min=70,max=1000
<button type:"submit"value="click.me"> 
<html>
<body>
<form action ="successfull.html">
<h1>Registration</h1>
<lable>username:<lable>
<input type="text"id=U1><br><br>
<lable>password:<lable>
<input type="password"id="pr"><br><br>
<lable>email:<lable>
<input type="text"id="pr"><br><br>
<lable>gender:<lable>
<input type="radio"id="R1">maless
<input type="radio"id="R2">female<br><br>
state:
<select><br>
<option value="TS">TS
<option value="AP">AP
</select><br>
course:<input type="checkbox">java
	<input type="checkbox">SE
	<input type="checkbox">WT
<lable>remark:<lable><br>
<input type="textarea"min=50><br>	
<button type:"submit">submit
void setup() 
     {  // initialize digital pin LED_BUILTIN as an output.           	
         pinMode(LED_BUILTIN, OUTPUT);
      }
void loop() {  
     digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on
            delay(1000);   // wait for a second 
     digitalWrite(LED_BUILTIN, LOW);   // turn the LED off
            delay(1000);   // wait for a second
}
import RPi.GPIO as GPIO
from time import sleep
GPIO.setwarnings(false)
GPIO.setmode(GPIO.BCM)
Blink_count=3
count=0
LEDPin=17
GPIO.setup(LEDPin,GPIO.OUT)
try:
	while count < Blink_count:
    	GPIO.output(LEDPin,False)
		print("LED OFF")
		sleep(1)
		count+=1
finally:
	GPIO.cleanup()
<html>
<body> 
<br><br>
<br>
<p align="center">
<b>SUCCESSFUL</b>
</html>
</body>
int trig=12;     // GPIO Pin D6
int echo=14;     //GPIO Pin D5
int time_microsec;
int time_ms;
int dist_cm;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(12,OUTPUT);
  pinMode(14,INPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(trig,LOW);
delayMicroseconds(2);
digitalWrite(trig,HIGH);
delayMicroseconds(10);
digitalWrite(trig,LOW);

//pulseIn gives time in micro seconds, 1Sec= 1000000 microseconds
time_microsec= pulseIn(echo,HIGH);
time_ms=time_microsec/1000;

dist_cm= (34*time_ms)/2;

Serial.print("Time to travel: ");
Serial.println(time_ms,1);
Serial.print("ms / ");
Serial.print("Distance: ");
Serial.print(dist_cm,1);
Serial.print("cm ");

delay(2000);
import RPi.GPIO as GPIO  
import time  
GPIO.setmode(GPIO.BCM)  
GPIO_TRIG = 11 
 GPIO_ECHO = 18 
GPIO.setup(GPIO_TRIG, GPIO.OUT) 
GPIO.setup(GPIO_ECHO, GPIO.IN)
GPIO.output(GPIO_TRIG, GPIO.LOW) 
 Time.sleep(2)  
GPIO.output(GPIO_TRIG, GPIO.HIGH) 
 Time.sleep(0.00001)  
GPIO.output(GPIO_TRIG, GPIO.LOW) 
 while GPIO.input(GPIO_ECHO)==0:  
  start_time = time.time()  
while GPIO.input(GPIO_ECHO)==1: 
 Bounce_back_time = time.time()  
 pulse_duration = Bounce_back_time - start_time 
 distance = round(pulse_duration * 17150, 2)  
print (f"Distance: {distance} cm")  
GPIO.cleanup()
#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN,DHTTYPE);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println(F("DHTxx test!"));
  dht.begin();

}

void loop() {
  // put your main code here, to run repeatedly:
  delay(2000);
  float h= dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);
  if(isnan(h)||isnan(t)||isnan(f))
  {
    Serial.println(F("Failed to read fromDHT sensor !"));
    return;
  }
  Serial.print(F("Humidity : "));
  Serial.print(h);
  Serial.print(F("% Temperature : "));
  Serial.print(t);
  Serial.print(F(" C : "));
  Serial.print(f);
  Serial.print(F(" F : "));
  Serial.println(" ");
  

}
$ git remote add origin https://github.com/OWNER/REPOSITORY.git
# Set a new remote

$ git remote -v
# Verify new remote
> origin  https://github.com/OWNER/REPOSITORY.git (fetch)
> origin  https://github.com/OWNER/REPOSITORY.git (push)
#include <stdio.h>

// Function to print the top part of the decorative box
void print_top() {
    printf("/\\/\\/\\/\\/\\\n");
}

// Function to print the bottom part of the decorative box
void print_bottom() {
    printf("\\/\\/\\/\\/\\/\n");
}

// Function to print the middle part of the decorative box
void print_middle(int how_many) {
    for (int i = 0; i < how_many; i++) {
        printf("\\        /\n");
        printf("/        \\\n");
    }
}

// Main function to demonstrate the functionality
int main() {
    int how_many;

    // Prompt the user for the number of middle parts
    printf("How many middle parts? \n");
    scanf("%d", &how_many);

    // Print the top part
    print_top();
    
    // Print the middle part specified number of times
    print_middle(how_many);
    
    // Print the bottom part
    print_bottom();
    
    return 0;
}
#include <stdio.h>

void print_ascii_rectangle(char symbol, int width, int height)
{
    for(int i =0;i<height;i++)
    {
        for(int j=0;j<width;j++)
        {
            printf("%c",symbol);
        }
        printf("\n");
    }
}

int main()
{
    char symbol;
    int width;
    int height;
    printf("Please enter an ASCII symbol:\n");
    scanf(" %c",&symbol);
    
    printf("Please enter the width:\n");
    scanf("%d",&width);
    printf("Please enter the height:\n");
    scanf("%d",&height);
    print_ascii_rectangle(symbol,width,height);
}
<div class="container text-center">
  <div class="row align-items-end">
    <div class="col">
      One of three columns
    </div>
    <div class="col">
      One of three columns
    </div>
    <div class="col">
      One of three columns
    </div>
  </div>
</div>
star

Sun Jun 09 2024 11:52:22 GMT+0000 (Coordinated Universal Time)

@payammhmd

star

Sun Jun 09 2024 11:45:30 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c #pointer

star

Sun Jun 09 2024 11:36:42 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sun Jun 09 2024 11:35:40 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sun Jun 09 2024 11:35:40 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sun Jun 09 2024 11:33:11 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c #pointer

star

Sun Jun 09 2024 11:32:00 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c #pointer

star

Sun Jun 09 2024 11:30:52 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c #pointer

star

Sun Jun 09 2024 11:29:47 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c #pointer

star

Sun Jun 09 2024 11:28:59 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c #pointer

star

Sun Jun 09 2024 11:27:57 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sun Jun 09 2024 11:26:45 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sun Jun 09 2024 11:10:04 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sun Jun 09 2024 10:43:55 GMT+0000 (Coordinated Universal Time)

@odesign

star

Sun Jun 09 2024 10:37:51 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:29:01 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:24:07 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:23:11 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:21:43 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:19:16 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:17:11 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:15:19 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 10:09:15 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:59:59 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:58:26 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:50:27 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:48:54 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:45:52 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:42:49 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:40:12 GMT+0000 (Coordinated Universal Time)

@sid_balar

star

Sun Jun 09 2024 09:07:48 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:07:15 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 09:06:02 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 07:43:09 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 07:40:44 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 07:17:04 GMT+0000 (Coordinated Universal Time)

@login

star

Sun Jun 09 2024 04:52:06 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:51:34 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:51:13 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:50:55 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:50:28 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:49:56 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:49:24 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 04:49:01 GMT+0000 (Coordinated Universal Time)

@user01

star

Sun Jun 09 2024 00:07:29 GMT+0000 (Coordinated Universal Time) https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories

@calazar23

star

Sat Jun 08 2024 23:59:25 GMT+0000 (Coordinated Universal Time) https://docs.github.com/en/repositories/creating-and-managing-repositories/transferring-a-repository

@calazar23

star

Sat Jun 08 2024 22:11:09 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sat Jun 08 2024 21:53:55 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sat Jun 08 2024 16:30:33 GMT+0000 (Coordinated Universal Time) https://getbootstrap.com/docs/5.3/layout/columns/

@CHIBUIKE

star

Sat Jun 08 2024 15:24:09 GMT+0000 (Coordinated Universal Time) https://nodejs.org/api/net.html#socketunref

@calazar23

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension