C Language in Hindi

Today I will discuss short summary of C Language which i have analysed till now for those who want to revise basic concepts.
There are two compilers which are known to me to compile C Programs.Turbo C Compiler and Quick C Compiler.Small Change in
Library fuctions of Turbo C Compiler can give birth to Quick C Compiler.C is basically used to connect user with computer
hardware like ROM, RAM, BIOS and Harddisk in IBM compatible computers with MS-DOS OS.The basic objective to use C Language is
to know different methods to input and output data of user and to combine and manipulate data.

C was created by Dennis Riche in 1972 after the fall of PASCAL, FORTRAN, PL/I, ALGOL Languages.After Creation of BCPL and then
B language by Ken Thompson C came into existence in AT & T Bell labs USA.Sab Kuch Usa mein hi bana hai kya.Language do tarah
ki hotee hain.High level , jo humarey program designing ko fast karti hain. Jaise Fortran, Pascal aur Low level jo program
execution ko fast karti hai jaisey TASM, ASM.Lekin C mein yeh dono khubian hain.Sabse pahley Commercially COBOL use hotee thee
aur scientific & mathematical calculations ke lie FORTRAN use hotee thee.Lekin dono ko mila kar ALGOL60 bana di gayi jo ki
asaani se samajh nahi aati thee, iseley CPL banai , lekin usme bhi bahut saarey features thee jinhey dhoondna mushkil ho jata
tha….isley ant mein BCPL banaai.
Ab hum C ka Character set dekengey bhai… kehney ka matlab hai ki C ka program kin kin cheezon se mila kar bantaa hai.Constant
,Variable aur Keywords kya hotee hain? Constant jaisey 2,3 values hotee hain, jinko change nahi kiya jata…jabki variable ko
chnage kar saktey hai aur Keyword jinka matlab pahley se hi library mein define kiya hua hai …. bas hum key keword likh dete
hain aur program apney aap sab kuch samjh jata hai.Dekh Bhai , tu keyword ko apney naam ya kisi aur word se replace nahi
kar saktaa kyonki wo pahle se hi defined hai….samjha ya samjhi?Constants Int Real aur char type ke hotey hain.Int jo without decimal
numbers hotey hain , Real jo decimal waaley hotey hain aur char constants jo single inverted comma “‘” mein likhe jaatey
hain, jinkey ASCII value le jaati hai.If, else, break, while yeh saare keywords hain jo pahley se defined hain.Samjha bedu.
Ab instructions ke baarey mein baat kartey hain jo in sub ko mila kar bantee hai.Instruction type bataaney ke lie, arithmatic
calculations ke lie, input/output karney ke lie aur programm ke sequence chnage karne ke lie use hotee hain.Agar mein a+b=c
liktaa huin to yahaan par a,b operands hain, aur + operator.
Sequence change karne ka matlb hai ki pahley program ki kisi aur line ko execute karnaa aur phir pahli ya doosri line ko.
Humney if, for, while loop padey hain, jinkaa indentation right side ko khisktaa jata hai hai … aisaa hogaa to program
right hand side ko shift hotaa jaaega…. isley hum Logical operators ka use karte hain jaise AND,OR or NOT.Isey loop ki
instruction choti ho jaatee hai… samjh le be… Koi nahi bataaegaa
Agar mein if (i=5) {work();}; use karta huin to, work to work();chalegaa hi kyonki i=5 ek positive aur true value hai, jo
statement ko execute kargee hi
if(i==2)
statement 1;
statement 2;
Agar statment 2 bracket mein nahi daali to yeh if condition se bahar ho jaaegi aur humsha execute hogee hi kyonki if ke
lie to pahli statement 1 hi maani jaaegi.Loop se bahar aaney ke lie break use hotaa hai.
while(i++ <= 31000);
yahaan i ki value range se bahar jaa rahi hai, isley indefinite loop chalegaa.Indefinite loop ko avoid karney ke lie
counter increment jaroor karein.Is statement mein pahley comparison hoga aur phir increment.Pad lo bhai.
Program se bahar aaney ke lie exit() use hotaa hai.Switch mein har case ke baad break; jaroor lagaa lenaa nahi to saaree
statements execute ho jaaengi…phir puneet ko mat bolnaa ….meraa farz thaa bataana
Fuctions ke baarey mein batata huin Called function mein jo arguments hotey hain, wo actual hotaa hain.Aur jahaan fuction
likkha hota hai , wahan ke argument formal argument hotey hain.Float value main me called function mein return karney ke
lie fuction se pahle float laga do.Har function ke variables ki value usee function tak local rahti hai… isley hum values
pass karte hain.Kisi function mein function nahi likhaa jata aur execution hamesha main() se start hotaa hai.Return; statement
garbage value return karegi.do varibales ki value ko swap aur adlaa badlli karney ke lie call by reference use hota hai, jimey
hum pointers ka use kartey hain.Varables ko memory mein 4 tarah se store kiya jaa saktaa hai
1.Auto – default hota hai … lagaao ya nahi … initial value garbage hotee hai
2.Static – Value humesha jindaa rahti hai… ek function se doosrey function mein transfer hotee hai – initial vaule=0
3.Register – fast processing ke lie counter variable mein use hotey hain, initial = garbage
3.Extern – variable har function mein use kiya jaa saktaa hai globally, initial = 0;

