Tuesday, December 28, 2021

single link list in cpp | oop in c++ single link list operations in cpp data structure | ds


#include<iostream>
#include<string.h>
#include<string>
using namespace std;
class node{
    public:
        int roll_no;
        string name;
        node *next;
};
class std_list{
    private:
        node *start,*current,*temp;
    public:
        std_list(void){
            start=NULL;
        }
        void insert(int,string);
        void insert_end(int,string);
        void delete_end();
        void count();
        void search(int);
        void display();
};

void std_list::delete_end(){
    node *previous;
    if(start==NULL){
        cout<<"List is empty"<<endl;
        return;
    }
    else
    {
        current=start;
        while (current->next!=NULL)
        {
            previous=current;
            current=current->next;
        }
        cout<<"Data of last student is "<<current->name<<endl;
        previous->next=NULL;
        delete current;
        cout<<"Data of last Student is Deleted"<<endl;
    }
}

void std_list::insert_end(int rn,string name){
    temp=new node;
    temp->name=name;
    temp->roll_no=rn;
    temp->next=NULL;
    if(start==NULL){
        start=temp;
    }
    else{
        current=start;
        while (current->next!=NULL)
        {
            current=current->next;
        }
    }
    current->next=temp;
   
}

void std_list::insert(int rn,string nm){
    temp=new node;
    temp->roll_no=rn;
    temp->name=nm;
    temp->next=NULL;
    if(start==NULL){
        start=temp;
    }
    else
    {
        current=start;
        while (current->next!=NULL)
        {
            current=current->next;
        }
        current->next=temp;
       
    }
}
// end of insert function

void std_list::display(){
    if(start==NULL){
        cout<<"List is empty";
        return;
    }
    else{
        int rec=1;
        current=start;
        while (current!=NULL)
        {
            cout<<"Student record of #"<<rec<<endl;
            cout<<"Name: "<<current->name<<endl;
            cout<<"Roll: "<<current->roll_no<<endl;
            current=current->next;
            rec++;
        }
       
    }

} //end of display function

void std_list::count(){
    node *temp;
    current=start;
    int n=0;
    while (current!=NULL)
    {
        n++;
        current=current->next;
    }
    cout<<"Student in this is school is "<<n<<endl;
   
} //end of count function

void std_list::search(int rn){
    node *temp;
    int f=0;
    current=start;
    while (current!=NULL)
    {
        if(current->roll_no==rn){
            f=1;
        }
        current=current->next;
    }

    if(f==1){
        cout<<"Student with the roll #"<<rn<<" is Exist in the school"<<endl;
    }
    else{
        cout<<"No Student with the roll #"<<rn<<endl;
    }
   
}
int main()
{
    std_list obj;
    // insert data
    obj.insert(14,"Zoha");
    obj.insert(11,"Zoha");

    // insert data at end
    obj.insert_end(22,"Zoha Ali");

    // dispaly data
    obj.display();
    // coutn data  
    obj.count();  
    // search data
    obj.search(22);
    // delete data at the end
    obj.delete_end();
    return 0;
}

Saturday, July 10, 2021

Deque in c++

 


#include <iostream>
using namespace std;
class deque{
    private:
        int F,B,DQ[5];
    public:
        deque()
        {
            F=-1;
            B=-1;
        }
        void insert_front(int);
        void insert_back(int);
        void del_front(void);
        void del_back(void);
        void print_deque(void);
};
int main()
{
    deque obj;
    int val,opt;
    while (true)
    {
        cout<<"1: insert in the front of deque"<<endl;
        cout<<"2: insert in the back of deque"<<endl;
        cout<<"3: Delete in the front of deque"<<endl;
        cout<<"4: Delete in the back of deque"<<endl;
        cout<<"5: Exit Programm"<<endl;
        cin>>opt;
        switch (opt)
        {
        case 1:
            cout<<"Enter value for insertion"<<endl;
            cin>>val;
            obj.insert_front(val);
            obj.print_deque();
            break;
        case 2:
            cout<<"Enter value for insertion"<<endl;
            cin>>val;
            obj.insert_back(val);
            obj.print_deque();
            break;
        case 3:
            obj.del_front();
            obj.print_deque();
            break;
        case 4:
            obj.del_back();
            obj.print_deque();
            break;
        case 5:
            exit(0);
            break;
        
        default:
            cout<<"invalid input"<<endl;
            break;
        }
    }
    return 0;
}

