C - Structure. What is structure in C Language?

A structure is a collection of one or more variables, possibly of different types, grouped together under a single name for convenient handling. Structures help to organize complicated data, particularly in large programs, because they permit a group of related variables to be treated as a unit instead of as separate entities.

The keyword struct introduces a structure declaration, which is a list of declarations enclosed in braces. An optional name called a structure tag may follow the word struct (as with point here). The tag names this kind of structure, and can be used subsequently as a shorthand for the part of the declaration in braces.

The variables named in a structure are called members. A structure member or tag and an ordinary variable can have the same name without conflict, since they can always be distinguished by context. Furthermore, the same member names may occur in different structures, although as a matter of style one would normally use the same names only for closely related objects.

Uses of C structures:

    1. 1. C Structures can be used to store huge data. Structures act as a database.
    2. 2. C Structures can be used to send data to the printer.
    3. 3. C Structures can interact with keyboard and mouse to store the data.
    4. 4. C Structures can be used in drawing and floppy formatting.
    5. 5. C Structures can be used to clear output screen contents.
    6. 6. C Structures can be used to check computer’s memory size etc.

Difference between C variable, C array and C structure:

    • 1. A normal C variable can hold only one data of one data type at a time.
    • 2. An array can hold group of data of same data type.
    • 3. A structure can hold group of data of different data types
    • 4. Data types can be int, char, float, double and long double etc. 
Datatype

C variable

C array

C structure

Syntax Example Syntax Example Syntax Example
int int a a = 20 int a[3] a[0] = 10
a[1] = 20
a[2] = 30
a[3] = ‘\0′
struct student
{
int a;
char b[10];
}
a = 10
b = “Hello”
char char b b=’Z’ char b[10] b=”Hello”

Below table explains following concepts in C structure.

    1. 1. How to declare a C structure?
    2. 2. How to initialize a C structure?
    3. 3. How to access the members of a C structure?
Type Using normal variable Using pointer variabe
Syntax struct tag_name
{
data type var_name1;
data type var_name2;
data type var_name3;
};
struct tag_name
{
data type var_name1;
data type var_name2;
data type var_name3;
};
Example struct student
{
int  mark;
char name[10];
float average;
};
struct student
{
int  mark;
char name[10];
float average;
};
Declaring structure variable struct student report; struct student *report, rep;
Initializing structure variable struct student report = {100, “Mani”, 99.5}; struct student rep = {100, “Mani”, 99.5};  report = &rep;
Accessing structure members report.mark
report.name
report.average
report  -> mark
report -> name
report -> average

 Example program for C structure:

           This program is used to store and access “id, name and percentage” for one student. We can also store and access these data for many students using array of structures. You can check “C – Array of Structures“ to know how to store and access these data for many students.

#include <stdio.h>
#include <string.h>

struct student
{
           int id;
           char name[20];
           float percentage;
};

int main()
{
           struct student record = {0}; //Initializing to null

           record.id=1;
           strcpy(record.name, "Caroline");
           record.percentage = 86.5;

           printf(" Id is: %d \n", record.id);
           printf(" Name is: %s \n", record.name);
           printf(" Percentage is: %f \n", record.percentage);
           return 0;
}

Output:

Id is: 1
Name is: Caroline
Percentage is: 86.500000

Example program – Another way of declaring C structure:

           In this program, structure variable “record” is declared while declaring structure itself. In above structure example program, structure variable “struct student record” is declared inside main function which is after declaring structure.
#include <stdio.h>
#include <string.h>

struct student
{
            int id;
            char name[20];
            float percentage;
} record;

int main()
{

            record.id=1;
            strcpy(record.name, "Raju");
            record.percentage = 86.5;

            printf(" Id is: %d \n", record.id);
            printf(" Name is: %s \n", record.name);
            printf(" Percentage is: %f \n", record.percentage);
            return 0;
}

Output:

Id is: 1
Name is: Raju
Percentage is: 86.500000

C structure declaration in separate header file:

