Ghar Baithe Paise Kaise Kamaye | Work From Home Jobs | घर बैठे ऑनलाइन पैसे कैसे कमाए



 भारत में ऐसे कई पढ़े-लिखें युवा है जो नौकरी करते है या नौकरी की तलाश कर रहे हैं। लेकिन इनमे से कई युवा है जो घर बैठे पैसे कमाना चाहते हैं लेकिन कैसे? आज के समय में पैसा कमाना बहुत आसान है, लेकिन लोगो को पैसे कमाने के तरीके पता होना चाहिए।

आज भारत में लगभग 90% लोग है जो नहीं जानते कि ऑनलाइन पैसे कमाने के तरीके क्या और घर बैठे भी पैसा कमाया जा सकता हैं। उनमे से सिर्फ 10% लोग ही ऑनलाइन पैसे कैसे कमाए? के बारे में सर्च करते हैं। आज ऐसे कई फ्री में पैसे कमाने के तरीके है जिनके माध्यम से आप घर बैठकर आसानी से अच्छी खासी कमाई कर सकते हैं।

कई लोग है जो इन पैसे कमाने के तरीकों को जानकार घर बैठे लाखों में इनकम कर रहे हैं और कुछ लोग हैं जिन्होंने ऑनलाइन पैसा कमाना (Work From Home) शुरू कर दिया। ऐसे में अगर आपने घर बैठे पैसा कमाने का विचार कर लिया है, और घर बैठे फ्री में पैसे कमाना चाहते है तो, यह आर्टिकल उन लोगो के लिए है जो ऑनलाइन फ्री में पैसा कमाना चाहते हैं।

घर बैठे ऑनलाइन पैसे कैसे कमाए?

देखा जाए तो घर बैठे पैसे कमाने का किसका मन नहीं करता? लेकिन हम आपकी जानकारी के लिए बता दे कि ऑनलाइन पैसे कमाना कोई राकेट साइंस नहीं हैं। हालाँकि, फ्री समय में कुछ एक्स्ट्रा पैसा कमाया जाये तो बहुत अच्छा हैं। ऑनलाइन पैसे कमाने के लिए क्या करना होगा? ये भी सवाल दिमाग में आता हैं। अगर आप पढ़े-लिखे है तो यह आपके लिए और भी आसान होगा।

ऐसे में आप पैसे कमाने को वो तरीके ढूंढ रहे हैं, जिसमें निवेश भी ना करना पड़े (How to earn money from home without investment) और कमाई भी हो सके तो आपके पास चीजों का होना बहुत जरूरी हैं।

  • लैपटॉप या मोबाइल (4 GB रैम)
  • फ़ास्ट इन्टरनेट
  • थोड़ी स्किल (टेक्नोलॉजी और कंप्यूटर)
  • कम से कम रोजाना 2 घंटे का समय

इसके बाद आप ऑनलाइन काम करके पैसे कमा सकते हैं। तो आइये जानते है ऑनलाइन पैसे कमाने के तरीको के बारे में।

1. YouTube करें कमाई

आज के समय में सबसे ज्यादा ऑनलाइन पैसा कमाने के तरीके में YouTube का नाम सबसे आगे आता है। इन दिनों YouTube के माध्यम से कई लाखों, अर्बो कमा रहे हैं। ऐसे में आज हर कोई यूट्यूब से पैसे कमाना चाहता है। यूट्यूब सबसे पॉपुलर प्लेटफॉर्म हैं घर से पैसे कमाने का और आप भी YouTube से ऑनलाइन पैसे कमा सकते हैं. लेकिन कैसे?

जी हाँ! Youtube मोबाइल से पैसा कमाने का तरीका बन चुका हैं। अगर आपका भी सवाल है कि YouTube से ऑनलाइन पैसे कैसे कमाए? तो इसके लिए आपके पास एक यूट्यूब चैनल होना जरुरी हैं। यदि नहीं है तो आप फ्री में बना सकते हैं। आपको यह पता होना चाहिए कि आप अपने चैनल पर क्या बताने वाले हैं। जिन लोगों को घूमने का शौक है वो ट्रेवल चैलन बनाता है, ऐसे ही कुकिंग, गेमिंग, टेक, डांसिंग, सिंगिंग, कॉमेडी, एंटरटेनमेंट के तमाम ऐसे कई चेनल्स हैं, जिनसे आज लोग लाखों कमा रहे हैं।

