Pages

Sunday, 21 October 2018

Knowing Ourselves: Only way to Success

SWOT Analysis - An Elixir to Professional Life

Wondering sometimes in the times of difficulty the thought that crosses everyone's mind at least once "What am I doing? What my life should be? What do I want? What is the purpose of my life?" are the most important and basic questions asked and if answered, make one above all.
Knowing ourselves, knowing our self worth are the keys to find the answers to these questions. You know, in science "To find the result you have to observe and to observe you have to perform". So there are many experimental methods that can be performed, one of them and my recommendation is SWOT analysis.

What is SWOT Analysis?

SWOT analysis (or SWOT matrix) is a strategic planning technique used to help a person or organization identify Strengths, Weaknesses, Opportunities, and Threats related to business competition or project planning.

That's just the scientific definition for an organisation to run it's business but this analysis can be used for an individual to know himself also. One's business can also be helped using this.

It is intended to specify the objectives of the business venture or project and identify the internal and external factors that are favorable and unfavorable to achieving those objectives. Users of a SWOT analysis often ask and answer questions to generate meaningful information for each category to make the tool useful and identify their competitive advantage. SWOT has been described as the tried-and-true tool of strategic analysis.
Strengths and weakness are frequently internally-related, while opportunities and threats commonly focus on the external environment. The name is an initialism for the four parameters the technique examines:
  • Strengths: characteristics of the business or project that give it an advantage over others.
  • Weaknesses: characteristics of the business that place the business or project at a disadvantage relative to others.
  • Opportunities: elements in the environment that the business or project could exploit to its advantage.
  • Threats: elements in the environment that could cause trouble for the business or project.
The degree to which the internal environment of the firm matches with the external environment is expressed by the concept of strategic fit. Identification of SWOTs is important because they can inform later steps in planning to achieve the objective. First, you should consider whether the objective is attainable, given the SWOTs. If the objective is not attainable, they must select a different objective and repeat the process. But here the objective will be attainable.
  • Strengths are made sharp.
  • Weaknesses are overcome.
  • Opportunities are taken from environment for personal development.
  • Threats are dealed with wiseness.


Have a paper and print this:

Ponder over the things and take as much time as you want but make it complete work done.
Now you know what to do....

Saturday, 31 March 2018

Inverse of a Matrix using Gauss Jordan Method in C/C++

PROGRAM :

/*To write a C/C++ program to find the inverse of a matrix using Gauss Jordan Method.*/

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

using namespace std;

int main()
{
    int i, j, k, n;
    float a[10][10] = { 0 }, d;
    cout << "No of rows ";
    cin >> n;
    cout << "\nEnter the elements of the matrix row-wise:\n";
    for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++)
            cin >> a[i][j];

    for (i = 1; i <= n; i++)
        for (j = 1; j <= 2 * n; j++)
            if (j == (i + n))
                a[i][j] = 1;

    for (i = n; i > 1; i--)
    {
        if (a[i - 1][1] < a[i][1])
            for (j = 1; j <= n * 2; j++)
            {
                d = a[i][j];
                a[i][j] = a[i - 1][j];
                a[i - 1][j] = d;
            }
    }
    cout << "pivoted output: " << endl;
    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= n * 2; j++)
            cout << a[i][j] << "    ";
        cout << endl;
    }

    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= n * 2; j++)
            if (j != i)
            {
                d = a[j][i] / a[i][i];
                for (k = 1; k <= n * 2; k++)
                    a[j][k] -= a[i][k] * d;
            }
    }
    for (i = 1; i <= n; i++)
    {
        d = a[i][i];
        for (j = 1; j <= n * 2; j++)
            a[i][j] = a[i][j] / d;
    }

    cout <<"\nInverse of the matrix is as follows :\n";
    for (i = 1; i <= n; i++)
    {
        for (j = n + 1; j <= n * 2; j++)
            cout << a[i][j] << "    ";
        cout << endl;
    }
    return 0;
}



OUTPUT :

No of rows 3

Enter the elements of the matrix row-wise:
 2    2    3
 2    1    1
 1    3    5

pivoted output:
 2    2    3    1    0    0
 2    1    1    0    1    0
 1    3    5    0    0    1

Inverse of the matrix is as follows :
 2    -1    -1
-9     7     4
 5    -4    -2

Gauss Jordan Method in C/C++

PROGRAM :

