Pattern Series | Interview Code

#include<iostream>

using namespace std;

int main()
{
    int no;
    cin>>no;
    for(auto i=0; i<no; i++)
    {
        for(auto j=i;j<no;j++)
        {
            cout<<"*";
        }
        for(auto j=0;j<i;j++)
        {
            cout<<' ';
        }
        for(auto j=0;j<i;j++)
        {
            cout<<' ';
        }
        for(auto j=i;j<no;j++)
        {
            cout<<"*";
        }
        cout<<"\n";
    }
    return 0;
}
Output will appear here
Featured

Pattern series | Interview Code

#include<iostream>

using namespace std;

int main()
{
    int no;
    cin>>no;
    for(auto i=0; i<no; i++)
    {
        for(auto j=0;j<i;j++)
        {
            cout<<"*";
        }
        for(auto j=i;j<no-1;j++)
        {
            cout<<' ';
        }
        for(auto j=i;j<no-1;j++)
        {
            cout<<' ';
        }
        for(auto j=0;j<i;j++)
        {
            cout<<"*";
        }
        cout<<"\n";
    }
    return 0;
}
Output will appear here..
Featured

Pattern Series | Interview Code

#include<iostream>
using namespace std;

int main()
{
    int no;
    cin>>no;
    for(auto i = 0; i<no; i++)
    {
        for(auto j = 0; j<i; j++)
        {
            cout<<" ";
        }
        for(auto j = i; j<no; j++)
        {
            cout<<"*";
        }
        cout<<"\n";
    }
    for(auto i = 0; i<no; i++)
    {
        for(auto j = i; j<no-1; j++)
        {
            cout<<" ";
        }
        for(auto j = 0; j<=i; j++)
        {
            cout<<"*";
        }
        cout<<"\n";
    }
    return 0;
}
Output will appear here
Featured

Adding new Rows to DataGridView on Button Click in C# | CodeWithC# | window based product

learn more about DataGridView.

here we are going to add new rows after every button click. so for that we need to create a function which holds columns and rows which holds data in DataGridView.

Hyper Links contains information from docs.microsoft.com

private void button1_Click(object sender, EventArgs e)
        {
            addRow(textBox1.Text.ToString(),Convert.ToInt32(textBox2.Text));
        }
private void addRow(string name,int roll)
        {
            dataGridView1.Columns.Add("Name","Name");
            dataGridView1.Columns.Add("Roll", "Roll");

            object[] data = { name, roll };
            dataGridView1.Rows.Add(data);
        }
above image contains data which is added to gridView on Add to list Button Click

Check out new one Here: AutoCompleteTextBox with C#

Auto Complete TextBox in C# with DataBase Values | CodeWith C# | Window Based Product

Featured

before copy paste code make sure that, you have used using System.Data.SqlClient; in your code

it is also important to connect data base to your application.

below code is for SQL DataBase

Hyper Links contains information from docs.microsoft.com

void autocomplete_txt()
        {
            textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
            textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
            AutoCompleteStringCollection coll_obj = new AutoCompleteStringCollection();

            SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\USERS\ANIKET\DOCUMENTS\JERRYINDIA.MDF;Integrated Security=True;Connect Timeout=30");
            conn.Open();
            SqlCommand cmd = new SqlCommand("select * from bazaar", conn);

            SqlDataReader reader = cmd.ExecuteReader();


            //this is for product name
            int itemCodeOrdinal = reader.GetOrdinal("product_name");
            while(reader.Read())
            {
                string prd_nm = reader.GetString(itemCodeOrdinal);
                coll_obj.Add(prd_nm);
            }

            textBox1.AutoCompleteCustomSource = coll_obj;

            
        }
in above image we can see that when we enter ‘wh’ it shows suggestion from DataBase values

Multi Threading in Java | Circle Moving Java Code | Simple to Understand |

Featured
import java.awt.*;
import java.util.*;
import javax.swing.*;

