C++ Program to calculate area of a triangle

How to write a C++ program to calculate area of a triangle ?


Area of Triangle - C++ Programming Question Program to find the Area of any Triangle Write a C++ program to find area of triangle.?  Make c++ program that calculate an area   program in c++ to compute and print area and perimeter of triangle  C++ Classes and Objects - calculate area and perimeter of Triangle c++ program to find area of triangle  Information: How to Find Area of Triangle using C++ Triangle Program - C++ Forum  Write a C++ program to find area of triangle Calculating an area of triangle using the inline function C++ C++ Simple Program Area Of A Triangle - C And C++ How Do I Get My C Program To Calculate Area Of A Triangle How to Write a Simple C++ Program to Find Area of Triangle
C++ Program to calculate area of a triangle



Solution:
//Program to calculate area of a triangle.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b;
cout<<"Enter height: ";
cin>>a;
cout<<"Enter base: ";
cin>>b;
a=0.5*a*b;
cout<<"Area of the triangle is: "<<a;
getch();
}

This C++ Program to calculate area of a triangle.

C - Determine If a Number is Odd or Even

How to write a C program to determine if a number is odd or even ?


Info! C program to determine if a number is odd or even
Solution:
#include <stdio.h>

int main()
{
int x;

scanf("%d", &x);

if(x % 2 == 0)
printf("Even");
else
printf("Odd");

return 0;
}

This C Program Determine If a Number is Odd or Even

C++ Print first 10 natural numbers using while loop.

How to write C++ Program to print first 10 natural numbers using while loop ?

C Program To Print First 10 Natural Numbers Program to print the sum of first n natural numbers using C++ program to find the sum of first 10 natural numbers using C Program to Calculate Sum of Natural Numbers How to print the sum of first 10 Natural Numbers using
C++ Print first 10 natural numbers using while loop.



Solution:
//Program to print first 10 natural numbers using while loop.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a=0;
while(a<10)
{
++a;
cout<<a<<endl;
}
getch();
}

This C++ Program to print first 10 natural numbers using while loop .

C++ Program to swap two numbers using function.

How to write a C++ Program to swap two numbers using function in C++ Programming ?

c program to swap two numbers using function call by value write a program to swap two numbers using function in c++ program to swap two numbers using functions in java program to swap two numbers using pointers and functions c program to swap two numbers using pointers without using third variable program to swap two numbers using call by reference in c++ program to swap two numbers using bitwise operators program to swap two numbers without using temporary variable
C++ Program to swap two numbers using function.


Solution:
//Program to swap two numbers using function.
#include<iostream.h>
#include<conio.h>
void swap(int&,int&);
void main()
{
clrscr();
int a,b,c;
cout<<"Enter one numbers: ";
cin>>a;
cout<<"Enter second number: ";
cin>>b;
swap(a,b);
cout<<a<<" "<<b;
getch();
}
void swap(int &a,int &b)
{
int c;
c=a;
a=b;
b=c;
}

This C++ Program to swap two numbers using function.

C++ Program to Find Length of a String

How to write a Program to find length of a string in C++ Programming ?


C++ Program to Find the Length of a String C++ Program to find string length c++ - calculate length of a string without using standard  String length - C, C++ and Java programming tutorials C Program to Find Length of String Without using Library ... program to find the length of the string manually - C / C++ C++ Programming Program to Calculate Length of a String Program to Calculate Length of a String c++ program to find length of string without using strlen function c++ program to find length of string using pointers program to find length of string in 8086 program to find length of string in java without using length method program to find length of string without using library function in c# how to calculate length of string in c++
C++ Program to Find Length of a String


Solution:
//Program to find length of a string.
#include<conio.h>
#include<iostream.h>
#include<stdio.h>

void main()
{
clrscr();
char a[80];
cout<<"Enter a string: ";
gets(a);
for(int i=0;a[i]!='\0';i++);
cout<<"The length of the string is: "<<i;
getch();
}

This C++ Program to Find Length of a String.

C++ Program to display a string reversed

How to write a C++ Program to display a string reversed in C++ Programming ?

