C Language for U

C Language for U

Share

THIS PAGE PROVIDE YOU ALL NECESSARY TUTORIAL ABOUT C LANGUAGE

01/04/2019

A GENERIC drug is a pharmaceutical drug that has the same chemical substance as the drug that was originally developed, patented and innovated. Generic drugs are allowed for sale after the expiry of the patent of the original drugs.

Generic drugs are copies of brand-name drugs that have exactly the same dosage, intended use, effects, side effects, route of administration, risks, safety, and strength as the original drug. In other words, their pharmacological effects are exactly the same as those of their brand-name counterparts.

FIND OUT GENERIC MEDICINE STORE NEARBY YOUR PLACE AND SAVE YOUR MONEY :)

18/02/2019

C Programming में Goto statement का उपयोग प्रोग्राम के प्रवाह को बदलने के लिए किया जाता है। जब कंपाइलर Goto statement पर पहुंचता है तो यह बिना शर्त (दोनों आगे और पिछे ) उस निर्दिष्ट स्थान पर उछाल जाता है जहाँ Goto statement के अंदर का Condition उसे जाने के लिए कहता है |

Example Of goto Statement in C Programming


int main()
{
int Totalmarks;
printf(" \n Please Enter your Subject Marks \n ");

scanf("%d", & Totalmarks);

if(Totalmarks >= 50)

{

goto Pass;

}

else

goto Fail;

Pass:
printf(" \n Congratulation! You made it \n");
Fail:
printf(" \n Better Luck Next Time \n");

return 0;

}

जब आप ऊपर लिखे C Program को अपने कंप्यूटर पर चलाते हैं अब आपको Output में Please Enter your Subject Marks मैसेज लिखा हुआ दिखाई देता है | तब आप इसके उत्तर में कोई संख्या लिख कर Enter Button को Press करते है तब C Program का if Statement execute होता है अगर आप ने Output में जीस संख्या को Enter किया है वो 50 से बड़ा या बराबर है तो if Statement के अंदर लिखा Goto Statement Execute होगा और Compiler सीधे Goto के साथ लिखे Pass पर पहुँच जाता है | और नीचे हमने Pass के साथ जो वाक्य लिखा है Congratulation! You made it वो Output में Print हो जाता है |

22/01/2015

Functions are where you “roll your own” in the C language. They’re nifty little procedures, or series of commands, that tell the computer to do something. All that’s bundled into one package, which your program can then use repeatedly and conveniently. In a way, writing a function is like adding your own commands to the C language.
If you’re familiar with computer programming languages, you should recognize functions as similar to subroutines or procedures. If you’re not familiar with computer programming (and bless you), think of a function as a shortcut. It’s a black box that does something wonderful or mysterious. After you construct the function, the rest of your program can use it — just like any other C language function or keyword. This chapter definitely puts the fun into function.
(This chapter is the first one in this book to lack a clever use of the letter C in the title. Yeah, I was getting sick of it too — C sick, in fact.)
Meet Mr. FunctionAre functions necessary? Absolutely! Every program must have at least one function, the main() function. That’s required. Beyond that, you don’t need to create your own functions. But, without them, often your code would contain a great deal of duplicate instructions.

A silly example you don’t have to type
Suppose that you write a program that plays “Alexander’s Rag Time Band” every time a user does something pleasing. Because the programming required to play the song is odd and unique, you decide to write a function to conduct the PC’s orchestra. For giggles, suppose that it looks like this:
playAlex()
{
play(466,125);
play(494,375);
play(466,125);
play(494,1000);
/* and there would be more... */
}

Assume that the play() function is used to make the computer’s speaker squawk at a specific pitch for a certain duration. A gaggle of play() functions put together makes the computer whistle a tune.
With all that neatly tucked into a function, your program can then “call” the function every time it wants to play the song. Rather than repeat a vast chorus line of commands, you merely stick the following line into your code:
playAlex();
That’s a C language “command” that says “Go off yonder to said playAlex() function, do what you must while you’re there, and then return to this here very spot to continue a-workin’.” Lo, the function has made writing the program easier.

 *You create a function by writing it in your source code. The function has a name, optional doodads, plus its own C language code that carries out the function’s task. More on this later in this chapter.