इसी तरह से आप भी अपना चैनल बनाकर और अच्छा, फ्रेश कंटेंट ढूंढ़ कर वीडियों बनाकर अपलोड करके अच्छी इनकम कर सकते हैं। हालांकि इसमें आपको कुछ समय देना होगा और धेर्य रखना होगा।

2. ब्लॉग बनाकर करे कमाई

यदि आप विडियो नहीं बना सकते तो आप अपना खुद का वेबसाइट या ब्लॉग स्टार्ट कर सकते हैं. ऑनलाइन पैसा कमाने के तरीके में Website या Blog भी काफी पोपुलर है। आजकल Blog लिखना आम बात हो गई है। Blog लिखने के लिए कंटेंट राइटिंग और स्किल होना जरुरी हैं। इसके अगर आप लिख नहीं सकते तो किसी प्रकार की टूल वेबसाइट स्टार्ट कर सकते हैं।

यदि आप नये है तो बिना पैसा खर्च किए भी ब्लॉग या वेबसाइट शुरू कर सकते हैं. फ्री में blog या वेबसाइट बनाने के लिए Blogger.com आज का सबसे अच्छा प्लेटफॉर्म हैं।

2. ब्लॉग बनाकर करे कमाई

यदि आप विडियो नहीं बना सकते तो आप अपना खुद का वेबसाइट या ब्लॉग स्टार्ट कर सकते हैं. ऑनलाइन पैसा कमाने के तरीके में Website या Blog भी काफी पोपुलर है। आजकल Blog लिखना आम बात हो गई है। Blog लिखने के लिए कंटेंट राइटिंग और स्किल होना जरुरी हैं। इसके अगर आप लिख नहीं सकते तो किसी प्रकार की टूल वेबसाइट स्टार्ट कर सकते हैं।

यदि आप नये है तो बिना पैसा खर्च किए भी ब्लॉग या वेबसाइट शुरू कर सकते हैं. फ्री में blog या वेबसाइट बनाने के लिए Blogger.com आज का सबसे अच्छा प्लेटफॉर्म हैं।

3. Affiliate Marketing से करें कमाई

ऑनलाइन पैसे कमाने के तरीकों में Affiliate Marketing आज का तीसरा सबसे बड़ा तरीका हैं। हालाँकि, किसी के लिए यह पहला पैसे कमाने का तरीका भी हो सकता हैं। एफिलिएट मार्केटिंग एक एसा तरीका है जिसमे किसी दूसरी कंपनी के प्रोडक्ट किसी प्लेटफॉर्म के माध्यम से प्रमोट करते हैं। जब कोई व्यक्ति उस प्रोडक्ट को खरीदता है तो उसके बदले में कमीशन मिलता हैं।

एफिलिएट मार्केटिंग को आप Retail Shop का नाम दे सकते हैं. इसके लिए आपको Flipkart और Amazon के साथ पार्नरशिप करना होता है, जिससे आप इनके प्रोडक्ट्स को प्रमोट कर सकते हैं। यदि आपके पास यूट्यूब चैनल या वेबसाइट है तो आप इससे ज्यादा कमाई कर सकते हैं।

Affiliate Marketing से आज लोग लाखों रुपये कमा रहे हैं। इससे कमाने के लिए सबसे पहले उन प्रोडक्ट्स की लिस्ट बनाएं, जिन्हें आप प्रमोट करना चाहते हैं। उसके बाद बाद उसे Flipkart या Amazon के एफिलिएट लिंक से जोड़ दें। ऐसे में लिस्ट को देख लोग अपनी पसंद से प्रोडक्ट्स पर्चेज कर पाएंगे। इससे आपको कमीशन मिलेगा।