void deque::insert_front(int n){
    if(F==0 && B==4){
        cout<<"Queue is full"<<endl;
        return;
    }
    if(F==-1 && B==-1){
        F=B=0;
        DQ[F]=n;
    }
    else if(F>0){
        F--;
        DQ[F]=n;
    }
    else{
        cout<<"There is no space in front side"<<endl;
    }
}
void deque::insert_back(int n){
    if(F==0 && B==4){
        cout<<"Queue is full"<<endl;
        return;
    }
    if(F==-1 && B==-1)
    {
        F=B=0;
        DQ[B]=n;
    }
    else if(B<4){
        B++;
        DQ[B]=n;
    }
    else{
        cout<<"There is no space in back side"<<endl;
    }
}
void deque::del_front(){
    if(F==-1 && B==-1)
    {
        cout<<"Queue is empty"<<endl;
        return;
    }
    else{
        DQ[F]=NULL;
    }
    if(F==B)
    {
        F=B=-1;
    }
    else if(F==4){
        F--;
    }
    else{
        F++;
    }
}
void deque::del_back(){
    if(F==-1 && B==-1){
        cout<<"Queue is empty"<<endl;
        return;
    }
    else{
        DQ[B]=NULL;
    }
    if(F==B){
        F=B=-1;
    }
    else{
        B--;
    }
}
void deque::print_deque(){
    cout<<"Deque after operations"<<endl;
    if(F==-1){
        cout<<"Queue is empty"<<endl;
        return;
    }
    for(int i=F;i<=B;i++){
        cout<<DQ[i]<<"\t";
    }
    cout<<endl;
}

Monday, May 24, 2021

get current date of system in c++ cpp

 #include<iostream>

#include<ctime>
using namespace std;
int main()
{
    time_t now=time(0);
    cout<<"now is :"<<now<<endl;
    chardate_time=ctime (&now);
    cout<<date_time;
    
    return 0;
}


get student data and display on the screen by using oop



#include<iostream>
#include<string>
using namespace std;
class student
{
private:
    string fname;
    string name;
    int s1,s2,s3;
    int avg,sum;
public:
     void getData()
     {
         cout<<"Enter name of student:";getline(cin,name);
         cout<<"Enter marks of subject 1:";cin>>s1;
         cout<<"Enter marks of subject 2:";cin>>s2;
         cout<<"Enter marks of subject 3:";cin>>s3;
         sum=s1+s2+s3;
         avg=sum/3;
     }
     void showData()
     {
         cout<<"*********Result of students************"<<endl;
         cout<<"Name of student :"<<name<<endl;
         cout<<"Subject 1 Marks :"<<s1<<endl;
         cout<<"Subject 2 Marks :"<<s2<<endl;
         cout<<"Subject 3 Marks :"<<s3<<endl;
         cout<<"Total Obtained Marks :"<<sum<<endl;
         cout<<"Averages Marks of student :"<<avg<<endl;

     }
};

 

int main()
{
    student std1;
    std1.getData();
    std1.showData();
    
    return 0;

} 

Sunday, May 16, 2021

Friend function in c++ | Friend fuctions class in c++

 


#include<iostream>
using namespace std;
class c2;

class c1{
    int val1;
    friend void exchange(c1 &,c2 &);
    public:
        void inData(int a)
        {
            val1=a;
        }
        void display(){
            cout<<"The value of c1 is "<<val1<<endl;
        }
};

class c2{
    int val2;
    friend void exchange(c1 &,c2 &);
    public:
        void inData(int a)
        {
            val2=a;
        }
        void display(){
            cout<<"The value of c1 is "<<val2<<endl;
        }
};