*To use a function, you call it. Yoo-hoo! You do this by typing the function’s name in your program, followed by the empty parentheses: playAlex();
This command calls the playAlex() function, and the computer goes
off and does whatever it’s instructed to do in that function.

*Yes, that’s right. Calling (or using) a function is as easy as sticking its name in your source code, just like any other C language statement.

*Some functions require information in their parentheses. For example,
puts:
puts(“Oh, what a great way to start the day.”);

* Some functions return a value. That is, they produce something that your program can use, examine, compare, or whatever. The getchar() function returns a character typed at the keyboard, which is typically stored in a character variable; thus:
thus=getchar();

*Some functions require parentheses stuff and return a value.

* Other functions (such as playAlex()) neither require parentheses stuff nor return a value.

*Functions are nothing new. Most C programs are full of them, such as printf(), getchar(), atoi(), and others. Unlike your own functions,
these functions are part of the compiler’s library of functions. Even so, the functions you write work just like those others do.

*Creating a function doesn’t really add a new word to the C language. However,
you can use the function just like any other function in your programs;
printf() and scanf(), for example.

22/01/2015

हम function के कुछ examples के द्वारा variable के scope के बारे में जानेंगे. अगर आपको C function और C variables का ज्ञान नहीं है तो पहले इन्हें पढ़ लें.

What is scope
C में किसी variable के scope का मतलब यह है कि उस variable को declare या define करने के बाद कहाँ कहाँ पर उसकी value पढ़ सकते हैं. अगर हमने किसी function के अंदर कोई variable x define किया है तो उस function के अंदर कहीं भी उस variable को read/write कर सकते हैं परन्तु किसी अन्य function के अंदर नहीं. अगर किसी loop के अंदर कोई variable define किया है तो उस loop के अंदर कहीं भी उस variable को read/write कर सकते हैं परन्तु उसके बाहर नहीं.
इसे समझना बहुत आसान है. किसी भी {...} के अंदर define किया गया variable उसके अंदर कहीं भी read/write किया जा सकता है परन्तु उसके बाहर नहीं. इसे हम नीचे दिए गए example से समझेंगे.
नीचे दिए गए program में हम एक register बनायेंगे जिसमेकोई भी नाम add कर सकते हैं और सभी नामों को print कर सकते हैं. program को run करने पर एक Menu आयेगा जिसके द्वारा हम उस register में name add कर सकते हैं या register के सभी नामो को print कर सकते हैं.


char list[10][20];
int length = 0;
void add_name()
{
if(length >= 10)
{
printf("list is full\n");
return;
}
printf("Enter the name: ");
scanf("%s", list[length]);
length = length + 1;
printf("name added\n");
}
void print_list()
{
int i = 0;
for(i=0; i < length; i++)
{
int serial_no = i + 1;
printf("%d : %s\n", serial_no, list[i]);
}
}
int main()
{
int input = 0;
while(input != 3)
{
if(input == 0)
{
printf("0 - Print this menu\n");
printf("1 - add name to list\n");
printf("2 - print list\n");
printf("3 - quit program\n");
}
else if(input == 1)
{
add_name();
}
else if(input == 2)
{
print_list();
}
else {
printf("Wrong Input, try again\n");
}
scanf("%d", &input);
}
}

ऊपर दिए गए program को run करने पर शुरू में एक menu print होगा जो यह बताएगा कि क्या enter करने पर क्या होगा. List में नाम add करने के लिए 1 press करके enter करें, इसके बाद या पूछेगा कि कौन सा नाम add करना है. नाम type करके enter करें. फिर से दूसरा नाम add करना हो तो फिर से 1 enter करें. List print करने के लिए 2 Enter करें. पहले इस program को run करके देखें फिर इसे समझते हैं कि यह कैसे काम करता है.