यदि आपके पास यूट्यूब चैनल या वेबसाइट नहीं है तो आप सोशल मीडिया पर प्रमोट करके एफिलिएट मार्केटिंग से ऑनलाइन पैसे कमा सकते हैं।

4. Content Writing से करें कमाई

यदि आपको स्टोरी, खबर, कविता लिखने का शौक है तो, Content Writing आपके लिए बेस्ट विकल्प हैं। इस टेलेंट से आप लाखों कमा सकते हैं। Content Writing से कमी करने के लिए आपकी भाषा, व्याकरण के बारे में अच्छी जानकारी होनी चाहिए। इसके बाद आप Content Writing कर ऑनलाइन पैसा कमा सकते हैं।

हिंदी हो या अंग्रेजी दोनों भाषाओं में Content Writing का काम ढूंढ़ सकते हैं। इसके लिए आप किसी ब्लॉग के लिए Content Writing का काम कर सकते हैं। आपको फ्रेश और अच्छा कंटेंट लिखना होगा, हां थोड़ा समय लगेगा, लेकिन आपको ही फायदा होगा।

इसके लिए आपको कोई भी Investment की जरूरत नहीं है। मार्केट में आपको कई कंपनियां या ब्लोग्स मिल जायेंगे जो ऑनलाइन फ्रीलांसर हायर करती हैं, जिन्हें आप सैंपल कंटेंट भेजकर काम शुरू कर सकते हैं। इसके अलावा आप पैसा देने वाली वेबसाइट के लिए भी लिखना शुरू कर सकते हैं।

यदि आप हिंदी में अच्छे है और आप टेक (हाउ टू, मेक मनी, बिज़नस, फाइनेंस और लोन, शेयर मार्केट) के बारे में हिंदी कंटेंट लिखने में अनुभव है तो आप हमारे ब्लॉग के लिए Content Writing का काम कर सकते हैं।

5. ऑनलाइन टीचिंग या ट्यूशन से पैसे कमाए

आज के दिनों में ऑनलाइन टीचिंग या ट्यूशन काफी बढ़ रहा हैं। आज हर स्कूल और कोचिंग क्लासेज ऑनलाइन हो चुके है और ऑनलाइन पढ़ा रहे हैं। ऐसे में अगर आपमें बच्चों को पढ़ाने का हुनर है या किसी विषय में अच्छी जानकारी है तो आपके लिए ऑनलाइन टीचिंग या ट्यूशन सबसे अच्छा विकल्प है।

पैसे कमाने का यह तरीका उन महिलाओं के लिए बेस्ट है, जो हाउस वाइफ हैं और घर बैठे कुछ काम करके पैसा कमाना चाहती हैं। ऐसी महिलाएं ऑनलाइन टीचिंग या ट्यूशन देकर अच्छे-खासे पैसे कमा सकती हैं। आज के समय में ऑनलाइन टीचिंग या ट्यूशन से महीने के 30 हजार से 50 हजार तक आसानी से कमा सकते है।

इसके लिए आप YouTube चैनल स्टार्ट करके सुरुआत कर सकते हैं। जितना अच्छे से आप पढ़ाएंगे उतने ही स्टूडेंट्स आपसे जुड़ेंगे। इसके अलावा आप किसी बड़ी ऑनलाइन क्लासेज से जुड़ सकते है और पढ़ा सकते हैं। यदि आप खुद का करते है तो बहुत अच्छी बात हैं। आप ऑनलाइन टीचिंग के साथ – साथ नोट्स, मोस्ट प्रश्न, ई-बुक आदि बेचकर भी पैसे कमा सकते हैं।

6. गेम खेलकर कमाए

आज बहुत से लोग है जो सिर्फ गेम खेलकर अच्छी इनकम कर रहे हैं। यदि आप को भी गेम खेलने का शोक है तो इसे आप अपना करियर बना सकते हैं। जी हाँ गेम खेलना पैसे कमाने का बहुत अच्छा तरीका हैं।