Search Results Write ac program to reverse a string - C programming  Search Results C++ Program to reverse a string C++ - How To Reverse A String How to Reverse string in c++ simple program C++ Strings - Programming Questions Write A C++ Program To Reverse A String. Reverse a string - C++  Reverse a String in C++  Display A String Backwards - C And C++ c++ - Loop to print string backwards C, C++ Program to Reverse a String without using C++ Program to display a string reversed. c++ program to reverse a string without using string functions c++ program to reverse a string using for loop c++ program to reverse a string using pointers c++ program to reverse a string using array c++ program to reverse a string using recursion c++ program to reverse a string using strrev c++ program to reverse a string using stack c++ program to reverse a string without using another array
C++ Program to display a string reversed


Solution:
//Program to display a string reversed.
#include<conio.h>
#include<iostream.h>
#include<stdio.h>

void main()
{
clrscr();
char a[80];
cout<<"Enter a string: ";
gets(a);
for(int i=0;a[i]!='\0';i++);
for(int j=i;j>=0;j--)
cout<<a[j];
getch();
}

This C++ Program to display a string reversed.

C++ Program to check if two strings are identical.

How to write a C++ Program to check if two strings are identical or not in C++ Programming ?



C++ Program to check if two strings are identical. How to compare two strings in C++ How to Compare Two Strings in C++ Programming  Check if sizes of two strings are same Check whether two strings are anagram of each other
C++ Program to check if two strings are identical.

Solution:
//Program to check if two strings are identical.
#include<conio.h>
#include<iostream.h>
#include<stdio.h>
#include<string.h>

int main()
{
clrscr();
char a[80],b[80];
int z=0;
cout<<"Enter a string: ";
gets(a);
cout<<"Enter another string: ";
gets(b);
if(strlen(a)!=strlen(b))
cout<<"The strings are not identical.";
for(int i=0;a[i]!='\0';i++)
if(a[i]==b[i])
++z;
if(z==strlen(a))
cout<<"The strings are identical.";
else
cout<<"The strings are not identical.";
getch();
}

This C++ Program to check if two strings are identical.

C++ Program to check if a string is palindrome.

How to write a Program to check if a string is palindrome in C++ Programming ?

C++ Program to check whether a String is Palindrome or not C++ Program to Check Whether String is Palindrome Program to check a string is palindrome or not - C++ Tutorial C++ Program to check whether a string is PALINDROME Write a c++ program to check whether a string is a palindrom A program to check for palindromes for C++ Code Example C++ program to check whether the given string is Program:To check if a string is a palindrome or not c++ - Check if a string is palindrome palindrome program  c program to check if a string is palindrome using pointers c program to check if a string is palindrome or not check if string is palindrome java check if string is palindrome using recursion check if string is palindrome python check if string is palindrome using stack check if string is palindrome geeksforgeeks
C++ Program to check if a string is palindrome.



Solution:
//Program to check if a string is palindrome.
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
clrscr();
char a[80];
int z=1;
cout<<"Enter a string: ";
gets(a);
int n=strlen(a);
for(int i=0,j=n-1;i<=(n-1)/2;i++,j--)
{
if(a[i]!=a[j])
{
z=0;
break;
}
}
if(z==0)
cout<<"The string is not palindrome.";
else
cout<<"The string is palinrome.";
getch();
}

This C++ Program to check if a string is palindrome.

C++ Program to toggle case of letters of a String

How to write C++ Program to toggle case of letters of a string in C++ programming language ?

C++ Program to toggle case of letters of a String


Solution:
//Program to toggle case of letters of a string.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<ctype.h>
void main()
{
clrscr();
char a[80];
cout<<"Enter a string: ";
gets(a);
for(int i=0;a[i]!='\0';i++)
{
if(isupper(a[i]))
a[i]=tolower(a[i]);
else
a[i]=toupper(a[i]);
}
puts(a);
getch();
}

This C++ Program to toggle case of letters of a String.

C++ Program To Find Out Number Of Vowels In A String

How to write a C++ Program to find out number of vowels in a string in C++ programming ?

