pre defined streams (cin, cout) for input and output in cpp

The header file <iostream.h> of C++ declares certain objects that are used to perform input and output operations on the standard input and output device. The iostream class inherits istream and ostream class for input and output operations respectively like cin, cout, cerr and clog.

C++ की हैडर फाइल iostream.h के द्वारा कुछ ऑब्जेक्ट को परिभाषित किया गया है जिनका प्रयोग स्टैण्डर्ड इनपुट एवं आउटपुट डिवाइस पर इनपुट व् आउटपुट संक्रिया करने के लिए किया जाता है। iostream क्लास द्वारा इनपुट और आउटपुट संक्रिया करने के लिए क्रमशः istream एवं  ostream क्लास को इन्हेरिट(विरासत) किया गया है 

The cout object in C++ is an object of class ostream. It is used to display the output to the standard output device i.e. monitor. It uses << insertion operator with cout for displaying output on stdout.
C++ में cout ऑब्जेक्ट ostream  क्लास का एक ऑब्जेक्ट है इसका प्रयोग स्टैण्डर्ड आउटपुट डिवाइस (मॉनिटर) पर आउटपुट को प्रदर्शित करने के लिए किया जाता है। यह cout के साथ << इंसर्शन ऑपरेटर का प्रयोग कर stdout पर आउटपुट प्रदर्शित करता है।   

Example:-
float p,r,t,si;
cout <<"Enter the value of principle , rate and time"<<endl;

The cin object in C++ is an object of class istream. It is used to accept the input from the standard input device i.e. keyboard. It uses >> extraction operator for taking input from stdin.
C++ में cin ऑब्जेक्ट istream  क्लास का एक ऑब्जेक्ट है इसका प्रयोग स्टैण्डर्ड इनपुट डिवाइस (कीबोर्ड) से इनपुट को प्राप्त करने के लिए किया जाता है। यह cin के साथ >> एक्सट्रैक्शन ऑपरेटर का प्रयोग कर stdin से इनपुट प्राप्त करता है। 

Example:-
cin>>p>>r>>t;

Program:- Simple interest

#include<iostream.h>
#include<conio.h>
void main(){
float p,r,t;
clrscr();
cout<<”Enter Principle, Rate and Time”<<endl;
cin>>p>>r>>t ;
float si=(p*r*t)/100 ;
cout<<”Simple Interest ="<<si<<endl;
getch();
}

No comments:

Post a Comment