आप ऑनलाइन अपने पीसी व मोबाइल पर गेम खेल सकते हैं. आज ऐसे कई गेमिंग प्लेटफार्म है जहाँ पर गेम गेल सकते हैं। मोबाइल के लिए अच्छे गेमिंग प्लेटफार्म में Winzo, Bigcash, Skilclash आदि हैं।

इनके अलावा आप MPL, Gamezy, Paytm First Games पर गेम्स खेल सकते है और जीत सकते हैं। आप अपने जीते हुए पैसों को अपने Paytm और बैंक अकाउंट में ट्रान्सफर कर सकते हैं।

7. सोशल मीडिया से करे कमाई

आज फेसबुक, ट्विटर, इंस्टाग्राम और स्नैपचैट जैसी सोशल मीडिया साइट्स का इस्तेमाल काफी किया जा रहा हैं किंतु, इनसे आप पैसे भी कमा सकते हैं। हालांकि, इसके लिए आपको इन सोशल मीडिया साइट पर थोड़ा पॉपुलर होना पड़ेगा। इसके लिए आपको अच्छे-खासे फॉलोवर्स करना होगा।

यदि सोशल मीडिया पर फॉलोवर्स की बात करें तो आपके कम से कम 10 हजार फॉलोवर्स होना बहुत जरुरी हैं। इसके बाद आप पैसा कमाना स्टार्ट कर सकते हैं। आप अपना फेसबुक व इंस्टाग्राम पेज बना सकते हैं और उस पर अच्छा-अच्छा कंटेंट देकर पेज लाइक्स और फॉलोवर्स बढ़ा सकते हैं।

जब पेज के लाइक्स व फॉलोवर्स बहुत अधिक हो जाएं तो आप स्पॉन्सर पोस्टिंग, एफिलिएट मार्केटिंग आदि कर सकते हैं। इतना ही नहीं, अगर आप चाहे तो अच्छी कीमत में किसी को वह पेज बेच भी सकते हैं।

8. वीडियो एडिटिंग

एक अच्छा विडियो लोगो को लुभाता हैं बस उसकी एडिटिंग अच्छी होनी चाहिए. आज वीडियो एडिटिंग भी एक अच्छा पैसे कमाने का तरीका बन चूका हैं. इस काम को आप आसानी से घर बैठे अपने कंप्यूटर, लैपटॉप या मोबाइल में कर सकते हैं। कई बड़े YouTuber हैं जो लगातार वीडियो बनाकर अपलोड कर रहे हैं और उन्हें अपने वीडियोज को एडिट करने के लिए एक अच्छा विडियो एडिटर की तलाश होती है।

ऐसे में यदि आपको अच्छा विडियो एडिटिंग आता हैं और आपको विडियो एडिटर के रूप में अनुभव है, तो घर बैठे पार्ट टाइम करके इससे अच्छी की जा सकता है। आपको बता दें कि एक एक्सपीरियंस वीडियो एडिटर प्रोजेक्ट के हिसाब से महीने के 40000-50000 रुपये तक कमा सकता है। वीडियो एडिटिंग का प्रोजेक्ट लेने के लिए आपको ऐसे YouTubers की तलाश करना होगा जिन्हें एक्सपीरियंस वीडियो एडिटर की जरुरत हैं।

9. ट्रांसलेशन का काम

यदि आपको किसी भाषा का अच्छे से ज्ञान है और उसका ट्रांसलेशन कर सकते हैं या फिर आपका हिंदी से अंग्रेजी या अंग्रेजी से हिंदी का ट्रांसलेशन अच्छा है तो आप ट्रांसलेशन का काम करके अच्छे पैसे कमा सकते हैं। आपको ट्रांसलेशन का काम फ्रीलांस वेबसाइटों से भी मिल सकता है और कई कंपनियां काम ही ट्रांसलेशन का करती हैं, जो आपको ट्रांसलेशन का कॉन्ट्रैक्ट दे सकती हैं। हालांकि, ध्यान रखिए कि आप ट्रांसलेशन में कोई गलती ना करें, क्योंकि ऐसे काम अधिकतर भरोसे पर ही चलते हैं।