/*To write a C/C++ program to find the solution of
the system of linear equations using Gauss Jordan
Method.*/

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,i,j,k;
    cout<<"\nEnter the no. of equations\n";        
    cin>>n;
    double a[n][n+1],x[n];
    cout<<"\nEnter the elements of the augmented-matrix row-wise:\n";
    for (i=0;i<n;i++)
        for (j=0;j<=n;j++)    
            cin>>a[i][j];
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n+1; j++)
            if (j != i)
            {
                double d = a[j][i] / a[i][i];
                for (k = 0; k < n+1; k++)
                    a[j][k] -= a[i][k] * d;
            }
    }
    cout<<"\n\nThe matrix after gauss-jordan elimination is as follows:\n";
    for (i=0;i<n;i++)
    {
        for (j=0;j<=n;j++)
            printf("%4f\t",a[i][j]);
printf("\n");
    }
    for(i=1;i<n;i++)
    {
    for (j=0;j<i;j++)
    {
    a[i][j]=0;
}
}
    for (i=n-1;i>=0;i--)
    {
x[i]=a[i][n];
for (j=i+1;j<n;j++)
            if (j!=i)
x[i]=x[i]-a[i][j]*x[j];
        x[i]=x[i]/a[i][i];
    }
    
    cout<<"\nThe values of the variables are as follows:\n";
    
    for (i=0;i<n;i++){
        cout<<(x[i])<<endl;
}
    return 0;
}



OUTPUT :

Enter the no. of equations
4

Enter the elements of the augmented-matrix row-wise:
10 -7 3 5 6
-6 8 -1 -4 5
3 1 4 11 2
5 -9 -2 4 7


The matrix after gauss-jordan elimination is as follows:
10.000000    0.000000    0.000000    0.000000    50.000000
0.000000     3.800000    0.000000    0.000000    15.200000
0.000000     0.000000    2.447368    0.000000   -17.131579
0.000000     0.000000    0.000000    9.924731     9.924731

The values of the variables are as follows:
5
4
-7
1

Gauss Elimination Method in C/C++

PROGRAM :

/*To write a C/C++ program to find the solution of
the system of linear equations using Gauss Elimination
Method.*/

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,i,j,k;
    cout<<"\nEnter the no. of equations\n";        
    cin>>n;
    float a[n][n+1],x[n];
    cout<<"\nEnter the elements of the augmented-matrix row-wise:\n";
    for (i=0;i<n;i++)
        for (j=0;j<=n;j++)    
            cin>>a[i][j];
    for (i=0;i<n-1;i++){
        for (k=i+1;k<n;k++)
            {
                double t=a[k][i]/a[i][i];
                for (j=0;j<=n;j++)
                    a[k][j]=a[k][j]-t*a[i][j];
            }
}
    cout<<"\n\nThe matrix after gauss-elimination is as follows:\n";
    for (i=0;i<n;i++)
    {
        for (j=0;j<=n;j++)
            printf("%4f\t",a[i][j]);
printf("\n");
    }
    for(i=1;i<n;i++)
    {
    for (j=0;j<i;j++)
    {
    a[i][j]=0;
}
}
    for (i=n-1;i>=0;i--)
    {
x[i]=a[i][n];
for (j=i+1;j<n;j++)
            if (j!=i)
x[i]=x[i]-a[i][j]*x[j];
        x[i]=x[i]/a[i][i];
    }
    
    cout<<"\nThe values of the variables are as follows:\n";
    
    for (i=0;i<n;i++){
    if (i==n-1)
    cout<<floor(x[i])<<endl;
    else 
        cout<<round(x[i])<<endl;
}
    return 0;

}


OUTPUT :

Enter the no. of equations
4

Enter the elements of the augmented-matrix row-wise:
10 -7 3 5 6
-6 8 -1 -4 5
3 1 4 11 2
5 -9 -2 4 7


The matrix after gauss-elimination is as follows:
10.000000   -7.000000    3.000000    5.000000    6.000000
0.000000     3.800000    0.800000   -1.000000    8.600000
-0.000000   -0.000000    2.447368   10.315789   -6.815791
0.000000    -0.000000   -0.000000    9.924731    9.924732

The values of the variables are as follows:
5
4
-7
1

Newton Raphson Method in C/C++

PROGRAM :

/*To write a C/C++ program to find roots of an equation using 
Newton Raphson method.*/

#include<iostream>
#include<cmath>
using namespace std;
float a,b,err,x1,x2,x0;
int maxitr,i=1,flag=0;
float f(float x){
return x*log10(x)-1.2;}
float df(float x){
return log10(x)+0.43429;}
int main(){
cout<<"Enter value of a and b :";
cin>>a>>b;
if(f(a)*f(b)>0)
cout<<"No Root or Even Root";
else{
cout<<"Enter maximum iteration and allowed error :";
cin>>maxitr>>err;
x0=(a+b)/2;
while(maxitr>0){
x1=x0;
x2=x1-(f(x1)/df(x1));
cout<<"After "<<i<<" iteration value of x ="<<x2<<"\n";
if(fabs(x1-x2)<err){
cout<<"After "<<i<<" iteration value of x is"<<x2<<"\n";
flag=1;
break;
}
x0=x2;
i++;
maxitr--;
}
if(flag==0)
cout<<"maximum iteration is insufficient";}
return 0;

}