Data types:
int 2 byte ka hotaa hai aur char ek byte ka
4 byte ka int long int ho jata hai
4 byte ka float hota hai
8 byte ka double
aur 10 byte ka long double
agar signed hai to ek sign bit bhi hogi 1(-ve) or 0(+ve)
Int ki range -+32700
char ki range -+127
range se bahar honey par indefinite loop chalega
unsigned +127 + 127 = 0->+255

Macros define kaisey kartey hain.Preprocesor source code ko expanded source mein convert kar detaa hai

main(); se pahley

# define PI 3.14

PI template hai
3.14 macro expansion hai
Jiasey “\X1B[2]” command ke jagah hum Clearscreen template use kar saktey hain pooray program main.Bor to nahi ho raha?

Isi tarah (n*n) macro ki jagah hum SQUARE(n) Template ka use kar sakte hain after defining before main().
chotey macros program ko fast kaartee hain bjaai ki fuctions se values caal karaaney se
#include “goto.c”
Library + Current Directory = dono mein khoj hogi

#ifdef OKAY
statemnt 1;
#endif statement 1 tabhi chalegi jab Okay macro define hoga main se pahley

ARRAY
a[1] = 6;
a-> subcripted variable hai
1-> subscript hai
array ki values jab sequncially access karni ho, to subscript ki jagah pointer ka use karnaa chahiye … pahley subscript
ke address pe pointer set kar do, aur pointer ko loop se aagey badaatey jaao

a -> base address of a
a+1 -> next address
*(a+1) -> value at a+1
a[0] -> value at base address
a[0]+ 0 -> value at base address
a[0]+ 1 -> value at next address

Array of Characters —> Strings —> Puppeting

char name[] = {‘P’,’U’,’N’,’E’,’E’,’T’,’\0′};
set pointer ptr at name[0]
ptr = name;
and start incrementing ptr++ till null ‘\0’
Puneet ko arrary name mein daal rahein hain aur phir base address pe ptr pointer set kar ke, pointer ko aagey le ke
jaa rahey hain jab tak null char nahi aaa jata…. hee heee heee neend aaa rahi hai kya ? so gaye kya ? uth jaao beta

 

scanf(); –> ek hi word ka string input karaa saktey hain
gets(); –> multi word string bhi kara sakte hain
puts(); –>

Humseha ‘\0’ jaroor place karnaa chahiye source string se target string mein copy maarney ke lie
strcpy(); automatically null assign kar detaa hai.

STRCMP — 2 strings ko compare kareingey
Puneet
Puneet
————
000000 ASCII values … dono ka difference 00000 hai, isley string match kar rahein hain

Puneet
Suneet
——-
4 ASCII value 0000 nahi hai …. mismatch ho gaya
——-

Puneet
Puneet-ji
———-
-32 kyonki null mein se ghtaa rahe hain hum….. samjaa……. again mismatch ho gaya
———-

 

Hum ek 2d array names[4][12]
lete hain aur usmey

01234567890(11)(12)
0.Puneet- – – – –
1.Puneet Verma- –
2.Puneet Ji- – –
3.Puneet webmaster

to humney dekhaa ki kasey iss 2d array main kaafi memory unused rah gayi strings ke beech mein, jahaan _ _ _ blank
lagey hain

Iss memory ko bachaaney ke lie hum Array of pointers use kartey hain kyonki pointer base har row ke base address pe
point karega aur last location 4×12= 48 ki bajaaey 4 ho jaaegi.Yahan sirf har row ke base address ko store karne
ke lie memory use hogi aur _ _ _ blanks waali memory bach jaaegi

Yahah hum memory ka efficenct use kar paa rahey hain … aur changes karnaa aasaaan ho jaaegaa

Yaad rakhio … hum kabhi bhi array pointers ko keboard se nahi le saktey ya scanf nahi karaa saktey

