Student Report Card Project : c++

Here is how we all can create a software based on C++ without a GUI. Graphic will be generated through <graphic.h> and <windows.h> but all we need is an algorithm and logic to impplement it. How we store data, how we create record and how we manipulate them.

Even With this program you can get the logic to create it, with all extra functions.

We try to implement every single phenomena which will help you to understand the logic.

Continue reading

How To Convert A String (Containing Number Followed By Spaces ) Into Integer Array : C++

Have you ever think of converting a string ( containing numbers followed by space ) into integer array.
For that we need to learn : How to convert single char into integer in C++.
A smaller Logic and Everything become easy : Read Article to search beyond this.
Query By- Ruchir Gupta

Continue reading

STACKS (USING TEMPLATES AND EXCEPTION H.)

We have posted a program on stacks operation which is done by normal class and function methood. Here is the generic function to make it more useful with different types of data. Go through Program ->

#include"conio.h"
#include"iostream"
using namespace std;
template<class t>
class stack
{
    private:
        t sta[50];
        int siz;
    public:
        stack()
        {
            siz=0;
        }
        t push();
        t pop();
        t display();
        
};
template<class t>
t stack<t>::push() // push fuction
{
    t num;
    if(siz==4)
    {
        cout<<"\nStack is already full.";
        return 0;
    }
    else
    {
        cout<<"\nEnter element : ";
        cin>>num;
        sta[siz]=num;
        siz++;
    }
    return 0;
}
template<class t>
t stack<t>::pop() //pop function;
{
    t num1;
    if(siz==0)
    {
        cout<<"\nStack is empty.";
        return 0;
    }
    else
    {
        num1=sta[siz-1];
        cout<<"\nElement popped : "<<num1;
        siz--;
    }
    return num1;
}
//c#ode studio appreciates this program;
template<class t>
t stack<t>::display() //display function;
{
    int i,j;
    if(siz==0)
    {
        cout<<"\nStack is empty.";
        return 0;
    }
    else 
    {
        for(i=siz-1,j=0;i>=0;i--,j++)
        {
            cout<<"\nELEMENT <"<<j<<"> IS : "<<sta[i];
        }
    }
}
int main()
{
    int choice=0;
    cout<<"\nNEED OPERATION WITH INTEGERS OR FLOAT( 1:INTEGER , 2:FLOAT ) : ";
    cin>>choice;
    try
    {
        if(choice==1)
        {
            stack <int> obj;
            int a;
            cout<<"\n_________STACK FUNCTIONS_________ "<<endl;
            int option=1;
            while(option)
            {
                cout<<"\n1:PUSH \n2:POP \n3:DISPLAY ";
                cout<<"\nEnter Choice : ";
                cin>>a;
                switch(a)
                {
                    case 1:
                        obj.push();
                        break;
                    case 2:
                        obj.pop();
                        break;
                    case 3:
                        obj.display();
                        break;
                    default:
                        cout<<"\nEnter correct choice... 404 ERROR <CHOICE NOT FOUND>";
                        return 0;
                }
                cout<<"\n1: Continue, 0:Exit :: ";
                cin>>option;
            }
        }
        else
            if(choice==2)
            {
                stack <float> obj;
                int a;
                cout<<"\n_________STACK FUNCTIONS_________ "<<endl;
                int option=1;
                while(option)
                {
                    cout<<"\n1:PUSH \n2:POP \n3:DISPLAY ";
                    cout<<"\nEnter Choice : ";
                    cin>>a;
                    switch(a)
                    {
                        case 1:
                            obj.push();
                            break;
                        case 2:
                            obj.pop();
                            break;
                        case 3:
                            obj.display();
                            break;
                        default:
                            cout<<"\nERROR 404-CHOICE DOESN'T EXISTS....TERMINATING PROGRAM";
                            return 0;
                    }
                    cout<<"\n1: Continue, 0:Exit :: ";
                    cin>>option;
                }
            }
            else
                throw choice;
    }
    catch(int x)
    {
        cout<<"\n\nERROR 404-CHOICE "<<x<<" DOESN'T EXISTS....TERMINATING PROGRAM";
    }
    cout<<"\n\nPROGRAMMING @ C#ODE STUDIO";
    getch();
    return 0;
}