Program To Find Out Number Of Vowels In A Atring C Program to Find the Number of Vowels, Consonants, Digits To count the number of vowels in a given string  C Program to Count the Number of Vowels & Consonants c program to count vowels in a string Program to find total vowels in the string C Program to count number of vowels in a string This C program counts the number of vowels in a string using for loop. The string is input by the user. Count number of vowels, consonants and digits in a String Write a c++ program that finds the number of vowels used in C++ program: count the number of vowels in a string .. In this program ill teach you how to count the number of vowels in a string that the user inputs.
C++ Program To Find Out Number Of Vowels In A Atring


Solution:
//Program to find out number of vowels in a string.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<ctype.h>
void main()
{
clrscr();
char a[80];
int n=0;
cout<<"Enter a string: ";
gets(a);
for(int i=0;a[i]!='\0';i++)
if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u')
++n;
cout<<"Number of vowels in the string: "<<n;
getch();
}

This C++ Program To Find Out Number Of Vowels In A Atring.

C++ Function And Pointers Swap Two Numbers Program

How to write a C++ Program to swap two numbers using function and pointers in C++ programming ?


C++ Program to swap two numbers using function and pointers in C++ programming
C++ Program to swap two numbers using function and pointers in C++ programming


Solution:
//Program to swap two numbers using function and pointers.
#include<iostream.h>
#include<conio.h>
void swap(int*,int*);
void main()
{
clrscr();
int a,b,c;
cout<<"Enter one numbers: ";
cin>>a;
cout<<"Enter second number: ";
cin>>b;
swap(&a,&b);
cout<<a<<" "<<b;
getch();
}
void swap(int *a,int *b)
{
int *c;
*c=*a;
*a=*b;
*b=*c;
}

This C++ Program to swap two numbers using function and pointers in C++ programming.

C++ Declare class item to store item number and name of 5 objects

How to write a Program to declare class item to store item number and name of 5 objects in  C++ Programming ?


Program to declare class item to store item number and name of 5 objects
Program to declare class item to store item number and name of 5 objects


Solution:
//Program to declare class item to store item number and name of 5 objects.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class item
{
       private:
       int item_no;
       char item_name[80];
       public:
       void getdata()
       {
     cout<<"Enter item number: ";
     cin>>item_no;
     cout<<"Enter item name: ";
     gets(item_name);
       }
       void putdata()
       {
cout<<"Item number is: "<<item_no<<endl;
cout<<"Item name is: ";
puts(item_name);
cout<<endl;
       }
};

void main()
{
item a,b;
a.getdata();
b.getdata();
a.putdata();
b.putdata();
getch();
}

This C++ Program to declare class item to store item number and name of 5 objects in  C++ Programming.

C++ Program to overload a Function area

How to write a (C++ function overloading program)  C++ Program to overload a function area ?


Search Results Simple Program for Function Overloading Using C++ C++ Program to overload a function area C++ function overloading programs Function Overloading in Classes in C++ C++ Overloading and Operator Overloading Function Overloading C++  C++ program to swap two variables using function overloading Find the Area of shapes using function overloading C++ Function Overloading
C++ Program to overload a Function area



Solution:
//Program to overload a function area.
//C++ function overloading program.
#include<iostream.h>
#include<conio.h>
#include<math.h>

void area(float);
void area(float,float);
void area(float,float,float);

void main()
{
clrscr();
int a;
cout<<"Choose: "<<endl<<"1.Area of circle."<<endl<<"2.Area of rectangle"<<endl<<"3.Area of triangle: "<<endl;
cin>>a;
switch(a) {
case 1: cout<<"Enter radius: "<<endl;
int r;
cin>>r;
area(r);
break;

case 2: cout<<"Enter length and width: "<<endl;
int l,w;
cin>>l>>w;
area(l,w);
break;

case 3: cout<<"Enter the lengths of 3 sides of triangle: "<<endl;
int b,c,d;
cin>>b>>c>>d;
area(b,c,d);
break;
}
getch();
}

