Showing posts with label Program to Display(). Show all posts
Showing posts with label Program to Display(). Show all posts

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++ 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.

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++ 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.