OUTPUT :

Enter value of a and b :5 1
Enter maximum iteration and allowed error :25
0.0001
After 1 iteration value of x = 2.74615
After 2 iteration value of x = 2.74065
After 3 iteration value of x = 2.74065

After 3 iteration value of x is 2.74065

Regula-Falsi Method in C/C++

PROGRAM :

//To write a C/C++ program to find roots of an equation using
//Regula-Falsi method.

#include<stdio.h>
#include<math.h>
float bisect(float a,float b);
float f(float x);
float f(float x)
{
float f;
f=cos(x)-x*exp(x);
return f;
}
float bisect(float a,float b)
{
float c=((b*f(a))-(a*f(b)))/(f(a)-f(b));
return c;
}
void main()
{
float a,b,x0,ae,x1;
int itr,maxitr;
printf("Enter a & b :");
scanf("%f%f",&a,&b);
if (f(a)*f(b)<0)
{
printf("Enter the no. of iterations required and Allowed error");
scanf("%d%f",&maxitr,&ae);
x0=bisect(a,b);
printf("Iteration no. 0 value of x is %f\n",x0);
for(itr=1;itr<=maxitr;itr++)
{
if (f(x0)*f(a)<0)
b=x0;
else a=x0;
x1=bisect(a,b);
printf("Iteration no. %d value of x is %f\n",itr,x1);
if ((fabs(x1-x0))<=ae)
{
printf("root is %f",x1);
break;
}
x0=x1;
}
if (itr==maxitr && fabs(x1-x0)>ae)
printf("Number of iterations is not sufficient");
}


}


OUTPUT :

Enter a & b :0 1
Enter the no. of iterations required and Allowed error25
0.0001

Iteration no. 0 value of x is 0.314665
Iteration no. 1 value of x is 0.446728
Iteration no. 2 value of x is 0.494015
Iteration no. 3 value of x is 0.509946
Iteration no. 4 value of x is 0.515201
Iteration no. 5 value of x is 0.516922
Iteration no. 6 value of x is 0.517485
Iteration no. 7 value of x is 0.517668
Iteration no. 8 value of x is 0.517728

root is 0.517728

Bisection Method in C/C++

PROGRAM :

//To write a C/C++ program to find roots of a polynomial using
//bisection method.


#include<stdio.h>
#include<math.h>
float bisect(float a,float b);
float f(float x);
float f(float x)
{
float f;
f=pow(x,3)-4*x-9;
return f;
}
float bisect(float a,float b)
{
float c=(a+b)/2;
return c;
}
void main()
{
float a,b,x0,ae,x1;
int itr,maxitr;
printf("Enter a & b :");
scanf("%f%f",&a,&b);
if (f(a)*f(b)<0)
{
printf("Enter the no. of iterations required and Allowed error");
scanf("%d%f",&maxitr,&ae);
x0=bisect(a,b);
printf("Iteration no. 0 value of x is %f\n",x0);
for(itr=1;itr<=maxitr;itr++)
{
if (f(x0)*f(a)<0)
b=x0;
else a=x0;
x1=bisect(a,b);
printf("Iteration no. %d value of x is %f\n",itr,x1);
if ((fabs(x1-x0))<=ae)
{
printf("root is %f",x1);
break;
}
x0=x1;
}
if (itr==maxitr && fabs(x1-x0)>ae)
printf("Number of iterations is not sufficient");
}

}




OUTPUT :

Enter a & b :2 3
Enter the no. of iterations required and Allowed error25
0.00001
Iteration no. 0 value of x is 2.500000
Iteration no. 1 value of x is 2.750000
Iteration no. 2 value of x is 2.625000
Iteration no. 3 value of x is 2.687500
Iteration no. 4 value of x is 2.718750
Iteration no. 5 value of x is 2.703125
Iteration no. 6 value of x is 2.710938
Iteration no. 7 value of x is 2.707031
Iteration no. 8 value of x is 2.705078
Iteration no. 9 value of x is 2.706055
Iteration no. 10 value of x is 2.706543
Iteration no. 11 value of x is 2.706299
Iteration no. 12 value of x is 2.706421
Iteration no. 13 value of x is 2.706482
Iteration no. 14 value of x is 2.706512
Iteration no. 15 value of x is 2.706528
Iteration no. 16 value of x is 2.706535

root is 2.706535