void exchange(c1 & x,c2 & y)
{
    int tem;
    tem=x.val1;
    x.val1=y.val2;
    y.val2=tem;
}

int main()
{
    c1 oc1;
    c2 oc2;
    oc1.inData(34);
    oc2.inData(88);

    cout<<"Before Exchange"<<endl;
    cout<<"c1 :";
    oc1.display();   
    cout<<"c2 :";
    oc2.display();
    cout<<endl

    exchange(oc1,oc2);

    cout<<"After Exchange"<<endl;
    cout<<"c1 :";
    oc1.display();   
    cout<<"c2 :";
    oc2.display();
    cout<<endl;   
    return 0;
}

Friday, May 14, 2021

Most Common Coding Mistakes by Beginners

 Most Common Coding Mistakes by Beginners

  1. Switching Between Multiple Languages
  2. No Roadmap
  3. Lone Wolf Programming
  4. Not Maintaining Notes
  5. Tutorial Hell
  6. Learning Without Applying
  7. Not Backing Up
  8. Leaving DSA
  9. Self Doubt
  10. Jumping into Competitive Coding
  11. Lack Of Code Formatting
  12. Not Using Comments
  13. Running Behind Multiple Platforms
  14. Not Debugging
  15. Inconsistency

1. Switching Between Multiple Languages

Switching between programming languages is one of the very common coding mistakes that a lot of people do. They try to learn many languages simultaneously. They start with C++ and then after 1 week they switch to Java or say Python then after 1 week they switch to Javascript. Sometimes beginners also try to learn 2 languages at the same. Imagine learning C++ and Python together. Learning more than one language at the same time is a very bad idea. You should avoid this mistake as a beginner. Choose one language and stick with it. Because the main goal is to learn concepts of programming.

Tips for choosing 1st programming language:

  • If you wanna go to competitive programming choose either Java or C++.
  • If you wanna make some good projects in Machine learning, NLP, or Artificial Intelligence go for Python.
  • For web development you can start with HTML then CSS and then Javascript.
  • Preparing for Placements? (Data Structures & Algorithms) go for C++ or Java.
  • For software development, you can go for Java.
  • If you don’t know what do you want to do Python is the best choice for you!

2. No Roadmap for learning Coding

Next coding mistake the beginners make is not having a proper roadmap for whatever they want to learn. This is very important to understand that if you don’t have any deadlines or schedule or plan for your whole journey of learning to code you’ll pretty much lost into the world of programming. Because see you can not learn a programming language “completely”. You should know beforehand which topics you’re going to cover and in how much time. Without any schedule or deadline, you might get stuck with one language for a long time or you might leave that language in between and switch to another one.

3. Lone Wolf Programming

Lone wolf programming means you are just learning alone. Instead, you should always try to do peer programming. Like you and your friend learning the same language together. This will be beneficial for both of you. You can discuss your doubts, share resources with each other, discuss problems, solution approaches, and so on. It will also help you to prevent procrastination because in the back of your mind you’ll always try to learn more than your friend.

4. Not Maintaining Notes

Notes are the best source for revision. Always maintain your own notes either in a notebook or on the notepad. We are humans and whatever you learn today you’ll definitely forget after 5-6 months. So, instead of again finding resources, maintain your own notes.

5. Tutorial Hell

Tutorial Hell means you’re just watching tutorials one by one without making your hands dirty (without writing code on your own). Neither you’re making notes nor you’re applying them on your own. If you don’t write the tutorial code by yourself at least once you’ll not get grip on that topic and you’ll watch that tutorial again and again. Ultimately you’ll fall into a loop of watching tutorials only aka tutorial hell.

6. Learning Without Applying

This is one of the very common mistakes that beginners make while learning to code they don’t solve problems related to that particular topic which they just learned. Suppose, If you’re learning Binary Search today then you should solve at least 4-5 problems on any coding platform like Leetcode, SPOJ, or InterviewBit. If you’re learning any language build some basic projects along with your learning. Apply your knowledge! Build something, upload it on Github, and show it to your friends!

