Showing posts with label C-plus-plus. Show all posts
Showing posts with label C-plus-plus. Show all posts

Sunday, 17 March 2019

even or odd number c++ || class program

even or odd number class program:

In this program find the entered number is Even number or Odd number. Which number is divisible by 2 is known as an even number, and which number is not divisible by 2 is known as an odd number.




Program:


#include<iostream>
using namespace std;
class even
{
int n,i;
public:
void read();
void print();
};
void even::read()
{
cout<<"enter the number\n";
cin>>n;
}
void even::print()
{
if(n%2==0)
{
cout<<"even number\n";
}
else
{
cout<<"odd number\n";
}
}
int main()
{
even ob1;
ob1.read();
ob1.print();
}


Output:

Click Here for Executable CPP file:









Print even numbers in c++ || using class


Print even numbers in c++:



Even numbers are the numbers which are divisible by 2 that type number is known as Even number

Remember this 2 point

for(i=0;i<n;i++)
if(i%2==0)


Program:

#include<iostream>
using namespace std;
class even
{
int n,i;
public:
void read();
void print();
}; void even::read()
{
cout<<"enter the number you want to print even number";
cin>>n;
cout<<"even number of size"<<n<<"is\n";
}
void even::print()
{
for(i=0;i<n;i++)
if(i%2==0)
cout<<i<<"\n";
} int main()
{
even ob1;
ob1.read();
ob1.print();
}

Output:

Click  Here Executable "CPP" file:





Saturday, 2 February 2019

stack program in c++ | stack meaning | program | output


stack Program in c++,


stack is  a data structure, basically stack is a linear data structure represented in real physical stack or pile.

In stack data structure insertion and deletion of the element is done only one end called as top.  The basic implementation of the stack is LIFO(Last in First Out), which means the element which are entered first is popped in the last.











Stack Program using class:





#include<iostream>
using namespace std;
#define size 5
class stack
{
int stack[size];
int tos;

public:
void temp();
void push();
int pop();
void display();
};
void stack::temp()
{
tos=0;
}
void stack::push()
{
int i;
if(tos==size)
{
cout<<"stack overflow\n";
return;
}

cout<<"enter element\n";
cin>>i;
stack[tos]=i;
tos++;
}
int stack::pop()
{
if(tos==0)
{
cout<<"stack underflow\n";
return 1;
}

tos--;
cout<<"popped element is"<<stack[tos]<<"\t";
return 0;
}
void stack::display()
{
if(tos==0)
{
cout<<"stack empty\n";
return;
}
for(int i=0;i<tos;i++)
{
cout<<stack[i]<<"\t";
}
}
int main()
{
int ch,i;
stack s;
s.temp();
while(1)
{
cout<<"\n 1.push \n 2.pop \n 3.display \n 4. exit\n";
cout<<"enter the element\n";
cin>>ch;
switch(ch)
{
case 1: s.push();
break;
case 2: s.pop();
break;
case 3: s.display();
break;
case 4: exit(0);
default:
return 0;
}
}
}









Direct Download CPP Executable file

                                                                              Download

Saturday, 26 January 2019

C++ program to implement tower of Hanoi || [PROGRAM AND ALGORITHM]



Tower of Hanoi Executable file link available...,

Tower of Hanoi is a puzzle game of mathematics, tower of Hanoi is a puzzle invented at 1883. Tower of Hanoi puzzle game consists of 3 Tower of different sizes and disk. Which can slide onto any Tower


Algorithm :

1.  Start
     Hanoi procedure(disk,source,destination,final)
2.  if disk==1 Then
     Move disk from source to destination
     Else
3.  Hanoi(disk -1,source,final,destination)
     Move disk from disk to destination
4.  Hanoi(disk-1,final,destination,source)
     END IF
     End Procedure
 




tower of Hanoi Profram:

#include<iostream>
using namespace std;

void tower(int d, char tower1, char tower2,char tower3)
{
if(d==1)
{
cout<<"shift first disk from tower\t"<<tower1<<"\tto tower"<<tower2<<"\n\n";
return;
} // if close here

tower(d-1,tower1,tower3,tower2); // recursive function call
cout<<"shift first disk from\t"<<tower1<<"\tto tower"<<tower2<<"\n";

tower(d-1,tower3,tower2,tower1);  //recursive function call
}

int main()
{
int disk;
cout<<"enter the number of disk\n\n";
cin>>disk;

if(disk<1)
cout<<"there are no disks are shifted\n\n";
else
cout<<"there are"<<disk<<"disk in tower\n\n";

tower(disk,'1','2','3');
cout<<"\n\n"<<disk<<"\tdisk in tower 1 are shifted to tower 2";
return 0;
}


Output:








Executable Cpp file


How to add and where to add executable cpp file

write a program to implement selection sort || Executable file download link

C++ PROGRAM TO IMPLEMENT STACK USING ARRAY | with executable cpp file

Program to find factorial of Number in C++ | Interesting321

C++ program to find largest of three numbers using inline function

how to install android os to your pc 

how to fix there is something wrong

Program to implement bubble sort

INSTALL G++ COMPILER TO LINUX | C++ Compiler | Full installation process with screenshot

Tuesday, 22 January 2019

C++ program to find largest of three number using inline function || Executable cpp file download link

find largest of three number

C++ program to find largest number among the three numbers using inline function is the program to find largest element of three numbers.

For Ex : 10 4 18 largest number among three is 18

program to find largest of three numbers

Program:


#include<iostream.h>
using namespace std;
inline int largest(int a, int b,int c)
{
return ((a>b)&&(a>c)?a:(b>c)?b:c);
}
int main()
{
cout<<"largest\t"<<largest(3,4,5);
return 0;
}


Output:


cpp file download link:






Saturday, 12 January 2019

How to add and where to add executable cpp file to turbo c++


Hello friends,

This article is based on How to add and where to add executable cpp file to turbo c++ 

What is cpp:
                     CPP is a source code file written in c++  program, it's a popular programming language that adds many features such as Object-Oriented programming to C.
ex: Main.cpp

How to download cpp file or How to create cpp file using the code copied from the net:

      Now  i am the new article writer(new website), i wrote only few posts, in my posts you can directly download CPP extension Executable file.
If You copied the c++ code from the net then i will tell you how to make it to CPP extension file and where i put this file.


1. Open the NOTEPAD++ and paste the code copied from the net:


   2.    Now go to the file and click on save button, or click ctrl+s, gives the file name choose "c++ source file" and save it.

    file>save>choose the save destination>file name>c++ source file
Ex: program1.cpp


3. Now your file is saved, copy(Right Click>Copy, or ctrl+c) the file from the saved location and paste it to the below location

C-Drive>TURBOC3>Bin>paste it.


4. Now open the turbo c++,  Go to File and select open file, enter the file name and click enter thats  it.



4.  Now your file is opened.


I Hope you guys are understand. if you face any problem than comment in a comment section. We need your support.

C++ PROGRAM TO IMPLEMENT STACK USING ARRAY | with executable cpp file

C++ PROGRAM TO IMPLEMENT STACK USING ARRAY | with executable cpp file direct download link.


Stack:
Stack is a linear data structure both insertion(Push) and deletion(pop) operation is made it only one end called top.

Push

Adding element to the Stack

Pop

Removing element from the stack

Display

 Display the total elements in the stack






#include <iostream>  // if you running on the turbo c++ add .h
using namespace std;   // if you use turbo c++ remove this line before compiling
int stack[100], n=100, top=-1;
void push(int val) {
   if(top>=n-1)
      cout<<"Stack Overflow"<<endl;
   else {
      top++;
      stack[top]=val;
   }
}
void pop() {
   if(top<=-1)
      cout<<"Stack Underflow"<<endl;
   else {
      cout<<"The popped element is "<< stack[top] <<endl;
      top--;
   }
}
void display() {
   if(top>=0) {
      cout<<"Stack elements are:";
      for(int i=top; i>=0; i--)
         cout<<stack[i]<<" ";
         cout<<endl;
   } else
      cout<<"Stack is empty";
}
int main() {
   int ch, val;
   cout<<"1) Push in stack"<<endl;
   cout<<"2) Pop from stack"<<endl;
   cout<<"3) Display stack"<<endl;
   cout<<"4) Exit"<<endl;
   do {
      cout<<"Enter choice: "<<endl;
      cin>>ch;
      switch(ch) {
         case 1: { 
            cout<<"Enter value to be pushed:"<<endl;
            cin>>val;
            push(val);
            break;
         }
         case 2: {
            pop();
            break;
         }
         case 3: {
            display();
            break;
         }
         case 4: {
            cout<<"Exit"<<endl;
            break;
         }
         default: {
            cout<<"Invalid Choice"<<endl;
         }
      }
   }while(ch!=4);
      return 0;
}


Output:



Executable cpp file download Link is below👇👇👇

Download





c++ program to find factorial of number

Program to find factorial of Number in C++ | Interesting321


factorial of Number in C++:

if a number is given for example 3, factorial of number 3 is 3*2*1 which means 6.




Logic of the program:

Logic of the program is very easy. the given value is assigned in a variable name
n. For loop end with 1 not a 0, it increase the element till the n number and both the
elements are multiply 1*2*3 = 6.


#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
clrscr();
int n,fact=1;
cout<<"Enter the positive numbers";
cin>>n;
for(int i=1;i<=n;i++)
{
fact=fact*i;
}
cout<<"factorial of a given number is = "<<fact;
return 0;
getch();
}


Output:



For download cpp file click below download button:

Download



Thursday, 10 January 2019

BASIC OF C PLUS PLUS PROGRAMING by interesting321

BASIC OF C(++) PLUS PLUS PROGRAMING:

It's a object orianted programing language "It was developed by Bjarne" Stroustrup at AT&T Bell Lamborateries in Murray Hill,New Jersey,USA in the early 1980's.
C++ is an extension of C with a majour addition of a class construct feature of Simula 670,

Application of c++

  • It is a versatile language,It handle very large prgram
  • It allows to create hierachy-related objects
  • It is able to map real word program properly
  • It is easily maintainable and expandable
Simple c++ program

Wite a c++ program to prints a string on the screen.

#include<iostream.h>  // it's a iclude header name not a file.
int main()    // main function
{
cout <<"it's a object orianted programing language"; // it's a print statement

return 0;
}

# Above example contains only one main() function. Usually the program execution is start at main function. every c++ program must contain main() 

Comments :
                            In c++ The comments are written in "//" (Double Slash and it is and with that line

ex:    // it is a comment line

Outpur Operator

The only one outpur statement is used in c++ that is "Cout"
Ex: Cout<<"It's a object orianted programing language";
Inside of the Quatation is display on the outpur screen
The operator "<<" is called insertion or put to operator

Header files:

<cassert> :  It Contains information for adding daignostics that aid program debugging.

<cctype>  :  It contains function prototypes for functions that test characters for certain properties.

<cfloat>   :  It cantains floating point size limits of the system.

<climits> : Contains the integral size limits of the system.

<cmath>  : Contain function prototypes for math library functions.

<iostream> : Contain function prototypes for standard input and standard output functions.

<iomanip.h> : Contain function prototypes for the stream manipulators that enable formatting of stream of data 

<fstream> : Contain functions prototypes for function that perform input from files on disk and output to files on disk.