In above structure programs, C structure is declared in main source file. Instead of declaring C structure in main source file, we can have this structure declaration in another file called “header file” and we can include that header file in main source file as shown below.
Header file name – structure.h

Before compiling and executing below C program, create a file named “structure.h” and declare the below structure.

struct student
{
int id;
char name[20];
float percentage;
} record;
Main file name – structure.c:

           In this program, above created header file is included in “structure.c” source file as #include “Structure.h”. So, the structure declared in “structure.h” file can be used in “structure.c” source file.
// File name - structure.c
#include <stdio.h>
#include <string.h>
#include "structure.h"   /* header file where C structure is
                            declared */

int main()
{

   record.id=1;
   strcpy(record.name, "Raju");
   record.percentage = 86.5;

   printf(" Id is: %d \n", record.id);
   printf(" Name is: %s \n", record.name);
   printf(" Percentage is: %f \n", record.percentage);
   return 0;
}

Output:

Id is: 1
Name is: Raju
Percentage is: 86.500000


ramayani

What Is The Difference Between 32-bit & 64-bit Windows?

“What is the difference between a 32-bit and 64-bit Windows operating system?” Most of you are running Windows XP or Vista in its 32-bit iteration. But as hardware gets cheaper, people are curious as to what the 64-bit operating system has to offer. First let’s see if we can grasp the difference between 32- and 64-bit.

Think of your computer as a series of tubes that can either be 32 or 64 bits wide. When you have the smaller 32-bit size, there is more potential for bottlenecks to occur. Bottlenecks slow down your system because one process has to wait for another to finish before it can begin. But if you want to have 64-bit wide tubes, your computer needs to be thinking in 64-bit so your software and hardware all need to support 64-bit.

If you do not know the difference between 32-bit and 64-bit, I would have told you in the past that you are running a 32-bit version of Windows. But now with Windows 7 I am seeing more and more 64-bit operating systems shipped by default without the end users knowledge. Don’t get me wrong, a 64-bit system is better but you also need to be running 64-bit programs and have a 64-bit processor or else all the trouble of setting up the 64-bit operating system would be worthless.

On a 32-bit operating system, you are restricted to a maximum of 3 gigabytes of RAM. On a 64-bit operating system, you really do not have a limit. Let’s look at Wikipedia and find out the maximum amount of RAM for a 64-bit operating system:

264 addresses, equivalent to approximately 17.2 billion gigabytes, 16.3 million terabytes, or 16 exabytes of RAM.
That is a huge amount of RAM! Normally when you exhaust your physical RAM on a 32-bit system, it has to use virtual memory or hard disk space to pick up the slack. On a 64-bit system, you can install as much RAM as you can to cover your overhead. From here on, 32-bit operating systems will be referred to as x86 and 64 bit operating systems as x64. You can tell what you are running by right clicking on My Computer and choosing Properties.  Below is a shot of a 64-bit machine using 12GB of memory.

 
And in this shot, we see a 32-bit machine trying to use 7GB of RAM.. Not going to happen!
 

If you are running 3D modeling systems or AutoCAD systems, you can benefit from a x64 bit architecture but remember, you need to be running ALL x64 applications, print drivers and anything else you are setting up on your system to realize its full potential. Not all programs have been created for x64 yet and you will find yourself installing applications to your Program Files x86 directory. On a x64 machine, you will have two Program File directories — one for 32-bit and one for 64-bit applications.
So after reading through that and you still want to run a x64 operating system, you will need to make sure your processor supports x64. Most new servers and new computers bought this year or beyond will support x64 but you will still need to check. Here are some facts you should know:
  • Almost all new servers sold within the last two years from AMD or Intel will have x64 capability.
  • Most mid- to high-end desktop processors from AMD or Intel within the last year have x64 capability.
  • Some higher-end Semprons have x64; lower-end Semprons do not.
  • No AMD Durons have x64.
  • All AMD Opteron processors have x64.
  • All AMD X2, FX, and Athlon64 chips have x64.
  • All Intel Pentium D and Celeron D chips have x64.
  • All AMD Turion notebook processors have x64.
  • All Intel Core 2 processors (mobile, desktop, and server) have x64.
  • No Intel Core Duo notebook processors have x64
  • No Intel Pentium M notebook processors have x64.