void area(float r)
{
float area=3.14*r*r;
cout<<"The area of circle of radius "<<r<<" is: "<<area;
}
void area(float l, float w)
{
float area=l*w;
cout<<"The are of rectangle of length "<<l<<" and width "<<w<<" is: "<<area;
}
void area(float b, float c, float d)
{
float s=(b+c+d)/2;
float area=sqrt(s*(s-b)*(s-c)*(s-d));
cout<<"The area of triangle is: "<<area;
}

This C++ Program to overload a function area.

C++ Program To Count Number Of Alphabets In A File

How to write C++ Program To Count Number Of Alphabets In A File in C++ programming ?


C++ Program To Count Number Of Alphabets In A File Character Count from a File, File handling program to count number of characters in a file, Program to count number of characters in specified string in C++ C Program to count number of characters in the file Write a c program to count the number of character C Program to count no. of characters, lines, spaces & tabs, C Program to count number of characters in the file. In this program you can learn c file operations.
C++ Program To Count Number Of Alphabets In A File


Solution:
//Program to count number of alphabets in a file.
#include<fstream.h>
#include<conio.h>
#include<ctype.h>
void main()
{
clrscr();
int count=0;
char a;

ofstream ofile("file.txt");
ofile<<"abcde34fghi43jkl34m234nop2343252qrst34uvwxyz";
ofile.close();

ifstream ifile("file.txt");
while(!ifile.eof())
{
ifile.get(a);
if(isalpha(a))
count++;
}
cout<<count;
getch();
}

This C++ Program executes To Count Number Of Alphabets In A File in C++ programming.

C++ File Handling Binary files - class EMPLOYEE

Assuming the class EMPLOYEE given below, write functions in C++ to perform following:

(i) Write the objects of EMPLOYEE to a binary file.
(ii) Read the objects of EMPLOYEE from binary file and display them on screen.

Assuming the class EMPLOYEE given below, write functions in C++ to perform following:  (i) Write the objects of EMPLOYEE to a binary file. (ii) Read the objects of EMPLOYEE from binary file and display them on screen.
C++ File Handling Binary files - class EMPLOYEE 


Solution:
class EMPLOYEE
{
            int ENO;
            char ENAME[10];
            public :
            void GETIT()
            {
                        cin >> ENO;
                        gets (ENAME);
            }
            void SHOWIT()
           {
                        cout <<ENO << ENAME <<endl;
            }
};

This C++ Program executes the objects of EMPLOYEE to a binary file and Read the objects of EMPLOYEE from binary file and display them on screen.

C++ Program To Write Numbers 1 to 100 in a data file

How to write a C++ Program to write numbers one to hundred in a data file notes.txt in C++ Programming.


C++ Program to write numbers 1 to 100 in a data file notes.txt in C++ Programmin.
C++ Program to write numbers one to hundred in a data file notes.txt in C++ Programmin.


Solution:
//Program to write numbers one to hundred in a data file notes.txt
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();

ofstream ofile("notes.txt");
for(int i=1;i<=100;i++)
ofile<<i<<" ";
ofile.close();

char a;
ifstream ifile("notes.txt");
while(!ifile.eof())
{
ifile.get(a);
cout<<a;
}
getch();
}

This C++ Program to write numbers one to hundred in a data file notes.txt in C++ Programming.

C++ Initializes A String Variable And Outputs String To Disk File

How to write a C++ Program which initializes a string variable and outputs the string to the disk file in C++ programming.

C++ Program which initializes a string variable and outputs the string to the disk file in C++ programming.
C++ Program which initializes a string variable and outputs the string to the disk file in C++ programming.


Solution:
//Program which initializes a string variable and outputs the string to the disk file.
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();
char a[]="Program which initializes a string variable and outputs the string to the disk file.";

ofstream ofile("disk.txt");
ofile<<a;
ofile.close();

char b;
ifstream ifile("disk.txt");
while(!ifile.eof())
{
ifile.get(b);
cout<<b;
}
getch();
}

This C++ Program which initializes a string variable and outputs the string to the disk file in C++ programming.

Read Content From a Text File then Count and Display the Number of Alphabets

How to write a C++ Program to read content from a text file out.txt, count and display the number of alphabets present in it in C++ Programming.