अब देखते हैं कि यह कैसे काम करता है. शुरू में हमने 2 variable list और length declare किया है. चूंकि ये दोनों variable किसी function के अंदर नहीं बल्कि सबसे बाहर हैं इसलिए इन्हें किसी भी function या loop के अंदर से read/write कर सकते हैं. नियम यह है कि variable जिस {} के अंदर declare किये गए हैं उससे बाहर कहीं भी access नहीं किये जा सकते, उसके अंदर कहीं भी access किये जा सकते हैं.
अब आते हैं char list[10][20]; पर. अगर सिर्फ char list[10]; होता तो इसका मतलब यह होता कि list एक array है जिसमे 10 char आ सकते हैं. पर यहाँ char list[10][20]; है इसका मतलब है कि list एक array है जिसमे 20 char वाली 10 array आ सकती हैं. यहाँ 10 char की जगह 10 array आएँगी और हर एक array 20 char वाली होगी.
अगर int a[2][3] होता तो इस तरीके से देख सकते हैं.
a = { {1,2,3} , {4,5,6} };

यहाँ पर a के अंदर 2 array आ सकती हैं एक array a[0] में और एक a[1] में. उन दोनों array में 3 3 int आ सकते हैं.
char list[10][20]; का use नाम store करने के लिए करेंगे. हम देख चुके हैं कि नाम string है जिसे char array में store करते हैं. यहाँ list में 10 char array आ सकती हैं इसलिए इसमें हम 10 नाम store कर सकते हैं. हर एक array में 20 char आ सकते हैं इसलिए हम वही नाम store कर सकते हैं जिसमे 20 या उससे कम letter हो. दूसरा variable length या बताता है कि currently list में कितने नाम हैं, जोकि शुरू में 0 है.

इसके बाद add_name function है जिसे call करने पर यह list में एक नाम add कर देगा. पहले हम check करते हैं अगर list में 10 नाम आ चुके हैं तो return का use करके function को वहीँ समाप्त कर देते हैं, अन्यथा scanf का use करके list variable में सीधे नाम read कर लेते हैं. ध्यान दें कि scanf का पहला argument "%s" है जो कि string read करता है इसलिए दूसरा argument char array होना चाहिए. list[0], list[1], list[2] ... list[19] सभी 20 char वाली array हैं.
list में नाम add होने के बाद हम length 1 बढ़ा देते हैं. list[length] हमें list में हमेशा अगली खाली जगह दे देगा क्योंकि शुरू में list खाली है इसलिए list[length] (length=0) वाली char array खाली है. एक नाम list[0] में add होने के बाद length = 1 हो जायेगा, अब list[length] (length = 1) वाली array खाली है.
इसके बाद print_list function define किया है, जिसे length से यह पता चल जाता है कि list में कितने नाम हैं उतना ही for loop से print कर लेते हैं. यहाँ for loop के अंदर एक variable serial_no define किया है जो उस loop के बाहर से access नहीं होगा.

अंत में main function है जहाँ program run होना start होता है. जिसमे if-else statement का use करके input variable की value के according list में नाम add करते हैं, list print करते हैं, menu print करते हैं. इस पुरे if-else को while loop के अंदर लिखा गया है, जो कि तब तक run होगा जब तक input की value 3 नहीं हो जाती. while loop खत्म होने से पहले input variable में scanf का use करके input read करते हैं, अगर input 3 है तो while loop खत्म होके program finish हो जायेगा otherwise while loop के अंदर फिर से आकर input value के according if-else का use करके list में नाम add करते हैं, list print करते हैं, menu print करते हैं और फिर से input variable में scanf का use करके input read करते हैं.

22/01/2015

CONTINUE FUNCTION TOPIC IN DETAIL with EXAMPLE

हम एक ऐसा function लिखेंगे जिसे total marks और obtained marks देने पर वह हमें percentage देदे. अभी percentage print करने का program ही देखते हैं, उसके बाद division print करने का program भी देखेंगे.
नीचे लिखे हुए program को देखिये जिसमे हमने function define किया है. पर इसे run न करे क्योंकि यह run नहीं होगा. इसके बाद function call करने और run करके का तरीका देखेंगे.

