JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Categories: c++ language in hindi

C++ : New Design with program example in hindi explanation , what is new design in c++ language

what is new design in c++ language , C++ : New Design with program example in hindi explanation :-
जिसे की c++ language मे , किसी प्रोग्राम को execute करने के लिए दो अलग अलग file को execute किया जाता है बाद मे इसे merge किये जाता है | अगर यूजर द्वारा किसी एक file को modify किया जाता है तब इसे recompile किया जाता है |और इसे पहले compile प्रोसेस मे मिली दूसरी file से merge किया जाता है | इस्लोये c++ लंगौगे एक बड़े प्रोग्राम को handle करने के लिए उपयुक्त language है | लेकिन c++ language इसके अलवा कई और भी facility भी देता है |
जैसे UNIX और Linux सिस्टम मे , track() किसी file को track करता है जो प्रोग्राम की dependency और last मॉडिफिकेशन को ट्रैक करता है  | जब इस track() function को execute किया जाता है तब ये प्रोग्राम किसी प्रोग्राम मे last compile प्रोसेस मे हुई changes को ट्रैक करता है और steps को hold भी करता है जो कसी प्रोग्राम को execute करने मे किया जाता है  |
borland c++ , Microsoft visual c++ और metrowerk code warrier भी इस तरह की facility देता है | जिसमे किस लम्बे प्रोग्राम को handle करने मे आसानी होती है |इस तरह के प्रोग्राम को design करने के लिए निन्म method को use किया जाता है :-
कसी प्रोघ्रम को break करने के लिए दो supporting function को दो अलग अलग file मे रखा जाता है |इस प्रोग्राम मे rectangular coordinator को polar coordinate मे convert किया जाता है |इस function main() मे दो प्रोग्राम को dotted lines से seperate नहीं किया जाता है | जब किसी structure को declare दोनों file मे सही तरह से declare किया जाता है |  अगर कसी एक struture मे चगेस किया जाता है तब स्दोनो declaration मे change किया जाता है | ये प्रॉब्लम को generate किया जाता है |
इस प्रॉब्लम को solve करने के लिए #include को use किया जाता है |  struture को file header मे लिखा जाता है | जिससे दोनों  files मे अलग अलग struture मे  मॉडिफिकेशन नहीं करना पड़ता है |
इस तरह प्रोग्राम को तीन मुख्य भागो मे convert किया जाता है :
1.header file : इस file मे , structure declaration और function prototype को declare किया जाता है |
2.source file : इस file मे , sturture related function को execute किया जाता है |
3.source file : इस file मे , structure function को call किया जाता है |

source code :\
In file struct

#ifndef COORDIN_H
#define COORDIN_H

struct polar {
double dis;
double angle;
};
struct rect
{
double a;
double b;
};
polar convert(rect);
void show(polar);

In file 1 :
#include<iostream.h>
#include<conio.h>
#include struct
using namespace std;
int main()
{
rect r;
polar p;
cout<<“Enter value of ‘x’ or ‘y’ :”;
while(cin>>r.a >> r.b)
{
p = convert(r);
show_polar(p);
cout<<“Next two number // For Quit , Enter ‘q’ “;
}
cout<<“Have a nice day !”;
getch();
}

In file 2
#include<iostream.h>
#include<conio.h>
#include struct
using namespace std;
polar convert(rect rec)
{
polar out;
out.dis = sqrt(rec.a*rec*a +rec.b*rec.b);
out.angle = atan(rec.b ,rec.a);
return out;
}
void show(polar output )
{
const degree = 57.295;
cout<<“Distance :”<<output.dis;
cout<<“Angle ( in rad ) : “<<output.angle;
cout<<“Angle ( in degree) :”<<output.angle * degree ;
}

इस उदाहरन से प्रोग्राम के design का एक नया रूप ही discuss किया है इस design पर based कुछ उदहारण निन्म है :

उदहारण मे :
इस उदाहरन मे , दो  file को use किया जाता है जिसमे class math को header file मे declare किया जाता है | और  main() function को  file1 मे declare किये जाता है |
class math को header file मे इसलिए  declare किये जाता है क्योकि इसे किसी भी प्रोग्राम मे use किया जा सकता है | इस header file मे  declare math class मे मुख्य चार functions को use किया जाता है |
add( ) : इस function से addition()को calculate करने  के  किया जाता है |
sub() : इस function मे subtrction को calculate किया जाता है |
mul() : इस function का use multiplication को calculate करने के लिए किया जाता है |
div() : इस function का use division को calculate करने के लिए किया जाता है |

file 2 मे main() को declare किया जाता है | जिसमे class math के function को use किया जाता है |

Header file मे

class math ()
{
private :
int output;
public:
// Function definition
void add(int a, int b)
{
output = a + b;
cout<<“Output : “<<output;
}
public:
// Function definition
void div(int a, int b)
{
output = a / b;
cout<<“Output : “<<output;
}
public:
// Function definition
void sub(int a, int b)
{
output = a – b;
cout<<“Output : “<<output;
}
public:
// Function definition
void mul(int a, int b)
{
output = a * b;
cout<<“Output : “<<output;
}
};

file 1 मे
#include <iostream>
#include<conio.h>
#include header
using namespace std;
void  main()
{
math  c;
int n1 , n2 ;
char choice ;
cout<<“Enter ‘+’ for addition”<<endl
<<“Enter ‘-‘ for subtraction”<<endl
<<“Enter ‘*’ for multiplication”<<endl
<<“Enter ‘/’ for division”<<endl;
cout<<“Enter choice : “;
cin >> choice;
cout<<“Enter n1 : “;
cin >> n1;
cout<<“Enters n2 : “;
cin >> n2;
switch(choice)
{
case ‘+’ :
c.add(n1,n2);
break;
case ‘-‘ :
c.sub(n1,n2);
break;
case ‘*’ :
c.mul(n1,n2);
break;
case ‘/’ :
c.div(n1,n2);
break;
default :
cout<<“invalid choice “;
break;
}
getch();
}

Sbistudy

Recent Posts

भारत पर पहला तुर्क आक्रमण किसने किया कब हुआ first turk invaders who attacked india in hindi

first turk invaders who attacked india in hindi भारत पर पहला तुर्क आक्रमण किसने किया…

1 day ago

बैराठ सभ्यता कहाँ स्थित है वर्तमान में bairath civilization in rajasthan in hindi present location

bairath civilization in rajasthan in hindi present location बैराठ सभ्यता कहाँ स्थित है वर्तमान में…

3 days ago

आहड़ सभ्यता की प्रमुख विशेषता , स्थल उत्खनन किसने किया कहाँ स्थित है ahar civilization in hindi

ahar civilization in hindi आहड़ सभ्यता की प्रमुख विशेषता , स्थल उत्खनन किसने किया कहाँ…

4 days ago

कालीबंगा सभ्यता के नोट्स , खोज कब और किसने की के बारे में kalibanga sabhyata in hindi

kalibanga sabhyata in hindi कालीबंगा सभ्यता के नोट्स , खोज कब और किसने की के…

4 days ago

सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है

सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…

6 days ago

मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the

marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…

6 days ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now