Friday 10 October 2014

C++ Left Lower Pattern Staric Traingle nested loop program

void main()

{

int size=3;
cin>>size;
int margin_space;
int row=size;
while(row>=0)
{
margin_space = size - row;
int col = 0;
while(col<margin_space)
{
cout<<" ";
col = col+1;
}
int starics = row;
while(starics>=0)
{
cout<<"X";
starics--;
}
cout<<endl;
row--;
}

}



output:-



c++ print left triangle upper portion

void main()
{
int size=3;
        cout<<"please enter the size of triangle to print";
cin>>size;
int margin_space;
int row=1;
while(row<=size)
{
margin_space = size - row;
int col = 0;
while(col<margin_space)
{
cout<<" ";
col = col+1;
}
int starics = 1;
while(starics<=row)
{
cout<<"X";
starics++;
}
cout<<endl;
row++;
}
}


output:-




C++ check entered string if repeated same character in string again "Taaseep" then show output it as "tasep" program





void main()
{
   string a = "azzfghk";

int i=0;
while(i<a.length())
{
if(a[i]==a[i+1])
{
cout<<a[i];
i=i+2;
}
else
{
cout<<a[i];
i++;
}
}
}