int get_percent(int total marks, int obtained marks)
{
int percent = obtained_marks*100/total_marks;
return percent;
}

सबसे पहले int लिखा गया है जोकि यह बताता है कि function किस तरह का मान हमें return करेगा. इस example में function int type का मान हमें return करेगा. उसके बाद function का नाम लिखते हैं, जोकि यहाँ पर get_percent है. उसके बाद () में function के input variable लिखते हैं जिन्हें parameter या argument कहते हैं input variable लिखते समय यह भी बताना पड़ता है कि वो किस type के हैं और उन्हें function के अंदर किस नाम से access करेंगे. यहाँ दोनों input int हैं. किसी function में हम कितने भी input दे सकते हैं, या फिर अगर एक भी input नहीं देना चाहते तो () के अंदर कुछ नहीं लिखते. यहाँ 2 input दिए गए हैं. उसके बाद {} के अंदर वो लिखते हैं जो function काम करेगा. यहाँ हमने दिए गए input का उपयोग करके percent निकाला है. अंत में return करते हैं.
शुरू में लिखा हुआ int यह बता रहा था कि यह function int type की value हमें देगा(return करेगा). अंत में return लिखकर हम percent return कर रहे हैं जो int type का ही है. अगर return statement के बाद कुछ लिखा है तो वह run नहीं होगा, क्योंकि return आते ही function को यह पता लग जाता है कि क्या value return करना है और function वह value return करके उसी समय खत्म हो जाता है.
अब यह देखते हैं कि इस function का use कैसे करेंगे. नीचे दिए गए program को run करके देखें.


int get_percent(int total_marks, int obtained_marks)
{
int percent = obtained_marks*100/total_marks;
return percent;
}
int main()
{
int percent;
percent = get_percent(500, 360);
printf("Percent is %d\n", percent);
percent = get_percent(500, 340);
printf("Percent is %d\n", percent);
scanf("%d", &percent);
return 0;
}

सबसे पहले हमने function define किया है किसका नाम है get_percent, जो int type की value return करेगा और 2 int type के parameter लेगा जैसे कि हम ऊपर भी देख चुके हैं. फिर main() के अंदर से program run होना start होता है जैसा कि हम अभी तक देखते आये हैं. main के अंदर पहले int type का percent variable define किया है. उसके बाद get_percent function call किया है जो ऊपर define किया था. इस function को हमने 2 parameter 500 और 360 दिए हैं. यहाँ parameter का क्रम भी important है. इस function को call करने पर ऊपर वाला function run होना शुरू हो जायेगा, जिसमे total_marks की value 500 और obtained_marks की value 360 चली जायेगी. इन values के basis पर get_percent percent की value 80 निकालकर return कर देगा.
percent = get_percent(500, 360);

यह लिखने पर get_percent जो भी return करेगा वह percent में store जायेगा. उसके बाद हम main() के अंदर ही percent print कर रहे हैं. इसी तरह एक बार और get_percent function को call करके जो value आती है उसे percent variable में store करके print कर रहे हैं.
यहाँ एक बात note करें कि main भी एक function है जो कोई भी parameter नहीं लेता(इसलिए main() लिखा है () में कुछ नहीं लिखा) और int return करता है इसीलिए हम अंत में हर बार return 0; लिखते आ रहे हैं. जब हम कोई भी C program run करते हैं तो सिर्फ उसका main function call होता है. main के अंदर हम जो जो function call करते हैं वो उसी sequence में call होते हैं. अंत में जब main function के अंत में पहुँच जाते हैं तो program finish हो जाता है. अगर आप किसी ऐसे program को run करे जिसमे main function न हो तो वह कुछ इस तरह कि error देगा कि main method not found.

अब हम एक और program देखते हैं जो division भी print करे. इसे run करके देखें.