7. Not Backing Up

Not saving their code or not maintaining any online backup of your work is one of those coding mistakes that programmers make quite often. We save our work on our local system only and forget to upload it anywhere. Just imagine if your hard disk got crashed or any other tragedy happens to your system, you’ll lose all your hard work in less than a minute! Also if you need your code somewhere else, where you don’t have your PC or laptop then what you’ll do? Write that again..? No right! So it’s really important to keep your work online for your future reference so that you can access it from anywhere. You can use GitHub to upload your serious projects and blogger to keep tutorial notes and code.

8. Leaving DSA Behind

Data Structures and Algorithm is the most important thing in your whole coding journey. You can not succeed in the world of programming leaving DSA behind. So always put your time in learning DSA and do development and practice side by side. And also don’t jump to advance data structures directly first cover basic data structures.

9. Self Doubt / Comparison

Beginners have some fear or self-doubt when they first start coding. They sort of like compare themselves with others maybe with their seniors or their own batchmates who are now reached to a particular level and you’re just starting out. So you’ll feel like they have done so much in their 1st year or 2nd year so I should also do this. So, don’t compare yourself with others instead get motivated with others. Talk to them, ask about some guidance, learn from their experience. And remember whatever you’re doing, whatever you’re learning is great! Quality is more important than quantity. Don’t go for a lot of things.

10. Jumping into Competitive Coding

Moving on to the next mistake that new programmers make is jumping into competitive coding without knowing basic concepts. So if you are going into competitive coding without knowing the basic syntax and covering basic data structures then you’re making a mistake.

11. Lack Of Code Formatting

The next mistake is lack of code formatting and ignoring the code quality. When people are just starting out with coding in general they’re like let me first learn all this stuff who’s watching my code? Why should I care about proper indentation and formatting stuff? This is a big mistake because then it becomes a habit. And then you’ll have to pay later for this. So it’s better if right from the scratch you do proper formatting and indentation of your code. Also, use relevant variable names and function names as well.

12. Not Using Comments

Comments are notes to future self. If you don’t use comments, your own code will look like an alien to you after some time. So don’t forget to put comments to describe what one piece of code does. However, it’s also important to avoid over commenting as a beginner. Use relevant, short, and sweet comments.

13. Running Behind Multiple Platforms

We have a lot of platforms for DSA practice and competitive coding. So beginners make this coding mistake that they run behind most of the platforms like Codechef, Codeforces, HackerRank, HackerEarth, Leetcode, InterviewBit, SPOJ, Topcoders, and many more. But we would suggest don’t go behind many platforms for placement preparation.

  • You can use Leetcode and InterviewBit for placement preparation.
  • Hackerrank is best for beginners for you know practicing syntax of any language.
  • Pick 1-2 platforms for contests like Codechef and Codeforces.

14. Not Debugging

The next beginner coding mistake is that they do not debug their program. Debugging your program is really important. Most beginners don’t really know about debugging. So, learn about how to debug your code, debugging pointers (it allows you to see the flow of your program), and so on. All these things are really helpful in logic building and improving problem-solving skills.

15. Inconsistency

Practicing should never stop. You should not stop solving coding problems. If you stop coding for a long time and then come back to problem-solving you’ll take some time to again go into that flow of approaching any problem. So, solve at least one coding problem daily avoid these coding mistakes to become a good programmer.


Thanks for reading!

If you found this article useful please support us by commenting “nice article” and don’t forget to share it with your friends

Happy Coding! ðŸ™‚

Sunday, March 21, 2021

Website desing by Eaglesoft source code

 


<!DOCTYPE html>
<html lang="en">
<head>
    <title>Welcome to Eaglesoft</title>