C++ Program to read content from a text file out.txt, count and display the number of alphabets present in it
C++ Program to read content from a text file out.txt, count and display the number of alphabets present in it 


Soulution:
//Program to read content from a text file out.txt, count and display the number of alphabets present in it.
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();

char a;
int count=0;
ifstream ifile("out.txt");
while(!ifile.eof())
{
ifile.get(a);
if((a>=65 && a<=90)||(a>=97&&a<=122))
{
count++;
cout<<a;
}
}
cout<<endl<<"Number of aplhabets in the file out.txt: "<<count;
getch();
}

This C++ Program to read content from a text file out.txt, count and display the number of alphabets present in it in C++ Programming.

C++ Program to count number of blanks present in a text file

How to write a C++ Program to count number of blanks present in a text file in C++ Programming.

C++ Program to count number of blanks present in a text file
C++ Program to count number of blanks present in a text file


Solution:
//Program to count number of blanks present in a text file.
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();

char a;
int count=0;
ifstream ifile("out.txt");
while(!ifile.eof())
{
ifile.get(a);
if(a==32)
count++;
}
cout<<endl<<"Number of blanks in the file out.txt: "<<count;
getch();
}

This C++ Program to count number of blanks present in a text file.

Binary File Handling in C++ Examples

Binary File Handling in CPP -  Binary File Handling in C++ Examples

Binary File Handling in CPP -  Binary File Handling in C++ Examples
Binary File Handling in CPP -  Binary File Handling in C++ Examples


Soltuion:
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
class BOOK
{
int b_no;
char b_name[50];
public:
void getdetails()
{
cout<<"\n Enter book no.: ";
cin>>b_no;
cout<<"\n Enter book name: ";
gets(b_name);
}
void showdetails()
{
cout<<"\n Book no.: "<<b_no;
cout<<"\n Book name: ";
puts(b_name);
}
int return_b_no() {return b_no;}
};
void insert()
{
BOOK obj;
obj.getdetails();
ofstream ofile;
ofile.open("BOOK.DAT",ios::app|ios::binary);
ofile.write((char*)&obj,sizeof(obj));
ofile.close();
cout<<"\n Insert successful. Press any key to continue...";
getch();
}
void display()
{
BOOK obj;
ifstream ifile;
ifile.open("BOOK.DAT");
while(ifile.read((char*)&obj,sizeof(obj)))
{obj.showdetails();}
ifile.close();
cout<<"\n Press any key to continue...";
getch();
}
void search()
{
BOOK obj;
int b_no,token=0;
cout<<"\n Enter book no. to be searched: ";
cin>>b_no;
ifstream ifile;
ifile.open("BOOK.DAT");
while(ifile.read((char*)&obj,sizeof(obj)))
{
if(obj.return_b_no()==b_no)
{
cout<<"\n Record found!";
token=1;
obj.showdetails();
}
}
ifile.close();
if(token==0)
cout<<"\n Record not found.";
cout<<"\n Press any key to continue...";
getch();
}
void count()
{
BOOK obj;
int count=0;
ifstream ifile;
ifile.open("BOOK.DAT");
while(ifile.read((char*)&obj,sizeof(obj)))
count++;
ifile.close();
cout<<"\n Number of records in the file: "<<count;
cout<<"\n Press any key to continue...";
getch();
}
void modify()
{
BOOK obj;
int b_no,token=0;
int pos ;
cout<<"\n Enter book no. to be modified: ";
cin>>b_no;
fstream file;
file.open("BOOK.DAT",ios::binary|ios::in|ios::out);
while(file.read((char*)&obj,sizeof(obj)))
{
pos=-1*sizeof(obj) ;
if(obj.return_b_no()==b_no)
{
token=1;
obj.showdetails();
cout<<"\n Modify:\n";
file.seekg(pos,ios::cur);
obj.getdetails();
file.write((char*)&obj,sizeof(obj));
cout<<"\n Modify successful!";
}
}
if(token==0)
cout<<"\n Record not found.";
cout<<"\n Press any key to continue...";
file.close();
getch();
}
void main()
{
while(1)
{
clrscr();
cout<<"\n\t\tMain Menu:-";
cout<<"\n\n\t1.Insert";
cout<<"\n\t2.Dispay";
cout<<"\n\t3.Search";
cout<<"\n\t4.Count";
cout<<"\n\t5.Modify";
cout<<"\n\t6.Exit";
cout<<"\n\n\tEnter choice: ";
int choice;
cin>>choice;
switch(choice)
{
case 1:
insert();
break;

case 2:
display();
break;

case 3:
search();
break;

case 4:
count();
break;

case 5:
modify();
break;

case 6:
exit(0);
}
}
}
This Binary File Handling in C++ Examples.

