Thursday, July 25, 2019

Bit field Sample C Code

/*Space optimized Structure representation of date */
#include <stdio.h>
struct date
{
         /* d has value between 1 and 31, so 5 bits are sufficient */
          unsigned int d: 5;
         /* m has value between 1 and 12, so 4 bits are sufficient */
         unsigned int m: 4;
         unsigned int y;
};
 
int main()
{
         printf("Size of date is %d bytes\n", sizeof(struct date));
         struct date dt = {31, 12, 2014};
         printf("Date is %d/%d/%d", dt.d, dt.m, dt.y);
         return 0;
}

Creation of Structure Pointer variable

#include<stdio.h>
#include<stdlib.h> /* For malloc() and free()*/
#include<string.h> /* For strcpy() */

struct test{
char name[10];
unsigned int rollno;
unsigned int marks;
};
int main()
{
struct test *ptr;
ptr = (struct test *)malloc(1*sizeof(struct test));
/* ptr->name = "Sreekanth"; Not allowed */
strcpy(ptr->name, "Sreekanth"); /* We should copy char by char or use strcpy() */
/* printf("Enter the name:"); scanf("%s",ptr->name); */
/* printf("Enter the Roll no:"); scanf("%d",&ptr->rollno);*/
ptr->rollno = 101;
ptr->marks = 555;
printf("Name: %s\n Roll no: %d\n Marks: %d\n",ptr->name, ptr->rollno, ptr->marks);
free(ptr);
return 0;
}

Tabata workout

Attended a session in KBR park on 09 May 2015.
Cross fit - High intensity workout with 10 Sec breaks.

1) Warm up:
 - Stretch your hands to backwards and keep it for  10 Sec
 - Rotate hands both forward and backward
 - Bend backwards and wait
 - Bend front and wait for 10 Sec

(1)
(2) Skipping
(3) Jogging
(4) Boxing



Bench push ups - Push up and wait for 5 Sec, 10
Mountain climb - 30
Sleep back and stretch forward (for abs)  - 10
Push ups by moving right and left sides (move both legs and hands)

The above whole cycle for 4/8 times.