STRING COMPARISON EXAMPLE IN CPP - PASSWORD EXAMPLE-2

//VARIOUS PATTERNS
#include<conio.h>
#include<iostream.h>
#include<string.h>
void main()
{
 int i, j, n, k;
 char pwd[]="Open",pwd2[20];
 clrscr();
 cout<<"Enter the password to run the program. : ";
 cin>>pwd2;
 if(strcmp(pwd,pwd2)==0)
 {
cout<<"Password Match...";
goto start;
 }
 else
 {
cout<<"Password Mismatched...";
goto end;
 }

 start:
 cout<<"\nEnter N : ";
 cin>>n;
 for(i=1;i<n*2;i++)
 {
   for(j=1;j<n*2;j++)
   {
     if(i==j || i==1 || j==1 || i==(n*2)-1 || j==(n*2)-1 || j==(n*2)-i)
       cout<<"*";
     else
       cout<<".";
   }
   cout<<"\n";
 }
 end:
 getch();
}

No comments

Post your comments

Powered by Blogger.