10. वेब और ऐप ऐप डेवलपमेंट

आज के दौर में वेबसाइट व ऐप डेवलपमेंट का काम खूब जोरों पर है। आजकल लगातार वेबसाइट व ऐप बन रहे हैं क्योंकि हर व्यक्ति अपने बिजनस को ऑनलाइन करते जा रहे हैं। ऐसे में यदि आपको वेब और ऐप डिवेलपमेंट का अच्छी जानकारी है तो आपके पास डेवलपमेंट का काम कर के पैसे कमाने का शानदार मौका है। आज नई – नई कंपनियां मार्केट में रही है जो अपनी वेबसाइट या ऐप बनवाती हैं ऐसे में आप उनके लिए काम कर सकते हैं।

वेबसाइट और ऐप डिवेलपमेंट भी घर बैठे ऑनलाइन पैसा कमाने के तरीकों में से एक है। हालांकि, इस काम के लिए आपके पास खास स्किल होने की जरूरत है। अगर आपको वेबसाइट डेवलपमेंट का काम अच्छे से नहीं आता है तो इस काम में बिल्कुल हाथ ना डालें।

वेब और ऐप डिवेलपमेंट में आप अपने समय और काम के अनुसार पैसे वसूल सकते हैं। आपको बता दें कि एक वेब और ऐप डेवलपर प्रोजेक्ट के हिसाब से महीने के 40000-50000 रुपये तक आसानी से कमा सकता है।

हमने आपको यहाँ पर घर बैठे ऑनलाइन पैसे कैसे कमाए (Online Paise Kaise Kamaye), ऑनलाइन पैसे कमाने के तरीके बताये हैं। जिनके माध्यम से कोई भी घर बैठे ऑनलाइन पैसे कमा सकते है।

हालांकि, आपके पास इंटरनेट की सुविधा होनी जरूरी है। हम आपकी जानकारी के लिए बता दे कि जिस काम के बारे में आको जानकारी हो वाही करें और ना हो तो बिल्कुल हाथ ना डालें। आप बताएं गए तरीकों में से एक तरीका सेलेक्ट करें, जब एक में सफल हो जाये तो दुसरे तरीकों पर काम करें।



Function Array Search in C Plus Plus

 Function Array Search in C Plus Plus. This is a C Plus Plus programming language program to input size of an array of integer numbers. The program will take item from the user to be searched in this array. If it finds the specified element in array, a suitable message of Item found on location is shown on the screen. Otherwise it will show a message of “Item not fond in this array”.

How this program works?

  1. First of all the user will enter size n of the array.
  2. Enter n items in array
  3. Input the item to be searched.
  4. Call the function search() with three arguments, array name, size n and item to be searched in array.
  5. The function search() will display location if item found or a ‘not found’ message.
  6. This function uses a for loop from 0 to n-1 for traversing he whole array.
  7. It compares each element of the array with given item to be searched.
  8. The sample run output of this program is at end of this tutorial.

Explanation of the User defined C Function

void search(int a[], int n, int item) 
{ 
int i; 
for (i = 0; i < n; i++) 
  { 
    if (a[i] == item) /* If required element is found */
      { cout<<item<<" is present at location "<<i+1<<" in the given array"; break; } 
  } 

if (i == n) cout<<item<<" isn't present in the array.\n"; 
}

Accept the parameters array a, size n and the item to search.

Write down a for loop from 0 to last element of the array.

Check if  the current array item is equal to the item.

If item is equal to the array element, display item found on the location.

Use break statement to terminate the loop.

After loop check if i is equal to n then show the message like “Item not found in array”.

The Source Code of C++ Program using Function Array Search

#include<iostream>
using namespace std;