C++ Program to count number of words in a text file

How to write Program to count number of words in a text file in C++ Programming.


C++ Program to count number of words in a text file
C++ Program to count number of words in a text file


Solution:
//Program to count number of words in a text file.
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();

char a[80];
int count=0;
ifstream ifile("out.txt");
while(!ifile.eof())
{
ifile>>a;
count++;
}
cout<<endl<<"Number of words in the file out.txt: "<<count;
getch();
}

.This C++ Program to count number of words in a text file

C++ Program to Counting Words "the" in a Text File

How to write Program to count number of times the word 'the' as an independant word in a text file in C++ Programming.

Program to count number of times the word 'the' as an independant word in a text file in C++ Programming.
C++ Program to Counting Words "the" in a Text File

Solution:
//Program to count number of times the word 'the' as an independant word in a text file.
//out.txt:-"The C++ is a the general purpose the programmingthe language."
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
void main()
{
clrscr();

char a[80];
int count=0;
ifstream ifile("out.txt");
while(!ifile.eof())
{
ifile>>a;
if((strcmp(a,"the")==0)||(strcmp(a,"The")==0));
count++;
}
cout<<endl<<"Number of 'the' in the file out.txt: "<<count;
getch();
}

This C++ Program to count number of times the word 'the' as an independant word in a text file.

C++ Program to Count Lines Starting Alphabet 'A' in text file

How to write a Program to count number of lines not starting with the alphabet 'A' in a text file in C++Programming.


C Program to Find the Number of Lines not starting with the alphabet 'A' in a text file in C++Programming.C Programming Examples on File Handling. How do I count the number of words in a text file using C++.C++ counting the number of lines in a text file
Program to count number of lines not starting with the alphabet 'A' in a text file in C++Programming.

Solution:
//Program to count number of lines not starting with the alphabet 'A' in a text file.
/*out.txt:-
*/

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
void main()
{
clrscr();

char a[80];
int count=0;
ifstream ifile("out.txt");
while(!ifile.eof())
{
ifile.getline(a,80);
if(a[0]!='A')
count++;
}
cout<<endl<<"Number of lines not starting with 'A' in the file out.txt: "<<count;
getch();
}

This C++ Program to count number of lines not starting with the alphabet 'A' in a text file.

C++ Program to Print lower-case vowels in second.txt from first.txt

How to write a Program that reads a file first.txt and creates a new file second.txt which contains only those words from first.txt which starts from lower-case vowels.

How to write a Program that reads a file first.txt and creates a new file second.txt which contains only those words from first.txt which starts from lower-case vowels.
C++ Data File Handling Program


Solution:
//Program that reads a file first.txt and creates a new file second.txt which contains only those words from first.txt which starts from lower-case vowels.
/*first.txt:-
*/

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<ctype.h>
void main()
{
clrscr();

char a[80];
ifstream ifile("first.txt");

ofstream ofile("second.txt");

while(!ifile.eof())
{
ifile>>a;
if((a[0]=='a')||(a[0]=='e')||(a[0]=='i')||(a[0]=='o')||(a[0]=='u'))
ofile<<a;
}
getch();
}

What is a File ?

• A file is a stream of bytes stored on some secondary storage devices.
Text file: A text file stores information in readable and printable form. Each line of text is
terminated with an EOL End of Line cha racter.
Binary file: A binary file contains information in the non-readable form i.e. in the same
format in which it is held in memory

There are three file I/O classes used for file read / write operations.

  1. ifstream - can be used for read operations.
  2. ofstream - can be used for write operations.
  3. fstream - can be used for both read & write operations.