SRUCTURES
Alag Alag datatypes , jaisey int char float ka collection se structure bantaa hai… aur ek structure ko hum
kai objects ke lie use kar sakte hain.
Jaisey ek book naaam ka structure banaa liaa , aur humney 100 books ke information ke lie 100 structures kaa
memory define kar diya.
struct book
{elements};
struct object b[100];

Array mein elements ki jagah bahut saarey structures bhi daal sakte hain …… jisey similar data type
collecttion structures ka hoga, jo ki dissimilar data types ka collection hotey hain

Array {
similar data typtes like
struct 1 {dissimilar data types}
struct 2 {dissimilar data types}
struct 3 {dissimilar data types}

}

elements humesha ek ke baad ek contagious memory locations mein store hotey hain.

Structures mein bajaai ki ek ek data element copy karney ke, hum variables ya objects ek doosray mein directly
copy kar saktey hain.

object2 = object1; (dekho aisey)

structures ke objects ke nesting bhi ki jaa saktee hai
object1.object2.object3 (is tarah se)

Normally hum object1.name jasey actual arguments pass karaatey hain , aur char pointer

Char *s as a formal argumant access kar lete hain.
Lekin yeh kaam hum object1 pass karaa kar aur struct book object jasey formal argument ke form mein bhi le saktey hain

Display(object1); ——> call

Display(struct book object) ——> called function yahan humey struct globally define karnnaa padegaa taki called func
usey samajh sakey.

Hum structure pointers ka bhi use kar saktey hain
ptr = &object1;
Display(&object); ——–> Call

Display(Struct book *ptr) ——>Called function
{ ptr->name printf karaa saktey hain}

INPUT/OUTPUT IN C
c mein input output functions ka development nahi hua tha , balki usey compiler developers ne banaya aur library mein daal dia

I/O functions ka use hum
1.Console(keyboard) se input dekar VDU par output lekar kar saktey hain
2.keyboard se disk par print kar saktey hain
3.Keyboard se port par output lene ke lie kar saktey hain

Console inputs type do tarah se ho saktey hain
1.Foramt – jo print output ko idhar udhar shift karney ke lie use kar saktey hain … jaisey %10d right shift kar dega
%-10d left shift kar dega , us output ko jo screen pe nazar aaegaaa

screen 80 column se milke banti hai aur ek tab 8 columns ke hotee hai….. aur symbols jaisey ‘ ko print karaaney ke lie
pahley \ lagaa saktey hain. Screen 10 tabs mein poori hotee hai …. mazaa aa raha hai naa ? mughey pataa tha …tabhi to
tu yahaan maze se C seekh raha hai…. soch meri kitnee waat lagi hogeee …. but u know mein india se bahut pyar kartaa
huin……aur shyad tu bhi

2.Unformat –> putch, puthcar,fputchar are examples

Sprintf se string mein alag alag variables ke values daal sakte hain
Sscanf se string se values lekar different variables mein daal saktey hain

Unformatted functions jaisey getch or getche mein input dekar enter key nahi dabaani padti or getche mein input print ho
jata hai , lekin getchar mein enter dabana padtaa hai aur input screen par aa jata hai …. for exampe yes or no option
ke baad enter dabana padtaa hai

Gets or puts se hum multi word string le saktey hain aur print karaa saktey hain.

Input output functions with buffer manager and without buffer manager bhi hotey hain…. low level functions main
buffer management apney aap hotaa hai… jabki high level mein programmer manage kartaa hai…… data text ya binary
format mein store hota hai ……. text form mein kartey hain to ek ek char ek ek byte letaa hai … lekin binary mein
sab kuch asii value pe depend kartaa hai , aur space kam use hotaaa hai.

Program se oS pe store koi file kholney ke lie hum FILE(size,location,pointer addr) structute ka use kartey hain aur
file chotey chotey hisson mein memory mein load hoti rahti hai jab ak 27 naa aa jaaey ya EOF naa aaa jaaey….lols

Ek variable ch ki help se hum data ek file se uthaa kar fputc kar dete hain doosri file mein aur fir usko fgetc se read
kar lete hain….. ch buffer ke tarah kaam karega … aur agar bffer poora nahi bharaa to process close karney ke lie
fclose func kaa use karengey.

Ek exe file tyarar ho jaati hai…. jisey hum command line mein direct chlaa saktey hain…. lekin command line
tips kaa use karkey hum us exe file ko bahut saarey tareekon se use kar saktey hain, jaisey

argv[0] argv[1] argv[2] ya filecopy pr1.c pr2.c ko hum command promt pe use kar rahey hain

