Saturday, August 30, 2014

Password Security in C++

One of the basic protection that we can apply in our computer is the use of password. In this article I will show you a sample program that I wrote before a simple password security program in C++. What this program will do is to ask the user to enter the correct password as you run the program, every time the user type the password it display asterisk character to hide the real password underneath it protects the user from anyone who looks in their screen while they are typing for this password to access their system.

I hope you will find my work useful in your quest in learning C++ as your programming language.

Thank you very much.


Sample Screen Shoot of Our Program

Program Listing

#include <iostream>
#include <conio.h>

using namespace std;

void start();

void start()
{
    char ch;
     string password;
       system("cls");
       cout << "\n\n";
       cout << "\t\t ===== SIMPLE PASSWORD VALIDATION =====";
       cout << "\n\n";
       cout << "\t Created By: Mr. Jake Rodriguez Pomperada, MAED-IT";
      cout << "\n\n\n\n";
      cout << "Enter Your Password ==> ";

         while ((ch=getch()) != 13) {
              cout << "*";
               password+=ch;
         }

         if (password == "123") {
             cout << "\n\n\n";
             cout << "\t\t\t Password is Right Access is Granted !!!";
             cout << "\n\n\n";
             system("pause");
         }
       else {
             cout << "\n\n\n";
             cout << "\t\t\t Password is Invalid Access is Denied !!!";
             cout << "\n\n\n";
             system("pause");
             start();
    }
 }


int main() {
    start();
}



Lower Case To Upper Case Conversion in C++

This program that I wrote will show you how to convert lowercase words in a given sentence into uppercase equivalent using C++ as my programming language. The C++ library file that I used to convert lowercase into uppercase is #include <cctype> this library file has a built in function called toupper() that enables the programmer to convert lowercase characters into uppercase characters. I hope you will find my work useful and beneficial in your learning how to program in C++.

Thank you very much.



Sample Output of Our Program

Program Listing

#include <iostream>
#include <cctype>
#include <string>

int main()
{
    using namespace std;
    string str;

   cout << " Lower Case To Upper Case String Conversion 1.0";
   cout << "\n\n";
   cout << "Enter a String : ";
   getline(cin,str);
    for (size_t i = 0; i < str.length(); ++i)
    {
        str[i]=toupper(str[i]);
    }

    cout << "\n";
    cout<<"\n Converted Results in Upper Case : "  <<str << ".";
    for (size_t i = 0; i < str.length(); ++i)
    {
        str[i]=tolower(str[i]);
    }

    cout<<"\n Converted Results in Lower Case : "  <<str << ".";
    cout << "\n\n";
    system("PAUSE");
}


Vowel Omitter in C++

In this article I would like to share with you a sample program that I wrote a long time ago in my class in C++ programming I called this program Vowel Omitter. What this program will do is to ask the user to enter a sentence and then the program will remove or omit all the vowels that can be found in the words in the given sentence. I used this program to show my students in my class that C++ has many features that are suitable in string manipulation not just solving numbers.

If you have some questions about my work please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

Thank you very much.


Sample Output of Our Program

Program Listing

#include <iostream>

 using namespace std;

int x=0,j=0, y=0,vow=0;
int countedw(char str[150]);

main()
{

char str[150];

cout << "\n\n \t VOWEL OMITTER ";
cout << "\n\n  Created By: Mr. Jake R. Pomperada, MAED-IT";
cout << "\n\n";
cout << "Type a Sentence :=> ";
gets(str);
cout << "\n\n";
cout <<"\nOriginal Words: " <<str ;

cout<< "\n\nRemaining letters: ";
countedw(str);


cout <<"\n\nTotal No. of Omitted Vowels:  " <<vow;
cout << "\n\n";
system("pause");

}


int countedw(char str[150])

{
char tmp,tmp1;
y=strlen(str);
for(x=0; x<=y; x++)
{

tmp=str[x];

  if (tmp!='a'&&tmp!='A'&&tmp!='e'&&tmp!='E'&&tmp!='i'&&tmp!='E'&&tmp!='o'&&tmp!='O'&&tmp!='u'&&tmp!='U' )
  {
   tmp1=tmp;

  cout << tmp1;

  }else{
  vow++;
     }
   }
}

DOWNLOAD FILE HERE

Wednesday, August 6, 2014

Positive and Negative Numbers Counter in C++

One of the basic programming problems that I have developed for my C++ programming class here in the Philippines is to count the number of positive and negative numbers being given by the user of our program. My intention of creating this program is to introduce my students in my programming class how to understand and learn how to use one dimensional array as their data structure to display the positive and negative numbers in our program.

Normally arrays is one of the simplest data structure in my own opinion that can be learned easy by apply person interested in computer programming. We can define array as a list of values that has the same data type and having the same variable name also. It is very easy to manage data if we are using arrays because we are only dealing with one variable name but we can identify different values in our array by its index or elements that we access in our program. 

If order for us to determine if the number is positive is by having using this condition in our program  if (numbers[y] >=0) this condition tells us the if number[x] is greater the zero then it will display all positive numbers in our program. In our case I consider zero as positive number in our example. For checking for negative numbers and display the values of our screen I am using this condition if (numbers[y] < 0) this condition implies that if the given numbers by our user is less that zero then the values to be displayed will be negative numbers.

I hope you will find my sample program beneficial and useful in your learning how to use arrays as your data structure in your C++ program. If you have some questions about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much.


Sample Output of Our Program

Program Listing

#include <iostream>

using namespace std;

main()
{
    int numbers[5];
    cout << "\n\n";
    cout << "\t Positive and Negative Numbers Counter";
    cout << "\n\n";
    for (int x=0; x<5; x++) {
        cout << "Enter item no." << x+1 <<  ": ";
        cin >> numbers[x];
     }
 cout << "\n\n";
 cout << "Positive Numbers";
 cout << "\n";
  for (int y=0; y<5; y++) {
    if (numbers[y] >=0) {
        cout << " " << numbers[y] << "";
    }
  }
  cout << "\n\n";
  cout << "Negative Numbers";
 cout << "\n";
  for (int z=0; z<5; z++) {
    if (numbers[z] <0) {
        cout << " " << numbers[z] << "";
    }
  }
 cout << "\n\n";
 cout << "\t Thank You For Using This Software.";
 cout << "\n\n";
}