STACK_EXP

Finding Roots Using Exception Handling

Question – WAP TO FIND THE ROOT OF AN EXPRESSION AS ” ax² + bx +c = 0″ ;

Answer –

#include"conio.h"
#include"iostream"
#include"math.h"
using namespace std;
int main()
{
    try
    {
        float a,b,c,d,root1,root2;
        cout<<"\nEnter 3 Coeff : "<<endl;
        cout<<"\nEnter A: ";
        cin>>a;
        cout<<"\nEnter B: ";
        cin>>b;
        cout<<"\nEnter C: ";
        cin>>c;
        if(a==0)
        {
            if(b==0)
            {
                throw b;
            }
            else
            {
                d=-c/b;
                cout<<"\n";
                cout<<"\nSolution will be :"<<d;
            }
        }
        else
        {
            d=b*b-4*a*c;
            if(d==0)
            {
                root1=(-b)/(2*a);
                root2=root1;
                cout<<"\nBoth the roots will be same : "<<root1<<" & "<<root2;
            }
            else
            {
                root1=(-b+sqrt(d))/(2*a);
                root2=(-b-sqrt(d))/(2*a);
                cout<<"\nRoot 1 : "<<root1<<"\t Root 2 : "<<root2;
            }
        }
    }
    catch(float x)
    {
        cout<<"\nBOTH THE VALUES CANT BE ZERO IN 'a*x^2 + b*x + c = 0 ";
    }
    cout<<"\n\nPROGRAMMING @ C#ODE STUDIO";
    getch();
    return 0;
}

roots


					

Armstrong Number:

By: Vinay Kumar
College : LPU

Question : WAP to check whether number is armstrong number or not ;

Armstrong number= suppose 153 = cube(1) + cube (5) + cube(3) = 1+125+27 =153

#include"conio.h"
#include"iostream"
#include"math.h"
using namespace std;
int main()
{
    int a,b,sum=0,num;
    cout<<"\nEnter Number : ";
    cin>>num;
    a=num;
    while(a!=0)
    {
        b=a%10;
        sum+=b*b*b;
        a/=10;
    }
    if(sum==num)
    {
        cout<<"\nARMSTRONG NUMBER ";
    }
    else
    {
        cout<<"\nNOT AN ARMSTRONG NUMBER";
    }
    cout<<"\nPROGRAMMING @ C#ODE STUDIO";
    getch();
}

ARMS

Complex Number : Operations

By: Arun GuptaCollege : LPU

Question  : Perform addition, subtraction and multiplication operation on complex number using operator overloading ;

Answer:

