Friday, November 24, 2017

Code Review: Horoscope System

Compiler or Tool: Turbo C

Programming Language: C++

User Interface Type: CUI [Character User Interface]

Description:

This Horoscope System is nothing but automating simple enquiry process at Astrologer. Even though the system is very small it teaches how to code simple system of RAM type [i.e., not file handling support system] in C++ language.

The system has include dependency graph as follows:

clip_image001

The main() function presents main menu and becomes single point entry and exit code. The main() function call graph is as follows:

clip_image002

The menu presented by this main() function is as follows:

clip_image004 

The system is good example for how to generate a good idea/code with already existing task. It uses only two functions. It is open for adding more features and facilities within it.

Total code lines for this system are 413 lines [approximately]. It is a most suitably called as mini project in C++ language.

If you want to write or construct or program C++ mini-project and do not know how or from where to start buy this simple e-book: Code Review of 26 C++ mini-projects.

Note: For other details send request e-mail to mailforprojects@rediffmail.com. Add your comments in below available comment box.

 

Note: Click these label/tags to view all related posts. Tags: C++MiniProject

 

…till next post, bye-bye & take care.

Thursday, November 23, 2017

C++ Code Review: Using Operator overload to compare two strings for equality.

Description: This program uses operator overload to compare two strings for equality.

Code:

//Compiling Tool: Code::Block IDE with MinGW

//Program compares two strings & tells whether equal or not.

 

#include<iostream>

#include<stdio.h> //used for gets()

#include<string.h> //used for strcmp()

 

using namespace std;

 

class String

{

    char str[20];

public:

    void

    getdata()  //function to read the string

    {

        gets(str);

    }

 

    //operator fun:overload comparison operator for compare two strings

 

    int operator

    ==(String s)

    {

        if(!strcmp(str,s.str))

            return 1;

        return 0;

    }

};

 

int main()

{

    String s1,s2;

 

    cout<<"Enter first string:";

    s1.getdata();

 

    cout<<"Enter second string:";

    s2.getdata();

 

    if(s1==s2) //here the operator function will be called

    {

        cout<<"Strings are Equal";

    }

    else

    {

       cout<<"Strings are Not Equal";

    }

 

    return(0);

}       

 

Output:

 clip_image002

If you want to write or construct or program C++ mini-project and do not know how or from where to start buy this simple e-book: Code Review of 26 C++ mini-projects. For book sample click this link.

Add your comments in below available comment box.

Note: Click these label/tags to view all related posts. Tags: C++Code

 

…till next post, bye-bye & take care.

Tuesday, November 21, 2017

C++ Code Review: Using pointer to compare two strings for equality.

Description: This program uses pointer to compare two strings for equality.

Code:

//Compiling Tool: Code::Block IDE with MinGW

//Program uses pointer to compare two strings for equality.

 

#include<iostream>

#include<conio.h> //for getch()

#include<cstdlib> //for system()

#include<stdio.h>

 

using namespace std;

int main()

{

 

    system("cls");//to clear the screen

 

    char str1[50],str2[50];

    int str_cmp(char*,char*);

 

    cout<<"Enter first string:";

    gets(str1);

    cout<<"Enter second string:";

    gets(str2);

 

    if(str_cmp(str1,str2))

        cout<<"Strings are equal";

    else

        cout<<"Strings are not equal";

 

    return 0;

}

 

 

int str_cmp(char *s1,char *s2)

{

    while(*s1==*s2)

    {

        if(*s1==' '||*s2==' ')

            break;

 

 

        s1++;

        s2++;

    }

 

 

    if(*s1==' '&&*s2==' ')

        return 1;

 

 

    return 0;

}       

 

Output:

clip_image002

If you want to write or construct or program C++ mini-project and do not know how or from where to start buy this simple e-book: Code Review of 26 C++ mini-projects. For book sample click this link.

Add your comments in below available comment box.

Note: Click these label/tags to view all related posts. Tags: C++Code

 

…till next post, bye-bye & take care.