public class ANImation  extends JFrame implements Runnable
{ 
	int x,y,stepx,stepy,width,end;
	int x1,y1;
	int x2,y2;
	Thread t1=new Thread(this); 
	ANImation() 
	{ 
		//blue circle
		x=100;
		y=50;
		//red circle
		x1=100;
		y1=50;
		//orange circle
		x2=100;
		y2=50;
		
		width=20;
		end=500;
		stepy=2;
		stepx=2;
		setTitle("Visit here:- JerryIndia.home.blog");
		setSize(800,500);
		setLayout(null);
		setVisible(true);
		t1.start();
	}
	public void paint(Graphics g)
	{
		super.paint(g);
		g.setColor(Color.BLUE);
		g.fillOval(x,y,width,width);
		g.setColor(Color.RED);
		g.fillOval(x1,y1,width,width);
		g.setColor(Color.ORANGE);
		g.fillOval(x2,y2,width,width);
	}

	public void run()
	{
		while (true) 
		{
			x+=stepx;
			y+=0;

			x1+=0;
			y1+=stepy;

			x2+=stepx;
			y2+=stepy;

			if(x<=100 || x>=end-width)
			{
				stepx*=-1;
				stepy*=-1;
			}
			repaint();

			try
			{
				t1.sleep(10);
			}
			catch(Exception e)
			{
				JOptionPane.showMessageDialog(null,"e");
			}
		}
	}

	public static void main(String[] args) 
	{
		ANImation JerryIndia=new ANImation();
		
	}
}
Featured

Socket Programs for client and server in Python

//for client machine
import socket

s=socket.socket()
#portno=13(daytime)||7(eco server)||17(chargen)
port=12345
s.connect(('127.0.0.1',port))
#s.sendall('hello') only for echo
print s.recv(1024)

	
s.close
//for server machine
import socket
s=socket.socket()
print 'connection is established....'
port=1234
s.bind(('',port))

s.listen(5)
print("server is listening")
while True:
	c, addr=s.accept()
	print "accespted connection from ",addr
	c.send("hiii from server....")
	c.close

Problem solving code in C++ | HackerRank | Birthday-Bar Code |

https://www.hackerrank.com/challenges/the-birthday-bar/problem
//coded by:- aniketkoli183@gmail.com
//for more codes visit here:- https://jerryindia.home.blog/


#include<iostream>
using namespace std;

int main()
{
	int size;
	cin>>size;
	int *arr=new int[size-1];
	
	for(int i=0;i<size;i++)
	{
		cin>>arr[i];	
	}
	long int day,month,total=0,count=0;
	cin>>day;
	cin>>month;
	
	for(int i=0;i<size;i++)
	{
		
		
		for(int j=i;j<i+month;j++)
		{
						
			total+=arr[j];						
		}
		
		
		if(total==day)
		{
			count++;
			total=0;
		}	
		if(total!=day)
		{			
			total=0;
		}
	}
	
	
	cout<<count;
	return 0;
}
Sample Output

Data Structure Program 1 | Array | simple array | array using pointers

//by:- aniketkoli183@gmail.com
//for more codes visit here:- http://jerryindia.home.blog

#include<iostream>

using namespace std;


int main()
{
	//simple array
	int arr[5];
	cout<<"Enter data into first array:= ";
	for(int i=0;i<5;i++)
	{
		cin>>arr[i];
	}
	cout<<"Entered data into first array:= ";
	for(int i=0;i<5;i++)
	{
		cout<<arr[i]<<"\n";
	}
	
	
	//array creation with the help of pointers pointer
	int size;
	int *arr1=new int[size];
	cout<<"\nhow much size you need for an array2:=";
	cin>>size;
	
	for(int i=0;i<size;i++)
	{
		cin>>arr1[i];
	}
	cout<<"\nEntered data into second array:= ";
	for(int i=0;i<size;i++)
	{
		cout<<arr1[i]<<"\n";
	}
	return 0;
}