#include"conio.h"
#include"iostream"
using namespace std;
class complex
{
    float real,img;
    public:
        void agn(float x, float y)
        {
            real=x;
            img=y;
        }
         void disp()
        {
            if(img>=0)
                cout<<real<<" + "<<img<<" i ";
            else
                cout<<real<<img<<" i ";
        }
        complex operator +(complex oj)
        {
            complex obj;
            obj.real=real+oj.real;
            obj.img=img+oj.img;
            return obj;
        }
        complex operator -(complex oj)
        {
            complex obj;
            obj.real=real - oj.real;
            obj.img=img - oj.img;
            return obj;
        }
        complex operator *(complex oj)
        {
            complex obj;
            obj.real=real*oj.real;
            obj.img=img*oj.img;
            return obj;
        }
};
int main()
{
    float x,y,a,b;
    int choice;
    complex obj1,obj2,obj3;
    cout<<"\nInput Value For 1st Complex No. :";
    cout<<"\nReal : ";
    cin>>x;
    cout<<"\nImaginary : ";
    cin>>y;
    cout<<"\nInput Value For 2nd Complex No. :";
    cout<<"\nReal : ";
    cin>>a;
    cout<<"\nImaginary : ";
    cin>>b;
    obj1.agn(x,y);
    obj2.agn(a,b);
    cout<<"\nValues Are : ";
    cout<<"\nFor 1st Complex No. :";
    obj1.disp();
    cout<<"\nFor 2nd Complex No. :";
    obj2.disp();
    cout<<"\n\nMenu : ";
    cout<<"\n\t1:ADDITION \n\t2:SUBTRACTION \n\t3:MULTIPLICATION \n\t0:EXIT";
    cout<<"\nMake Choice : ";
    cin>>choice;
    switch(choice)
    {
        case 0:
            cout<<"\nEXITING. . . .";
            break;
        case 1:
            obj3=obj1+obj2;
            cout<<"\nAnswer Will Be : ";
            obj3.disp();
            break;
        case 2:
            obj3=obj1-obj2;
            cout<<"\nAnswer Will Be : ";
            obj3.disp();
            break;
        case 3:
            obj3=obj1*obj2;
            cout<<"\nAnswer Will Be : ";
            obj3.disp();
            break;
        default:
            cout<<"\nWrong Choice has been made : Exiting . . .";
    }
    cout<<"\nProgramming @ c#ode studio";
    getch();
    return 0;
}

Addition :                                                                                    Multiplication:

complex complex2

 

Stack Operations;

Name: Rahul
Email: rahultiwari.uk@gmail.com
Question: Write a genetic class to implement stack with array as data member and implement push and pop operation with member function.
College: LPU

We can perform two operation with stack;

Push – To put an element at vacant position without violation of stack rule;
Pop- We can throw a element from a position which is at top most i.e. STACK RULE;

STACK

#include"conio.h"
#include"iostream"
using namespace std;
class stack
{
    private:
        int sta[50];
        int siz;
    public:
        stack()
        {
            siz=0;
        }
        int push();
        int pop();
        int display();

};
int stack::push() // push fuction
{
    int num;
    if(siz==4)
    {
        cout<<"\nStack is already full.";
        return 0;
    }
    else
    {
        cout<<"\nEnter element : ";
        cin>>num;
        sta[siz]=num;
        siz++;
    }
    return 0;
}
int stack::pop() //pop function;
{
    int num1;
    if(siz==0)
    {
        cout<<"\nStack is empty.";
        return 0;
    }
    else
    {
        num1=sta[siz-1];
        cout<<"\nElement popped : "<<num1;
        siz--;
    }
    return num1;
}
//c#ode studio appreciates this program;
int stack::display() //display function;
{
    int i,j;
    if(siz==0)
    {
        cout<<"\nStack is empty.";
        return 0;
    }
    else 
    {
        for(i=siz-1,j=0;i>=0;i--,j++)
        {
            cout<<"\nELEMENT <"<<j<<"> IS : "<<sta[i];
        }
    }
}
int main()
{
    stack obj;
    int a;
    cout<<"\n_________STACK FUNCTIONS_________ "<<endl;
    int option=1;
    while(option)
    {
        cout<<"\n1:PUSH \n2:POP \n3:DISPLAY ";
        cout<<"\nEnter Choice : ";
        cin>>a;
        switch(a)
        {
            case 1:
                obj.push();
                break;
            case 2:
                obj.pop();
                break;
            case 3:
                obj.display();
                break;
            default:
                cout<<"\nEnter correct choice... 404 ERROR <CHOICE NOT FOUND>";
                return 0;
        }
        cout<<"\n1: Continue, 0:Exit :: ";
        cin>>option;
    }
    cout<<"\nPROGRAMMING @ C#ODE STUDIO";
    getch();
    return 0;
}

stack_push_pop