If you are still not sure if your processor can support x64 check out GRC’s SecurAble and let them help you figure it out! You might also want to check out Mahendra’s post How To Choose Between 32-bit & 64-bit Windows 7 Operating Systems.

If you are running a server that has all its hardware and software certified for x64, then you should install the 64-bit version but beware of device drivers and any 32-bit environments because if I used the word difficult, it would be an understatement!


ramayani

Who are you? Who am I?

Psychologists Say :
  1.  1.  If A Person Laughs Too Much, Even At Stupid Things, He Is Lonely Deep Inside.
  2.  2. If A Person Sleeps A Lot, He Is Sad.
  3.  3. If A Person Speaks Less, But Speaks Fast, He Keeps Secrets.
  4.  4. If Some One Can't Cry, He Is Weak.
  5.  5. If Some One Eats In An Abnormal Manner, He Is Tensed.
  6.  6. If Some One Cries On Little Things, He Is Innocent & Soft-Hearted.
  7.   7. If Some One Becomes Angry Over Silly Or Petty (Small) Things, It Means He Needs Love......


  Try To Understand People. We are living in such a World, where Artificial Lemon Flavour is used for Welcome Drink &  Real Lemon is used in Finger bowl.


............is my number ?
ramayani

What is Compiler ?

Definition of Compiler :

  1. A computer program which reads source code and outputs assembly code or executable code is called compiler.
  2. A program that translates software written in source code into instructions that a computer can understand Software used to translate the text that a programmer writes into a format the CPU can use.
  3. A piece of software that takes third-generation language code and translates it into a specific assembly code. Compilers can be quite complicated pieces of software.

Compiler Overview :

Consider process of Executing Simple C Language Code –

We have opened C Code editor and wrote simple C Program , Whenever we try to compile code and try to execute code our code is given to the compiler.
int main()
{
printf("Hello");
return(0);
}
Now our main intention is to convert program into lower level language which can be read by Machine. Compiler have different phases , and program undergoes through these 6 phases. After Passing through all the compilation Phases our code is converted into the machine level language code which can be read by machine.


ramayani

What is Layer in Photoshop?

Layers are like stacked, transparent sheets of glass on which you can paint images. You can see through the transparent areas of a layer to the layers below. You can work on each layer independently, experimenting to create the effect you want. Each layer remains independent until you combine (merge) the layers. The bottommost layer in the Layers panel, the Background layer, is always locked (protected), meaning you cannot change its stacking order, blending mode, or opacity (unless you convert it into a regular layer).
About the Layers panel

The Layers panel (Window > Layers) lists all layers in an image, from the top layer to the Background layer at the bottom. In Expert mode, if you are working in the Custom Workspace, you can drag the Layers panel out and tab it with other panels.

The active layer, or the layer that you are working on, is highlighted for easy identification. As you work in an image, it’s a good idea to check which layer is active to make sure that the adjustments and edits you perform affect the correct layer. For example, if you choose a command and nothing seems to happen, check to make sure that you’re looking at the active layer.

Using the icons in the panel, you can accomplish many tasks—such as creating, hiding, linking, locking, and deleting layers. With some exceptions, your changes affect only the selected, or active, layer, which is highlighted.
ramayani

How To Change Inches To Centimeters In wORD 2007, Word 2010

By default in Microsoft Word 2010, width, height, and even paper size is shown in inches. For some people this is an obscure measurement that is hardly ever used. If you’d rather display in centimeters instead, let’s take a look at how we can change the default measurement unit from inches to centimeters.

Click on the File Menu and select  Options:

Now click on the Advanced section:

Scroll down to the Display section and change the the option to display measurements in to centimeters, by selecting it from the drop-down menu:
If you use the rulers you will immediately notice a difference:


ramayani

How to block ads in website. Remove ads from website.