void get_percent(int total_marks, int obtained_marks)
{
int percent = obtained_marks*100/total_marks;
if(percent >= 60)
{
printf("Congrats!! You passed in 1st division.\n");
printf("Your percentage is %d.\n",percent);
}
else if(percent >= 45)
{
printf("You passed in 2nd division.\n");
printf("Your percentage is %d.\n",percent);
}
else if(percent >= 33)
{
printf("You just passed in 3rd division.\n");
printf("Your percentage is %d.\n",percent);
}
else
{
printf("Sorry! you failed.\n");
printf("Your percentage is %d.\n",percent);
}
}
int main()
{
get_percent(500, 360);
get_percent(500, 340);

int abc;
scanf("%d", &abc);
return 0;
}

इस example में get_percent function division भी print कर रहा है. इसमें पहले वाले function से थोडा difference यह है कि यह function ही सब कुछ print कर रहा है इसलिए main में अलग से print करने कि जरुरत नहीं है. शुरू में void लिखा गया है इसका मतलब है कि यह function कुछ return नहीं करेगा, इसलिए main में function को सिर्फ call किया गया है, जबकि पहले वाले example में जो value function return कर रहा था उसे एक variable में store कर रहे थे.

17/01/2015

Top 10 Places Where C Language is Used for

Where C Language is Used for is a question arises in the mind of any new guy when s/he starts-up to learn C. If you are interested in the answer of this question too, this article is just for you.

Using a high level language, such as C, can make OS development much easier. The most common languages that are used in OS development are C, C++, and Perl. Do not think these are the only languages that may be used; It is possible in other languages.

C and C++ are the most common, with C being the most used. C, as being a Middle Level Language, provides high level constructs while still providing Low-Level Details that are closer to Assembly Language, and hence, the System. Because of this, using C is fairly easy in OS development.

This is one of the primary reasons why it is the most commonly used: Because the C programming language was originally designed for System Level and Embedded Software development.
Following are some programming fields where generally either there is no choice other than C or no alternative regarding performance, easiness, speed and many more factors, that’s why C is the most used language:

Operating System Kernel Development

Almost all major Operating System Kernels have been written in C. C++ came as a natural extension to some of them. For example Android Platform has an underlying Linux kernel which is written basically in C. Although as a Middleware of the Android Platform is written in Java, so that you can develop Android Apps using Java.
Middleware, Firmware and Drivers

These pieces of software in the Operating System interact with the Kernel which is basically written in C. Also, they need to be really fast. Hence they tend to be written in C as well. Although this is changing and more middleware comes in Java these days, but still some sectors are there where you need to stick with C for Middleware, Firmware and Device Drivers.

File Systems

These have got to be in C because of C’s closeness to Hardware as compared to upper layer languages like Java, C #. Since, the speed of Disk is always slowest part of any Computer System, so it’s naturally very important to interact with File System (which exists on the Hard Disk Drive) should be as fast as possible and that’s why C is the best choice to work with File Systems.
Implementation of Network Sockets

As Jin Christophe mentions in his post, TCP/IP, IP over infiniband and all the code going into Routers, Gateways, Relays and Switches need to be FAST. These have layers and layers of code written fully in C, primarily for speed.
Video Games

When computing speed was an issue and Physical Memory wasn’t equal to the size of Virtual Memory, Games were written in C to compute more data per unit game cycle. Some examples of such games: Doom, Quake, City of Heroes, championship manager, most Microsoft games, EA game engines etc. Game Engines in particular need speed and optimization for the Hardware they are being built for.

In fact Graphics Libraries like OpenGL (and DirectX too?) are written in C/C++, with APIs supporting other languages. This is changing though with increasing computational power available to us but still approximately all task related to Computer Graphics basically depends on either OpenGL or DirectX like libraries which have been developed and maintained in C/C++ and that’s why, still most of the Graphics Software like Photoshop, Adobe Premier, Maya, 3D Studio, AutoCad, etc… and the Games are mostly powered by OpenGL or DirectX Libraries.
Many Libraries