</head>
<body>
    
    <table  width="900px" height="100px" align="center">
        <tr>
            <td align="center" width="150px">
                <a href="index.html">
                <img src="logo.png" width="150px" height="100px">
            </a>
            </td>
            <td align="center" width="150px">
                <a href="index.html">Home</a>
            </td>
            <td align="center" width="150px">
                <a href="product.html">Products</a>
            </td>
            <td align="center" width="150px">
                <a href="outteam.html">Our Team</a>
            </td>
            <td align="center" width="150px">
                <a href="contact.html">Contact Us</a>
            </td>
            <td align="center" width="150px">
                <a href="about.html">About</a>
            </td>
        </tr>
    </table>

    <table border="1px" bgcolor="gray" width="900px" height="400px" align="center">
        <tr>
            <td align="center" width="450px">
                <h1>Best Laptop</h1>
                <h3>For Study</h3>
                <p>Shop our wide selection of laptops from top brands like Dell, Acer, HP, Apple or Asus and enjoy free shipping if you're in Pakistan. Grab the best deals today.</p>
            </td>
            <td align="center" width="450px">
                <img src="laptop.jpg" width="450px" height="300px">
            </td>
        </tr>
    </table>

    <table border="1px" width="900px" height="600px" align="center">
        <tr>
            <td align="center" width="700px" valign="top">
                <img src="laptop2.jpg" width="700px" height="250px">
                <h1>HP LAPTOPS ARE BEST IN THE WORLD</h1>
                <P>
                    Buy Hp, Acer, Lenovo, Dell, Sony Vaio Laptops With Best Laptop Prices In Pakistan From The Largest Online Store At HomeShopping.pk.Buy Hp, Acer, Lenovo, Dell, Sony Vaio Laptops With Best Laptop Prices In Pakistan From The Largest Online Store At HomeShopping.pk.Buy Hp, Acer, Lenovo, Dell, Sony Vaio Laptops With Best Laptop Prices In Pakistan From The Largest Online Store At HomeShopping.pk.Buy Hp, Acer, Lenovo, Dell, Sony Vaio Laptops With Best Laptop Prices In Pakistan From The Largest Online Store At HomeShopping.pk.Buy Hp, Acer, Lenovo, Dell, Sony Vaio Laptops With Best Laptop Prices In Pakistan From The Largest Online Store At HomeShopping.pk.
                </P>
            </td>
            <td align="center" valign="top" width="200px">

                <table border="1px" valign="top" width="187px">
                    <tr>
                        <td align="center" width="187px" bgcolor="yellow"><h1>LIKE US</h1></td>
                    </tr>
                    <tr>
                        <td align="center" width="187px">
                            <a href="https://www.facebook.com/eaglesoft.pk">Facebook</a>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" width="187px">Insagram</td>
                    </tr>
                    <tr>
                        <td align="center" width="187px">Twitter</td>
                    </tr>
                    <tr>
                        <td align="center" width="187px">Linkeding</td>
                    </tr>
                    <tr>
                        <td align="center" width="187px">youtube</td>
                    </tr>
                    <tr>
                        <td align="center" width="187px">Qura</td>
                    </tr>
                    <tr>
                        <td align="center" width="187px">Stackoverflow</td>
                    </tr>
                    <tr>
                        <td align="center" width="187px">W3school</td>
                    </tr>
                    <tr>
                        <td align="center" width="187px">Github</td>
                    </tr>
                    <tr>
                        <td align="center" width="187px">Eaglesoft</td>
                    </tr>
                    <tr>
                        <td align="center" width="187px"></td>
                    </tr>
                    <tr>
                        <td align="center" width="187px" height="112px">
                            <img src="add1.png" width="185" height="112px">
                        </td>
                    </tr>
                    <tr>
                        <td align="center" width="187px" height="112px">
                            <img src="add2.png" width="185" height="112px">
                        </td>
                    </tr>
                    
                
                </table>

            </td>
        </tr>
    </table>

    <table border="1px" bgcolor="green" width="900px" height="50px" align="center">
        <tr>
            <td align="center">Designed by Eaglesoft</td>
        </tr>
    </table>

</body>
</html>