Ask a Teacher



A program to print int this format &&&&&&& &&&& && &

#include<iostream.h>
#include<conio.h>
void main()
{
    int i=0,j=7,k=0;
    for(i=j;i>0;i=j/2)
    {
        for(k=0;k<i;k++)
        {
              cout<<"&";
         }
          cout<<"  ";
         if(k%2!=0 && k!=1)
            j=k+1;
         else
             j=k;
     }
  getch();
}



comments powered by Disqus