void search(int a[], int n , int item);
int main()
{
  int a[100], item, i, n;

  cout<<"Enter number of elements in array[Maximum 100]=";
  cin>>n;

  
  for (i = 0; i < n; i++)
    {
    cout<<"Enter the Element Number "<<i+1<<" in Array=";
	cin>>a[i];
	}

  cout<<"Enter a number to search in the array=";
  cin>>item;

  // call to function

   search(a,n,item);  
    return 0;
}


  void search(int a[], int n, int item)
  {
  
  int i;
  for (i = 0; i < n; i++)
  {
    if (a[i] == item)    /* If required element is found */
    {
      cout<<item<<" is present at location "<<i+1<<" in the given array";
      break;
    }
  }
  if (i == n)
    cout<<item<<" isn't present in the given array.\n";
}

Second Version of Program Search Array

//Program to search an element from an array of integer numbers


#include<iostream>
using namespace std;

void search(int a[], int n , int item);
int main()
{
  int a[100], item, i, n;

  cout<<"Enter number of elements in array[Maximum 100]=";
  cin>>n;

  
  for (i = 0; i < n; i++)
    {
    cout<<"Enter Element Number "<<i+1<<" in Array=";
	cin>>a[i];
	}

  cout<<"Enter a number to search in array=";
  cin>>item;

  // call to function

   search(a,n,item);  
    return 0;
}


  void search(int a[], int n, int item)
  {
  
    int i;
    for (i = 0; i < n; i++)
     {
       if (a[i] == item)    /* If required element is found */
         {
           cout<<item<<" is present at location "<<i+1<<" in the given array";
           return;
         }
     } 
    cout<<item<<" isn't present in the given array.\n";
  }

Output of Search an Item in Array Program in C++

Enter number of elements in array[Maximum 100]=5
Enter Element Number 1 in Array=4
Enter Element Number 2 in Array=7
Enter Element Number 3 in Array=89
Enter Element Number 4 in Array=34
Enter Element Number 5 in Array=23
Enter a number to search in array=34
34 is present at location 4 in the given array
Enter number of elements in array[Maximum 100]=10
Enter Element Number 1 in Array=1
Enter Element Number 2 in Array=2
Enter Element Number 3 in Array=3
Enter Element Number 4 in Array=4
Enter Element Number 5 in Array=5
Enter Element Number 6 in Array=78
Enter Element Number 7 in Array=90
Enter Element Number 8 in Array=32
Enter Element Number 9 in Array=12
Enter Element Number 10 in Array=45
Enter a number to search in array=100
100 isn't present in the given array.

C Plus Plus Program Alphabet Triangle Pattern

 Task: Write down a C++ Program to display Alphabet Triangle Pattern. The user will enter the height of triangle. Then the program will show a right angle triangle of alphabets in Capital letters.

How Alphbets Triangle Program Works

This program uses nested for loops to display the required output pattern. The program asks the user to enter height of the triangle. The user will enetr a whole number like 5 or 10 etc. The program will display the right angle triangle of capital letters according to the required height.

The first loop uses a loop control variable row. This row variable shows the lines of the output. Wheras the variable col represents a column to display characters.

This program uses a char variable intialized with ‘A’. It will print A in first row. And it will print two characters A and B in second row and so on.

The outer for loop in nested loops is used to control the number of lines or rows. Whereas the col varible is used to print the required number of alphabetics.

The Source Code of Alphabets Triangle Program


// C++ Program to display 
// Right Angle Triangle
// of Capital Alphabets A,B,C
#include<iostream>

using namespace std;

int main()
{

  /*
   A
   AB
   ABC
   ABCD
   ABCDE 
  */

  char row,col,ch;
  int height;
  cout<<"Enter the height of Triangle=";
  cin>>height;
  for(row=1;row<=height;row++)
  {
  	 ch='A';
	 for(col=1;col<=row;col++)
  	   {
		cout<<ch<<" ";
		ch++;
	   }
  	cout<<endl;
  	
  }
  return 0;

}

/*
OUTPUT
Enter the height of Triangle=10
A
A B
A B C
A B C D
A B C D E
A B C D E F
A B C D E F G
A B C D E F G H
A B C D E F G H I
A B C D E F G H I J

--------------------------------
Process exited after 28.16 seconds with return value 0
Press any key to continue . . .
*/

Output of Alphabet Triangle Program


C++ Circle Area or Circumference Program

 Write a C++ Program To Calculate Circle Area or Circumference according to the User choice.