argv waaley program mein fs pointer jahaan per hai wahaan se data read hona shuru hoga or ch buffer mein aaa jaeyga
… phir jab tak ch EOF nahi ho jata ……. data fputc hotaa jaaega us location pe , jahaan ft pointer hai.

Enter press kartey hi multi word string ya ek line fputs hogi ya enter hogi … agar ek baar enter press karney ke
baad … binaa kuch likhey enter press kar diya to multiword string 0 ho gaya…. aur condtion false ho gayi aur hum loop se
bahar aaa jaaengey.
Jab hum Dos command se file read kartey hain … to carrriage return character add ho jata hai … lekin c program se nahi
hota …. isley c program se file open karney par uskaa size kam hotaa hai.

Hum int float char bhi ek file mein enter kar saktey hain by using fprinf(variables se outpur lena) and
fscanf(variables mein store karna)

Stdin ya stadard input lene ke baad humey enter key press ko fflush kar denaa chahiye … taki memory khali ho jaaey…

Hum apne input ko directly print, display, port output pe daal saktey hain——–>stdprn,stdout,stdaux

Numerical data ko binary format mein hi store karnaa chahiye…. kyonki agar char form mein karenge to ek char ek byte
legaa aur jyaada space use hoga….. jabki binary format mein kam space use hogaa bits ki form mein storage distribute
hoga…..

Agar text file mein humney 26 likha hai aur usey binar mein khol rahe hain …. to poori file nah khulegi kyonki 26 ko
EOF mana jaaegaa …. sahi kahaa naa

BINARY FORMAT and STRUCTURES
fread
fwrite
fprintf
use hotey hain

&object se data fp pe fwrite kiya —-> bin
&object pe data fp se fread kiya —-> bin

scanned data fp pe fprintf kiya ——> not a binary mode

Ek file emp.dat mein agar ek record se doosre record pe jana hai to f(seek()); hotaa hai , start pe jana hai to rewind use hotaa
ha … cursor postion dekni hai to ftell use hotaa hai……. reference point see_cur deta hai aur destination point
-recsize detaa hai.seek_set matlab start point

LOW LEVEL mein hum read() close() open() buffer use kare hain with permissions to copy files on command line.

Hum IO REDIRECTIONS ka use karke exe ka use bahut tareekon se kar saktey hain

puneet.exe ek file hai jismey hum kuck stdin karaaengey aur wo VDU pe stdout hoga.compile karengey to exe generate hogee

C:>Puneet.EXE < Source.c > Desination.c

puneet.exe ka use hum source to destination file copy karney ke lie use kar rahey hain …. jabki wo is lie nahi banaai…
this is called IO redirection

Hish level languaage dos functions kaa group hai aur har DOS() func ROM_BIOS() functions se mil kar bana hai …. har
rom_bios function ka address Interrupt vector table mein store hotaa hai , aur ROM_BIOS input values inregs mein
aur output values outregs registers mein store hotee hain in the low memory area of ROM.Inko hum change kar saktey hai
aur virus kaa subroutine IVR mein daal saktey hain … heee hee hee aisaa mat karnaa …. mere bhai

UNION:

UNION MEIN hum ek memory space ko char int float mein share kartey hain alaag alag time pe.

SHOWBITS

yahan hum har cheez ko pahley left shift kartey hain aur phir right shift and then decimal nikaal lete hain….he hee hee

AND bit ko switch off kar deta hai aur
OR bit ko switch on kar deta hai

showbits function mein hum 1 ko 16 bit tak right shift kar kar kar har baar kisi bhi number jiskaa bin chahiye , ke saah AND
karaatey hain aur hum wo bin number mil jata hai

Enum se hum PERSON ko kai values , jaise married, unmarried ,divorsed de saktey hain ……

Enum Person
{single, married,divorsed,widowed
};

Enum Person person1,Person2;

Typecasting mein hum kisi particular expression mein float ko int or int to float mein convert kar saktey hain

Facebook Comments
Puneet Verma
Puneet Verma, is founder, promoter & author of Mission Green Delhi platform. He is Acumen & Ideo.org certified Human-Centered Design professional as well. You can find more than 600 articles, stories and poems written by him on this online publication. To share thoughts with him, you can whatsapp him at +91- 9910162399. Puneet had worked with The QED Group LLC (www.qedgroupllc.com), Washington DC based International Development sector management consulting firm and looked after their web projects.

Leave a Reply

Your email address will not be published. Required fields are marked *

4 × 1 =

What are you looking for ?


Your Email

Let us know your need

×
Connect with Us

Your Name (required)

Your Email (required)

Your Message

×
Subscribe

×
Translate »
Close