सफ्टवेयर राखेर पनि वेबसाइट र मेसेन्जरहरुमा आउने विज्ञापन रोक्न सकिन्छ 


इन्टरनेट चलाउनेहरुलाई विभिन्न वेबसाइट खोल्दा आउने विज्ञापनहरुले हैरान नै पारेको हुनुपर्छ। कम्प्युटर तथा मोबाइलको स्क्रिन नै ढाक्ने गरेर ढकमक्क देखिने विज्ञापनहरुले वेबसाइटमा रहेका सामग्री हेर्न मात्र मुस्किल पार्दैनन् तल माथि र दायाँ बायाँ एकोनास हल्लीरहने विज्ञापनले ध्यान पनि भंग गराउँछन्। यती मात्र होइन वेबसाइट हेर्नेहरुले गल्तीले क्लिक गरोस् भनेर नै सामग्रीहरुको लिंकमा टाँसेरै विज्ञापन राख्नेहरु पनि धेरै छन्। जसले गर्दा तपाइँ आफूले हेर्न चाहेको विषय भन्दा फरक लिंक र ठाउँमा पुग्नुहुन्छ। यसले दिने हैरानी त छँदैछ यस्ता विज्ञापनले तपाइँको इन्टरनेटको गती सुस्तो बनाएर हैरान बनाउँछन्। वेबसाइटहरु धेरै ढिलो खुल्दा तपाइँलाई रिस उठ्नु पनि स्वभाविक नै हो। कतिपय नेपाली वेबसाइटमा छ ठूला ठूला आकारका र पाठकको आँखालाई ख्यालै नगरी डिजाइन गरिएका भद्दा विज्ञापनको संख्या पनि धेरै नै हुन्छ। जसले आँखालाई असजिलो त पार्छ नै इन्टरनेटको गती पनि सुस्तो हुन्छ। भोल्युम बेस इन्टरनेट लिनेलाई त त्यस्ता विज्ञापनले अनावश्यक धेरै पैसा पनि खर्च गराउँछ।

इन्टरनेट प्रयोगका क्रममा दैनिक साक्षात्कार हुने यस्ता विज्ञापन र तिनले दिने हैरानीबाट जोगिन प्रमुख इन्टरनेट ब्राउजरहरुमा यस्ता विज्ञापन रोक्ने एडअन्स (सफ्टवेयर)हरु पनि विकास भएका छन्। जसले तपाइँलाई त्यस्ता विज्ञापन जसले फोकटमा पैसा खान्छन् र हैरानी दिन्छन् तीनलाई सँधैका लागि बाइबाइ गर्न सक्नुहुन्छ सित्तैमा। प्रमुख पाँच इन्टरनेट ब्राउजरमा यस्ता खालका एडअन एप राख्न सक्नुहुन्छ।


Install ABP Ad Blocker


ramayani

Shut down button लाई Change गर्नुहोस Windows 7



पाईंले जब Start button मा Click गर्नुहुन्छ अनि त्यहाँ Start menu को right side को तल Shut down लेखेको अबश्य देख्नुहुनेछ होला हैन हो तर यदी तपाईंले चाहनुभयो भयो भने त्यसलाई  बदलेर त्यसको ठाउँमा Restart, Lock, Log off जस्ता कुनै एक Button लाई राख्न सक्नुहुन्छ
१. सबैभन्दा पहिला Desktop को तल Taskbar मा Right click गर्नुहोस र त्यहाँ "Properties" मा Click गर्नुहोस
 

 
२. त्यसपछी अब त्यहाँ खुलेको Pop up box को माथी "Start menu" tab मा Click गर्नुहोस र अब तल power button action: लेखेको दायाँतिर हेर्नुहोस र Drop down को Icon मा Click गरी आफुले चाहेको कुनै एक Option मा Click गरी अब तल "Apply" button थिची "Ok" गर्नुहोस
र अब Start button मा Click गरी त्यहाँ हेर्नुहोस Shut down button हटेर अघी तपाईंले राखेको Button देखिनेछ धन्यबाद |
ramayani

Tricks and Tips