OpenGL, OpenCV, OpenGV, Boost, DirectX, GTK, GIMP etc. all have been developed in basically C/C++ because these are the libraries basically related to Computer Graphics and Graphics should be the most performing part of any Visual Device like Computer, Mobile Phone, Game Console, etc…
The C programming language uses libraries as its primary method of extension. In C, a library is a set of functions contained within a single “archive” file. Each library typically has a header file, which contains the prototypes of the functions contained within the library that may be used by a program and declarations of special data types and macro symbols used with these functions.
In order for a program to use a library, it must include the library’s header file and the library must be linked with the program which in many cases requires compiler flags (e.g., -lm, shorthand for “math library“).

The most common C library is the C Standard Library, which is specified by the ISO and ANSI C Standards and comes with every C implementation. (Implementations which target limited environments such as Embedded Systems may provide only a subset of the standard library.)

This library supports Stream Input and Output, Memory Allocation, Mathematics, Character Strings, and Time Values. Several separate standard headers (for example, stdio.h) specify the interfaces for these and other standard library facilities.

Another common set of C library functions are those used by applications specifically targeted for Unix and Unix-like systems, especially functions which provide an interface to the kernel. These functions are detailed in various standards such as POSIX and the Single UNIX Specification.

Since many programs have been written in C, there are a wide variety of other libraries available. Libraries are often written in C because C compilers generate efficient object code; programmers then create interfaces to the library so that the routines can be used from higher-level languages like Java, Perl, and Python.
Browsers

Chrome and Firefox are both written in C++ because Web Browsers are actually another kinds of Operating System which in turn executes on Operating System. That’s why they also needs to be very fast and wherever the SPEED is in main concern, C/C++ is the only choice.
Codecs

Since, Codecs are actually related to Sound / Audio which also is the biggest Media Type after Graphics, so codecs are also primarily developed in C/C++, because Speed and Performance of processing Audio is the main concern too in any Audio Processing Application like WavePad, Audacity, Fruity Loops, VirtualDJ, etc…
Unit Tests in Semiconductor Companies

Chip making is hard. For every small piece, you need to write a test. Although scripts are useful you normally would write a small software model (in C/C++) to test your unit against.

Embedded Systems

We already have discussed this sector in too much detail, where Embedded Products rely on C heavily.
There are so many more…

Here’s a very small list of Applications Written in C/C++ discussed above but there are lots and lots more. Frankly, C/C++ is an area that does not seem like a popular language among quorans. You’ll see tons of discussions about Python, PHP, Ruby, some random language made in Facebook, Google or Twitter. These are all custom languages made to speed up certain elements of design or a specific domain.
C is basically a vocabulary on top of the Von Neumann Machine. And since every computer you’ll ever use is a von Neumann Machine, C is perhaps the most useful language for fundamentally reasoning about the properties and problem-solving capabilities of a computer.

17/01/2015

Type Declaration Instructions : “C” Language में किसी Program File में हम मुख्‍यतया तीन तरह के Instructions लिखते हैं। इन तीनों प्रकार के Instructions का एक विशेष काम होता है और हर प्रकार Instruction अपने उस विशेष काम को पूरा करता है। ये तीनों Instructions निम्नानुसार होते हैं:
Type Declaration Instruction