The Source Code of C++ Circle Program

// Write a program that uses two user defined functions
// for calculating area and circumference of a circle.
//The program will input radius and asks the user
// to enter a choice 1 or 2.
//If the user enters 1, it will display area
// if the user eneters 2 then circumference
//of the circle will be the output

#include<iostream>
using namespace std;
void area(float);
void circumference(float);
int main()
{
	float radius;
	int choice;
	cout<<"Enter Radius of Circle: ";
	cin>>radius;
	cout<<"Enter Your Choice 1 for Area and 2 for Circumference:";
	cin>>choice;
	
	if(choice==1)
	  area(radius);
	else if(choice==2)
	  circumference(radius);
	else
	  cout<<"Wrong choice!";
	
	return 0;
}


void area(float r)
{
	cout<<"Area of Circle="<<(3.1415 * r* r);
}
void circumference(float r)
{
	cout<<"Circumferenceb of Circle="<<(2.0 * 3.1415 * r);
}

Output of the C++ Circle Program Calculations

Enter Radius of Circle: 2.5
Enter Your Choice 1 for Area and 2 for Circumference:1
Area of Circle=19.6344
——————————–
Process exited after 18.92 seconds with return value 0
Press any key to continue . . .

Enter Radius of Circle: 2.5
Enter Your Choice 1 for Area and 2 for Circumference:2
Circumferenceb of Circle=15.7075
——————————–
Process exited after 21.03 seconds with return value 0
Press any key to continue . . .

Enter Radius of Circle: 5.26
Enter Your Choice 1 for Area and 2 for Circumference:1
Area of Circle=86.9178
——————————–
Process exited after 11.3 seconds with return value 0
Press any key to continue . . .

Enter Radius of Circle: 10.67
Enter Your Choice 1 for Area and 2 for Circumference:2
Circumferenceb of Circle=67.0396
——————————–
Process exited after 17.52 seconds with return value 0
Press any key to continue . . .

CPP Program to write / add records in Binary File

 How this Program Works?

This C++ Program will open a binary file either by creating a new file or by just opening it if it already exists. Then it will use write() method to write for first time or append more records in the existing file. It is because we have opened the file in append mode as follows:


//opening binary file in appending / writing mode

