MindTree Coding Pattern Questions | MindTree Pattern Programs

MindTree Pattern Programs with Answers

MindTree Coding Pattern Programs, MindTree Pattern Questions, MindTree Pattern Programs, MindTree Coding Pattern Questions

Program in C for MindTree Pattern

#include
int main()
{
int i,j,n,count=0,k=0;
printf(“Enter N”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)

count=k;
for(j=1;j<=i;j++)

if(i%2==0)
{
printf(“%d”,count+i);
count=count-1;
if(j!=i)printf(“*”);
k++;
}
else
{
count=count+1;
printf(“%d”,count);
if(j!=i)printf(“*”);
k++;
}
}
printf(“\n”);
}
return 0;
}

Program in Java for MindTree Pattern

import java.io.*; 
import java.net.*; 
public class Selenium_Projext { 
public static void main(String[] args){ 

PrintPat(9); 
}

public static void PrintPat(int a)
{ int last=0;
for(int i=1;i<=a;i++)
{ last=last+i;
int l=i;

for(int j=last;l>0;l–)
{

System.out.print(j–);
if(l>1)
System.out.print(“*”);

}

System.out.println();
}
}}

17 comments on “MindTree Coding Pattern Questions | MindTree Pattern Programs”


  • Mahesh

    #include

    using namespace std;

    int main()
    {
    int i,j,c=0,n;
    cin>>n;
    for(i=1;i<=n;i++)
    {
    if(i%2!=0)
    {
    for(j=1;j<=i;j++)
    {
    c++;
    if(j<i)
    {
    cout<<c<<"$";
    }
    else
    {
    cout<<c;
    }
    }
    cout<<endl;
    }
    else
    {
    c+=i;
    for(j=1;j<=i;j++)
    {
    if(j<i)
    {
    cout<<c<<"$";
    }
    else
    {
    c–;
    cout<<c;
    }
    }
    c++;
    cout<<endl;
    }
    }
    return 0;
    }


  • 3.ABHISHEK

    Python3 Code
    n=int(input(“Enter the no. N”))
    k=1
    for i in range(1,n):
    st=””
    for j in range(1,i+1):
    if i%2==0:
    t=str(k)
    st=t+”*”+st
    k+=1
    else:
    t=str(k)
    st=st+”*”+t
    k+=1
    print(st.strip(“*”))
    print(“\n”)