wap to print the following pattern.





#include<stdio.h>
void main()
{
int i,j,k,a=1,b=1,n;
printf("enter the number of rows");
scanf("%d",&n);
for(i=n;i>=1;i--)
 {
   {
    for(j=1;j<=i-1;j++)
    printf("  ");
    for(k=1;k<=b;k++)
    if((k&1)==0)
    printf("  ");
    else
    printf("%c ",'a');
    }

  b=b+2;
  printf("\n");
  }
}

NOTE-  i have compiled this program in codeblocks if u do it in turbo c++  use  conio.h  header file in the beginning  and getch()  a the  last

wap to print the following pattern....























#include<stdio.h>
void main()
{
int i,c=1,a=1,n;
printf("enter the no of rows");
scanf("%d",&n);
for(i=1;i<=n;i++)
{

if((i&1)==0)
   {
    for(c=1;c<=i;c++)
    if((c&1)==0)
    printf("%d ",1);
    else
    printf("%d ",0);

    }
else
    {
    for(a=1;a<=i;a++)
    if((a&1)==0)
    printf("%d ",0);
    else
    printf("%d ",1);

    }
printf("\n");
}

}

wap to print the following pattern.

                                     






















#include<stdio.h>
void main()
{
int i,j,n,a=1,k,m,b=1;
printf("enter the no. of rows");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
 {
 for(j=1;j<=i-1;j++)
 printf("  ");
 for(k=b;k<=a;k++)
 printf("%d ",k);
 for(m=a-1;m>=b;m--)
 printf("%d ",m);
 }
 printf("\n");
 a=a+2;
 b=b+1;
 }
}



NOTE-  i have compiled this program in codeblocks if u do it in turbo c++  use  conio.h  header file in the beginning  and getch()  a the  last

wap to print the sum of the following series.

(2^2)+(2^2+2^4)+(2^2+2^4+2^6)+...........n terms.




#include<stdio.h>
void main()
{
int i,j,sum,seriesum=0,p,n;
printf("enter the number");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
 p=2,sum=0;
for(j=1;j<=i;j++)
{
 sum=sum+pow(2,p);
 p=p+2;
}
seriesum=seriesum+sum;
}
printf("%d",seriesum);
}


NOTE-  i have compiled this program in codeblocks if u do it in turbo c++  use  conio.h  header file in the beginning  and getch()  a the  last

wap to delete all vowels from a sentence and print the sentence without vowels.




#include<stdio.h>
void main()
{
char sen[1000],sen2[100];
int i,a,count=0,j=0;
gets(sen);
a=strlen(sen);
for(i=0;sen[i]!='\0';i++)
{
 if(sen[i]=='a'||sen[i]=='e'||sen[i]=='i'||sen[i]=='o'||sen[i]=='u')
        count++;
        else
    {
    sen2[j]=sen[i];
    j++;

    }
    }

printf("%d\n%d",i,a);
printf("\n%s",sen2);
}


NOTE-  i have compiled this program in codeblocks if u do it in turbo c++  use  conio.h  header file in the beginning  and getch()  a the  last

wap that reads string from the keyboard and determine whether string is a palindrome or not.




#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
char string[50],reverse[50];
int i;
printf("enter the string\t");
gets(string);
strcpy(reverse,string);
strrev(reverse);
i=stricmp(reverse,string);
if(i==0)
printf("the string entered is a palindrome");
else
printf("the enterted string is not a palindrome.");
getch();
}

wap to implement binary search.


#include<stdio.h>
int binarysearch(int list[],int low,int high,int key);
void main()
{
int list[20],num,i,key,low,high,index;
printf("enter the number of elements(max 20)\t");
scanf("%d",&num);
printf("enter the elements in ascending order");
for(i=0;i<num;i++)
scanf("%d",&list[i]);
printf("enter the key that u want to search");
scanf("%d",&key);
index=binarysearch(list,0,num-1,key);
if (index==-1)
printf("does not exist in the list");
else
printf("exists at the location %d",index+1);
}
int binarysearch(int list[],int low,int high,int key)
{
int mid;
if(low==high)
{
if(list[low]==key)
return low;
else
return -1;
}
else
{
mid=(low+high)/2;
if(list[mid]==key)
return mid;
else if(list[mid]>key)
return binarysearch(list,low,mid-1,key);
else
return binarysearch(list,mid+1,high,key);
}
}

NOTE-  i have compiled this program in codeblocks if u do it in turbo c++  use  conio.h  header file in the beginning  and getch()  a the  last


Implemet Stack in python

  class Stack : def __init__ ( self , data ): self . stack = [] if ( data ): self . stack . append ( da...