file1.open(“d://cppfile.dat”,ios::binary |ios::app);

The following figure shows that the file cpppfile.dat has been created on D drive after execution f the C++ program.

C++ Program: write / add records in Binary File
C++ Program: write / add records in Binary File

First of all a user will input a record and it is written into binary file using write()method as follows:

/* write a record to binary file */
file1.write((char*)&srecord,sizeof(srecord));

Then program will ask from the user: Add more records? press y or n:

The user will press ‘y’ if he wishes to add more records. Otherwise he will type ‘n’, if he wishes to stop the program. This input logic is maintained by a while loop.

Source code for the C ++ program to enter records in a binary file.
/* Write a C Program to add more records at
end of already existing binary file
that is append file operation
*/
#include<iostream>
#include<fstream>
#include<conio.h>
#include<stdlib.h>
#include<string>
using namespace std;

struct student
{
int rollno;
char name[30];
}srecord;

fstream file1;
int main()
{
char ans;
int i;
//opening binary file in appending / writing mode	

file1.open("d://cppfile.dat",ios::binary |ios::app);

if(!file1)
{
cout<<"File could not open";
exit(0);
}

while(1)
{
cout<<"\nEnter Student Record\n";
cout<<"Roll No:";
cin>>srecord.rollno;
getchar();
cout<<"Name:";
gets(srecord.name);
/* write a record to binary file */
file1.write((char*)&srecord,sizeof(srecord));
cout<<"\nRecord has been added successfully";

cout<<"\nAdd more records? press y or n =";
ans=getche();
if(ans=='n' || ans=='N')
break;
}
file1.close();
cout<<"\nProgram ended: C++ Program To Add more Student Records in Binary File:";
return 0;
}

A Sample Run of the C++ Program: write / add records in Binary File

Enter Student Record
Roll No:101
Name:sajid

Record has been added successfully
Add more records? press y or n =y
Enter Student Record
Roll No:102
Name:majid

Record has been added successfully
Add more records? press y or n =n
Program ended: C++ Program To Add more Student Records in Binary File:
--------------------------------
Process exited after 41.99 seconds with return value 0
Press any key to continue . . .

C ++ Program To Display All File Records

 

The source code of C Plus Plus Program To Read and Display All Records from a Binary File

/* Write a C Program to read and display 
all records from an existing binary file
*/
#include<iostream>
#include<fstream>
#include<conio.h>
#include<stdlib.h>
#include<string>
using namespace std;

struct student
{
int rollno;
char name[30];
}srecord;

fstream file1;
int main()
{
char ans;
int i;
//opening binary file in reading mode	

file1.open("d://cppfile.dat",ios::binary |ios::in);

if(!file1)
{
cout<<"File could not open";
exit(0);
}

while(!file1.eof())
{
file1.read((char*)&srecord,sizeof(srecord));
if(!file1.eof())
{
cout<<"\n------------------\n";
cout<<"Roll No:"<<srecord.rollno;
cout<<"\nName:"<<srecord.name;
}
}
file1.close();
cout<<"\nProgram ended: C++ Program To Read and Display all Student Records from Binary File:";
return 0;
}

A sample run of the C++ Read Binary File Program

------------------
Roll No:1
Name:sajid
------------------
Roll No:2
Name:majid
Program ended: C++ Program To Read and Display all Student Records from Binary File:
--------------------------------
Process exited after 3.887 seconds with return value 0
Press any key to continue . . .

CPP Program to write / add records in Binary File

 

How this Program Works?

This C++ Program will open a binary file either by creating a new file or by just opening it if it already exists. Then it will use write() method to write for first time or append more records in the existing file. It is because we have opened the file in append mode as follows:

//opening binary file in appending / writing mode

file1.open(“d://cppfile.dat”,ios::binary |ios::app);

The following figure shows that the file cpppfile.dat has been created on D drive after execution f the C++ program.

C++ Program: write / add records in Binary File

C++ Program: write / add records in Binary File

First of all a user will input a record and it is written into binary file using write()method as follows:

/* write a record to binary file */
file1.write((char*)&srecord,sizeof(srecord));

Then program will ask from the user: Add more records? press y or n:

The user will press ‘y’ if he wishes to add more records. Otherwise he will type ‘n’, if he wishes to stop the program. This input logic is maintained by a while loop.

Source code for the C ++ program to enter records in a binary file.

/* Write a C Program to add more records at
end of already existing binary file
that is append file operation
*/
#include<iostream>
#include<fstream>
#include<conio.h>
#include<stdlib.h>
#include<string>
using namespace std;

struct student
{
int rollno;
char name[30];
}srecord;

fstream file1;
int main()
{
char ans;
int i;
//opening binary file in appending / writing mode	

file1.open("d://cppfile.dat",ios::binary |ios::app);

if(!file1)
{
cout<<"File could not open";
exit(0);
}

while(1)
{
cout<<"\nEnter Student Record\n";
cout<<"Roll No:";
cin>>srecord.rollno;
getchar();
cout<<"Name:";
gets(srecord.name);
/* write a record to binary file */
file1.write((char*)&srecord,sizeof(srecord));
cout<<"\nRecord has been added successfully";

cout<<"\nAdd more records? press y or n =";
ans=getche();
if(ans=='n' || ans=='N')
break;
}
file1.close();
cout<<"\nProgram ended: C++ Program To Add more Student Records in Binary File:";
return 0;
}

A Sample Run of the C++ Program: write / add records in Binary File

Enter Student Record
Roll No:101
Name:sajid

Record has been added successfully
Add more records? press y or n =y
Enter Student Record
Roll No:102
Name:majid

Record has been added successfully
Add more records? press y or n =n
Program ended: C++ Program To Add more Student Records in Binary File:
--------------------------------
Process exited after 41.99 seconds with return value 0
Press any key to continue . . .