Wednesday, 19 July 2017

Difference Between Union and Enum

Union 


Union is user defined data type which is use to store a data member from more than one data member. Followings are some key point about union
  • Union is also a user defined data type But only one member can be saved at a time
  • A common space allocated for all member
  • Only one member can be initialized at a time.
  • Space allocated equal to higher member allocated space.
  • Only one member value can be read or write at ones.
  • Uses rate is lower than structure due common space allocation.
  • If a member initialized and another attempt for change value of other member lead loss of previous value. 
#include<stdio.h>
union emp
{
     int roll;
     char nm[10];
     char city[10];
};
void main()
{
     union emp ob2;     

     ob2.roll=101;
     printf("\nSize of Union\t %d",sizeof(ob2));
     printf("\nUnion Roll %d",ob2.roll);
     strcpy(ob2.nm,"Girfa");
     printf("\nValue Loss due to Union  %d",ob2.nm); 
}

Enum

Enumerate is user defined data type which is integer value assign to a data member as its options. Enumerate is useful to provide user friendly name for available integer options used as some setting of application. For example if an application has shown available color to its window by integer number as we have seen in dos color command.

So for change color you need to remember color code which increase complexity. By using enumeration you provide color name in user friendly mode.
i.e.  Color.Red,Color.Blue instead of integer code. System will find the correspondence integer related to given color by enumeration definition.

Saturday, 15 July 2017

Greatest Number from array using Pointer

Q : Write a program using pointer to find greatest number in an array.

Solution : 

#include<stdio.h>
#define MAX 5
void main()
{
     int ar[MAX],*pt,h,i;
     for(i=0;i<MAX;i++)
     {
          printf("Enter Number>> ");
          scanf("%d",&ar[i]);
     }

Table read with Java Script


This is how I consummate reading a table in javascript. Basically I study down into the rows and then I was able to drill down into the individual cells for each row. This should give you an idea.

Roll Name City
101 Sona Varanasi
102 Mona Chandauli
103 Amit Jaunpur





<html>
<head>
    <title>Girfa Student Help : Table read with javascript</title>
    <script>
        function GetData()
        {

Bitwise operator


Logical Operators

Logical operators are used to make a decision on behalf of some criteria. We evaluate given criteria in terms of (and,or,not). Decision making process changed with given terms. If AND  is used there then all given criteria must be true to become result true and in case of OR , condition become true if any given criteria return true. Not reverse result True to false and vice versa.