Archive | September 2013

Super Video Graphics Array or Ultra Video Graphics Array, almost always abbreviated to Super VGAUltra VGA or just SVGA or UVGA is a broad term that covers a wide range of computer display standards.

Originally, it was an extension to the VGA standard first released by IBM in 1987. Unlike VGA—a purely IBM-defined standard—Super VGA was never formally defined. The closest to an “official” definition was in the VBEextensions defined by the Video Electronics Standards Association (VESA), an open consortium set up to promote interoperability and define standards. In this document, there was simply a footnote stating that “The term ‘Super VGA’ is used in this document for a graphics display controller implementing any superset of the standard IBM VGA display adapter.” When used as a resolution specification, in contrast to VGA or XGA for example, the term SVGA normally refers to a resolution of 800 × 600 pixels.

Though Super VGA cards appeared in the same year as VGA (1987), it wasn’t until 1989 that a standard for programming Super VGA modes was defined by VESA. In that first version, it defined support for (but did not require) a maximum resolution of 800 × 600 4-bit pixels. Each pixel could therefore be any of 16 different colours. It was quickly extended to 1024 × 768 8-bit pixels, and well beyond that in the following years.

Although the number of colours is defined in the VBE specification, this is irrelevant when referring to Super VGAmonitors as (in contrast to the old CGA and EGA standards) the interface between the video card and the VGA or Super VGA monitor uses simple analog voltages to indicate the desired colour. In consequence, so far as the monitor is concerned, there is no theoretical limit to the number of different colours that can be displayed. Note that this applies to any VGA or Super VGA monitor.

While the output of a VGA or Super VGA video card is analog, the internal calculations the card performs in order to arrive at these output voltages are entirely digital. To increase the number of colours a Super VGA display system can reproduce, no change at all is needed for the monitor, but the video card needs to handle much larger numbers and may well need to be redesigned from scratch. Even so, the leading graphics chip vendors were producing parts for high-colour video cards within just a few months of Super VGA’s introduction.

On paper, the original Super VGA was to be succeeded by Super XGA[citation needed], but in practice the industry soon abandoned the attempt to provide a unique name for each higher display standard, and almost all display systems made between the late 1990s and the early 2000s are classed as Super VGA.

Monitor manufacturers sometimes advertise their products as XGA or Super XGA. In practice this means little, since all Super VGA monitors manufactured since the later 1990s have been capable of at least XGA and usually considerably higher performance.

SVGA uses a VGA connector, the same DE-15 (a.k.a. HD-15) as the original standard.

File:Vector Video Standards2.svg

Advertisements

Difference between a Structure and a Union in C

With a union, you’re only supposed to use one of the elements, because they’re all stored at the same spot. This makes it useful when you want to store something that could be one of several types. A struct, on the other hand, has a separate memory location for each of its elements and they all can be used at once.

To give a concrete example of their use, I was working on a Scheme interpreter a little while ago and I was essentially overlaying the Scheme data types onto the C data types. This involved storing in a struct an enum indicating the type of value and a union to store that value.

union foo {
  int a;   // can't use both a and b at once
  char b;
} foo;

struct bar {
  int a;   // can use both a and b simultaneously
  char b;
} bar;

union foo x;
x.a = 3; // OK
x.b = 'c'; // NO! this affects the value of x.a!

struct bar y;
y.a = 3; // OK
y.b = 'c'; // OK

edit: If you’re wondering what setting x.b to ‘c’ changes the value of x.a to, technically speaking it’s undefined. On most modern machines a char is 1 byte and an int is 4 bytes, so giving x.b the value ‘c’ also gives the first byte of x.a that same value:

union foo x;
x.a = 3;
x.b = 'c';
printf("%i, %i\n", x.a, x.b);

prints

99, 99

Why are the two values the same? Because the last 3 bytes of the int 3 are all zero, so it’s also read as 99. If we put in a larger number for x.a, you’ll see that this is not always the case:

union foo x;
x.a = 387439;
x.b = 'c';
printf("%i, %i\n", x.a, x.b);

prints

387427, 99

To get a closer look at the actual memory values, let’s set and print out the values in hex:

union foo x;
x.a = 0xDEADBEEF;
x.b = 0x22;
printf("%x, %x\n", x.a, x.b);