ये वे Instructions होते जिनका प्रयोग करके हम विभिन्न प्रकार के Data को Computer की Memory में Store करने के लिए Memory Reserve करते हैं। हम जिस किसी भी Data को Program में Process करना चाहते हैं, उस Data को Store करने के लिए हमें Memory की जरूरत होती है, जहां उन Process किए जाने वाले Data को Hold करके रखना होता है।
Required Data के आधार पर हमें Memory में कुछ जगह Reserve करने के लिए जिन Instructions का प्रयोग करना होता है, उन्हें Type Declaration Instructions कहते हैं। इन Instructions का प्रयोग करके हम विभिन्न प्रकार के Variables Declare करते हैं।
एक “C” Program में हम कई तरह से Variables Create कर सकते हैं। Variables Declare करते समय ही हम उन Variables को Data Initialize कर सकते हैं। जैसे:
int i = 19, j = 23 * 3/2-1;
जब हम किसी Variable को Create करते समय ही उसमें कोई एक निश्चित मान Initialize कर देते हैं, तो इस प्रक्रिया को Implicit Initialization कहते हैं। उदाहरण के लिए उपरोक्त Instruction में Variable i को Declare करते समय ही उसमें मान 19 को Initialize कर दिया गया है, जो कि Implicit Initialization का उदाहरण है।
जब हम किसी Variable को Declare करते समय उसमें किसी प्रकार की Calculation से प्राप्त मान को Initialize करते हैं, तो इस प्रक्रिया को Explicit या Dynamic Initialization कहते हैं। उदाहरण के लिए उपरोक्त Statement में Variable j को Create करते समय उसमें जो मान Initialize किया जा रहा है, वह मान एक Calculation से Generate हो रहा है, इसलिए ये एक Explicit या Dynamic Initialization का उदाहरण है।
हम किसी Variable को Create करने के बाद यदि कोई दूसरा Variable Create करते हैं, तो उस दूसरे Variable में पहले Variable के मान को भी Initialize कर सकते हैं। जैसे:
int i = 19, j = i;
इस Statement में हमने जो मान Variable i में Store किया है, वही मान हमने Variable j में भी Store किया है। लेकिन यदि हम इस Declaration के क्रम को निम्नानुसार Change कर दें:
int j = i, i = 19;
तो Compiler हमें निम्नानुसार Error प्रदान करता है:
Error: Undefined symbol ‘i’
Error: Multiple declaration for ‘i’
ऐसा इसलिए होता है, क्योंकि “C” का Compiler हर Instruction को Up to Down व Left to Right Execute करता है। इस स्थिति में Compiler सबसे पहले int j = i; Instruction को Execute करता है।
इस Instruction के आधार पर Compiler जब Variable j के मान में Variable i का मान Initialize करने के लिए Variable i की Memory Location को खोजता है, तो उसे ऐसा कोई Memory Location प्राप्त नहीं होता है, जिसका नाम i है, क्योंकि Compiler ने अभी तक Variable i के लिए Memory में किसी Location को Reserve ही नहीं किया है और Compiler जब किसी ऐसे Variable को Memory में खोजता है, जिसे उसने किसी Memory Block के साथ Associate करके Define ही नहीं किया है, तो वह “Undefined symbol” का Error Message Generate करता है।
Compiler हमें दूसरी Error इसलिए Display करता है, क्योंकि Compiler जिस Variable i को पहले Memory में खोज चुका होता है, उसी नाम का Variable हम बाद में Define करने की कोशिश करते हैं। इस स्थिति में पहले Instruction के लिए तो Compiler ये समझता है, कि हमने variable i को Define नहीं किया है, जबकि दूसरे Instruction के लिए Compiler ये सोंचता है कि हम एक ही नाम के एक से ज्‍यादा Variables Define करने की कोशिश कर रहे हैं।
इस तरह से एक Misplaced Instruction एक से ज्‍यादा प्रकार की Errors को Generate कर रहा है। जब किसी Program में कोई एक गलत Instruction एक से ज्‍यादा प्रकार की Errors को Generate करने में सक्षम होता है, तो इस प्रकार के Error Instruction को “Error Generator Source Instruction” कहा जाता है।
कई बार हमें ऐसी जरूरत पडती है कि एक ही मान को एक से ज्‍यादा Variables में Assign या Initialize करना होता है। इस प्रकार की जरूरत को हम निम्नानुसार पूरा कर सकते हैं:
int x, y, z;
x = y = z = 100;
लेकिन यदि इन दोनों Instructions को हम एक Instruction के रूप में निम्नानुसार Use करें:
int x = y = z = 100;
तो ये एक गलत Instruction होगा और हमें फिर से “Undefined Symbol” की Error प्राप्त होगी। क्योंकि यहां फिर से हम उस Variable y का मान Variable x में Initialize करने की कोशिश कर रहे हैं, जिसे अभी तक Memory Allot नहीं किया गया है।

Want your school to be the top-listed School/college in Faridabad?

Click here to claim your Sponsored Listing.

Location

Telephone

Website

Address


Faridabad