fstream.h:
• This header file includes the definitions for the stream classes ifstream, ofstream and
fstream. In C++ file input output facilities implemented through fstream.h header file.
• It contain predefines set of operation for handling file related input and output, fstream
class ties a file to the program for input and output operation.
• A file can be opened using:
o By the constructor method. This will use default streams for file input or output.
This method is preferred when file is opened in input or output mode only.
Example : ofstream file“student.dat”); or ifstream file“student.dat”);
o By the open member function of the stream. It will preferred when file is
opened in various modes i.e ios::in, ios::out, ios::app, ios::ate etc.
e.g fstream file;
file.open “book.dat”, ios::in | ios::out | ios::binary);
File modes:
• ios::out It open file in output mode i.e write mode and place the file
pointer in beginning, if file already exist it will overwrite the file.
• ios::in It open file in input moderead mode and permit reading from the file.
• ios::app It open the file in write mode, and place file pointer at the end of file i.e to
add new contents and retains previous contents. If file does not
exist it will create a new file.
• ios::ate It open the file in write or read mode, and place file pointer at the end of
file i.e input/ output operations can performed anywhere in the file.
• ios::trunc It truncates the existing file (empties the file.
• ios::nocreate If file does not exist this file mode ensures that no file is
created and open fails.
• ios::noreplace If file does not exist, a new file gets created but if the file
already exists, the open( fails.
• ios::binary Opens a file in binary mode.

This Progarm reads a file first.txt and creates a new file second.txt which contains only those words from first.txt which starts from lower-case vowels.

C++ Menu driven program to Insert(), Display(), Delete() in a linked queue.

How to Write a menu driven program to Insert(), Display(), Delete() in a linked queue. (C++ Programming)


Each node of a Queue contains the following information, in addition to required pointer field:
1. Ticket No.
2. Passenger Name

How to Write a menu driven program to Insert(), Display(), Delete() in a linked queue. (C++ Programming)   Each node of a Queue contains the following information, in addition to required pointer field: 1. Ticket No. 2. Passenger Name
C++ Menu driven program to Insert(), Display(), Delete() in a linked queue.

/*
Write a menu driven program to Insert(), Display(), Delete() in a linked queue.
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
struct node
{
int t_no;
char p_name[50];
node *link;
};

node *temp=NULL;
node *front=NULL;
node *rear=NULL;

void insert()
{
clrscr();
temp=new node;
cout<<"\n Enter ticket no.: ";
cin>>temp->t_no;
cout<<" Enter passenger name: ";
gets(temp->p_name);
temp->link=NULL;
if(front==NULL)
{
front=temp;
rear=temp;
}
else
{
rear->link=temp;
rear=temp;
}
cout<<"\n Insert Successful!";
cout<<"\n Press any key to continue...";
getch();
}
void display()
{
clrscr();
if(front==NULL)
cout<<"\n The queue is empty!";
else

{
temp=front;
while(temp!=NULL)
{
cout<<"\n Ticket no.: "<<temp->t_no;
cout<<"\n Passenger name: ";
puts(temp->p_name);
temp=temp->link;
}
}
cout<<"\n Press any key to continue...";
getch();
}
void delete_node()
{
clrscr();
if(front==NULL)
cout<<"\n The queue is empty!";
else
{
temp=front;
front=front->link;
cout<<"\n Deleted the following record: ";
cout<<"\n Ticket no.: "<<temp->t_no;
cout<<"\n Passenger name: ";
puts(temp->p_name);
delete temp;
}
cout<<"\n Press any key to continue...";
getch();
}
void main()
{
clrscr();
int choice;
while(1)
{
clrscr();
cout<<"\n\t\t\tMain Menu\n\t1.Insert\n\t2.Display\n\t3.Delete\n\t4.Exit";
cout<<"\n Enter your choice: ";
cin>>choice;
switch(choice)
{
case 1:
insert();
break;

case 2:
display();
break;

case 3:
delete_node();
break;

case 4:
exit(0);
}
}
}

This C++ Menu driven Program to Insert(), Display(), Delete() in a linked queue.