prints

deadbe22, 22

write a function that sorts the smallest element in the array

Write a recursive function that finds and returns the minimum or smallest elemnt in an array, where the array and its size are given as parameters.

Solution:

#include <iostream>
using namespace std;

int smallest_element(int [], int size);

int main()
{
int array[5] = {9,-8,1,8,-7};
cout << “Smallest element of array is ” << smallest_element(array,5) << endl;
return 0;
}

//Function
int smallest_element(int array[], int counter)
{
int smallest;
if (counter == 1)
return array[0];
else
{
smallest = smallest_element(array+1,counter-1);
if (smallest < array[0])
return smallest;
else
return array[0];
}
}

differentiate b/w && and || with ex

There are some posts that asks what the difference between those two are already.
(why do I have to even mention this…)

But my question is different in a way that I am calling “throw ex” in another error god-like handling method.

public class Program
{
    public static void Main(string[] args)
    {
        try
        {
            // something
        }
        catch (Exception ex)
        {
            HandleException(ex);
        }
    }

    private static void HandleException(Exception ex)
    {
        if (ex is ThreadAbortException)
        {
            // ignore then,
            return;
        }

        if (ex is ArgumentOutOfRangeException)
        {
            // Log then,
            throw ex;
        }

        if (ex is InvalidOperationException)
        {
            // Show message then,
            throw ex;
        }

        // and so on.
    }
}

DIFFERENT BETWEEN STRUCTURE & ARRAY

The following are the differences between structures and arrays:

– Array elements are homogeneous.

-Structure elements are of different data type.
– Array allocates static memory and uses index / subscript for accessing elements of the array.

-Structures allocate dynamic memory and uses (.) operator for accessing the member of a structure.
– Array is a pointer to the first element of it.

-Structure is not a pointer
– Array element access takes less time in comparison with structures.     

DIFFERENT BETWEEN STRING CONSTANT & CHARACTER CONSTANT

String constants

                 A string constant consists of zero or more character enclosed in quotation marks. Several string constants are given below.

       “Welcome to C Programming”                      “ ”

        “a+b\n”                                                          “Error\a\a\a”

                There is a difference between the constant ‘A’ and “A” in C, the first ‘A’ is a character constant while the second “A” is string constant. The notation ‘A’ is a constant occupying a single byte containing the ASCII code of the character A. The notation  “A”  on the other hand ,is a constant that occupies two bytes one for ASCII code of A and another for the null character with the value 0,that terminates all the string.

Example:

Top-down and bottom-up design

Top-down and bottom-up are both strategies of information processing and knowledge ordering, used in a variety of fields including software, humanistic and scientific theories (see systemics), and management and organization. In practice, they can be seen as a style of thinking and teaching.

top-down approach (also known as stepwise design or deductive reasoning, and in many cases used as a synonym of analysis or decomposition) is essentially the breaking down of a system to gain insight into its compositional sub-systems. In a top-down approach an overview of the system is formulated, specifying but not detailing any first-level subsystems. Each subsystem is then refined in yet greater detail, sometimes in many additional subsystem levels, until the entire specification is reduced to base elements. A top-down model is often specified with the assistance of “black boxes”, these make it easier to manipulate. However, black boxes may fail to elucidate elementary mechanisms or be detailed enough to realistically validate the model. Top down approach starts with the big picture. It breaks down from there into smaller segments.

bottom-up approach (also known as inductive reasoning, and in many cases used as a synonym of synthesis) is the piecing together of systems to give rise to grander systems, thus making the original systems sub-systems of the emergent system. Bottom-up processing is a type of information processing based on incoming data from the environment to form a perception. Information enters the eyes in one direction (input), and is then turned into an image by the brain that can be interpreted and recognized as a perception (output). In a bottom-up approach the individual base elements of the system are first specified in great detail. These elements are then linked together to form larger subsystems, which then in turn are linked, sometimes in many levels, until a complete top-level system is formed. This strategy often resembles a “seed” model, whereby the beginnings are small but eventually grow in complexity and completeness. However, “organic strategies” may result in a tangle of elements and subsystems, developed in isolation and subject to local optimization as opposed to meeting a global purpose.