Technocrat

  • Home

Wednesday, May 13, 2020

Automating your deployments using Ansible

 Sumit Kar     May 13, 2020     No comments   

 Since the world is moving into the DevOps model, and the industry started focusing on automation, I thought of sharing something related to automation for deployment. Server-side deployment can be automated using several tools. One of which is Ansible. Ansible is a management tool that helps to maintain the cluster of machines.

There are several configuration-management tools out there why we should go with Ansible. For that there are below reasons

  • Idempotent- Ansible’s whole architecture is structured around the concept of idempotency. The core idea here is that you only do things if they are needed and that things are repeatable without side effects.
  • Agentless - There is no software that needs to be installed on the client system. We can use ansible as long we can ssh
  • Modules - we create the new module in the ansible and add it to the ansible
  • Tiny Learning Curve- Ansible is quite easy to learn. It doesn’t require any extra knowledge. With basic Linux knowledge this can be learnt.

Ansible needs 3 files:

hosts [ Inventory file: This file can contain the list of servers. It can be a list of DNS name and IP. ]

[web]
host1.example.com
192.168.1.122
host3.example.com

[db]
host4.example.com
host5.example.com
host6.example.com

The following code can added to try this locally

[all:vars]
ansible_connection=local

ansible.cfg [ Config file ] Order of preference of confirguation file

  1. File specified by the ANSIBLE_CONFIG environment variable
  2. ./ansible.cfg (ansible.cfg in the current directory)
  3. ~/.ansible.cfg (.ansible.cfg in your home directory)
  4. /etc/ansible/ansible.cfg
[defaults]
inventory = hosts 
remote_tmp      = ~/.ansible/tmp
local_tmp       = ~/.ansible/tmp
remote_user = ubuntu 
private_key_file = ansible.pem
#vault_password_file = /path/to/vault_password_file
#executable = /bin/sh
#ask_pass        = False
host_key_checking = False 
interpreter_python = auto
[privilege_escalation]
#become = False
#become_method = sudo
#become_ask_pass = False


[persistent_connection]
#connect_timeout = 30
#command_timeout = 30

play-nginx.yml [Play file]

---
- hosts: web
  become: yes
  tasks:
    - name: ensure nginx is at the latest version
      apt: name=nginx state=latest
    - name: copy the content of the web site
      copy:
        src: index.html
        dest: /var/www/html/
    - name: start nginx
      service:
          name: nginx
          state: started

Ansible Ad-hoc command

The Ad-Hoc command is the one-liner ansible command that performs one task on the target host. It allows you to execute simple one-line task against one or group of hosts defined on the inventory file configuration.

adhoc command has the two parts List of host that you want to run the module ansible module to run

$ ansible all -m ping

The first parameter all tells we are performing the task against the all host The second parameter m tells we are going to use ping module

To Know the list of modules type the below command in the terminal

$ ansible-doc -l | more

To Find the detail of modules

$ ansible-doc <module-name>

Performing basic task using ansible command

Installing packages

Run the below command in the terminal and see the output

$ ansible testserver -m shell -a "whoami"

Run the below command in the terminal and see the output and compare with above one

$ ansible testserver -m shell -a "whoami" --become [ --become is a parameter used to become root user ]

Type the below command in the terminal to install nginx

$ ansible testserver -m apt -a 'name=nginx state=latest' --become

starting the services : Run the below command in the terminal to start the service

$ ansible -m service -a "name=nginx state=started enabled=yes" testserver --become

Run the below command in the terminal to see ths status of the ngnix

$ ansible testserver -m shell -a "service nginx status" --become

Run the below command to stop the service

$ ansible -m service -a "name=nginx state=stopped enabled=yes" testserver --become

File module

Run the below command in the terminal to find the existence of the folder $ ansible -m file -a "path=/usr/share/nginx/html state=directory" testserver --become

Copy module: Run the below command in the terminal to copy the file from host to node (Copy module take 2 parameter : Source and Destination)

$ ansible -m copy -a "src=a.txt dest=/usr/share/nginx/html/" testserver --become

Ansible setup module

The setup module is used to gather the information about the host
$ ansible testserver -m setup $ ansible testserver -m setup -a "filter=*ipv4"

Writing your first playbook

Playbooks are list of plays grouped together and plays is group of tasks and task call modules Playbooks are generally written in the yaml format Note : we can also write the playbook in the json format

To run the playbook we can simply use the ansible-playbook and followed by the playbook name

Every playbook has 2 components

  • hosts - list of host in which we want to run the task
  • task - task need to be performed

Run the below command

$ ansible-playbook <playbook-name>.yaml

To know whether the syntax of the playbook was correct we can use

$ ansible-playbook --syntax-check <playbook-name>.yaml

Ansible Roles

Roles in Ansible are next level abstraction of playbook Roles are way to organize the playbook in the efficient manner so that we can use it later. Type the below command to see the list of command of available using the ansible-galaxy

$ ansible-galaxy -h

The syntax to create the role was

$ ansible-galaxy init <role-name>

Files inside the Role

  • Default - Data about the role / application default variable eg:port no
  • files - put the static files
  • Handlers - handler are kept here
  • meta - Information about the role
  • task - Task are kept here
  • templates - Similar to files but they are dynaimic
  • vars - Same as Default it has high prority

Ansible Vault

Ansible vault to encrypt the playbook and store them safely Basic Ansible vault command

  • create
  • encrypt
  • decrypt
  • view
  • rekey

Create

Type the below command in the terminal to create the playbook

$ ansible-vault create filename.yaml

Edit

Type the below command in the terminal to edit the encrypted playbook

$ ansible-vault edit filename.yaml

View

Type the below command in the terminal to view the encrypted playbook

$ ansible-vault view filename.yaml

Rekey

Rekey is the command used to change the password

$ ansible-vault rekey filename.yaml

Encrypt

Type the below command in the terminal to encrypt the existing playbook

$ ansible-vault view filename.yaml

Decrypt

Type the below command in the terminal to de-encrypt the existing playbook

$ ansible-vault view filename.yaml

Running the encrypted playbook

Type the below command in the terminal to run the encrypted playbook $ ansible-playbook filename.yml --ask-vault-pass

Ansible is a powerful tool and this can not only be used for automating deployment. It is also used to harden Operating System and applying patch.

Try out basic ansible commands : https://github.com/karsumit94/ansible-example

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Tuesday, October 13, 2015

Find the GCD of two numbers

 Sumit Kar     October 13, 2015     DS, For Loop, Recursion     No comments   

Using For Loop
#include<stdio.h>
int main(){
int x,y,m,i;
do
{
printf("Enter two number: ");
scanf("%d%d",&x,&y);
if(x==0 || y==0)
printf("Please check the input and try again...\n");
}while(x==0 || y==0);
if(x>y)
m=y;
else
m=x;

for(i=m;i>=1;i--){
if(x%i==0&&y%i==0){
printf("\nGCD of %d and %d is %d",x,y,i) ;
break;
}
}
return 0;
}
Using Recursion
#include <stdio.h>

int gcd(int a, int b)
{

if (a == b)
return a;
if (a > b)
return gcd(a-b, b);
return gcd(a, b-a);
}

int main()
{
int x,y,m,i;
do
{
printf("Enter two number: ");
scanf("%d%d",&x,&y);
if(x==0 || y==0)
printf("Please check the input and try again...\n");
}while(x==0 || y==0);
printf("GCD of %d and %d is %d ", x, y, gcd(x, y));
return 0;
}

   

Output
Enter two number: 0 99
Please check the input and try again...
Enter two number: 99 121

GCD of 99 and 121 is 11

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Find the Factorial of a number

 Sumit Kar     October 13, 2015     For Loop, Recursion, While Loop     No comments   


Summary: Factorial is represented using '!', so five factorial will be written as (5!),n factorial as (n!).
n! = n*(n-1)*(n-2)*(n-3)...3.2.1 and zero factorial is defined as one i.e. 0! = 1.



Using While Loop
#include<stdio.h>
void main()
{
int a,f,i;
printf("Enter a number: ");
scanf("%d",&a);
f=1;
i=1;
while(i<=a)
{
f = f * i;
i++;
}
printf("\nFactorial of %d is: %d",a,f);
}


Using For Loop
#include<stdio.h>
void main()
{
int a,f,i;
printf("Enter a number: ");
scanf("%d",&a);
f=1;
for(i=1;i<=a;i++)
f = f * i;
printf("\nFactorial of %d is: %d",a,f);
}


Using Recursion
#include<stdio.h>
int fact(int);
int main(){
int num,f;

printf("\nEnter a number: ");
scanf("%d",&num);

f=fact(num);

printf("\nFactorial of %d is: %d",num,f);
return 0;
}

int fact(int n){
if(n==1)
return 1;
else
return(n*fact(n-1));
}



   
Output

Enter a number: 5

Factorial of 5 is: 120
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Solve All-Pairs Shortest Path Problem using Floyd - Warshall Algorithm

 Sumit Kar     October 13, 2015     DS, Graph     No comments   

#include<stdio.h>
#include<conio.h>
#define inf 999

void main()
{
int i,j,k,n,w[20][20];
printf("\n Enter the no. of vertices : ");
scanf("%d",&n);
printf("\n Enter the weights : ");
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
printf("w[%d][%d]= ",i,j);
scanf("%d",&w[i][j]);
if(i!=j && (w[i][j]==0))
w[i][j]=inf;
}

for(i=1;i<=n;i++)
{
printf("\n");
for(j=1;j<=n;j++)
printf("%d\t",w[i][j]);
}


for(k=1;k<=n;k++)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(w[i][k]+w[k][j]<w[i][j])
w[i][j]=w[i][k]+w[k][j];
}
}
}


printf("\n The resultant Matrix : \n");
for(i=1;i<=n;i++)
{
printf("\n");
for(j=1;j<=n;j++)
printf("%d\t",w[i][j]);
}

getch();

}

   

Output

Enter the no. of vertices : 5

Enter the weights : w[1][1]= 0
w[1][2]= 3
w[1][3]= 8
w[1][4]= 0
w[1][5]= 4
w[2][1]= 0
w[2][2]= 0
w[2][3]= 0
w[2][4]= 1
w[2][5]= 7
w[3][1]= 0
w[3][2]= 4
w[3][3]= 0
w[3][4]= 0
w[3][5]= 0
w[4][1]= 2
w[4][2]= 0
w[4][3]= 5
w[4][4]= 0
w[4][5]= 0
w[5][1]= 0
w[5][2]= 0
w[5][3]= 0
w[5][4]= 6
w[5][5]= 0

0 3 8 999 4
999 0 999 1 7
999 4 0 999 999
2 999 5 0 999
999 999 999 6 0
The resultant Matrix :

0 3 8 4 4
3 0 6 1 7
7 4 0 5 11
2 5 5 0 6
8 11 11 6 0

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Binary Search using Recursion

 Sumit Kar     October 13, 2015     DS, Recursion, Search     No comments   

#include<stdio.h>

void bins(int lb,int ub,int item,int a[]);
void main()
{
int i,n,item,a[20];
printf("Enter the size of an array: ");
scanf("%d",&n);

printf("Enter the elements of the array: " );
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}

printf("Enter the number to be search: ");
scanf("%d",&item);


bins(0,n-1,item,a);

}

void bins(int lb,int ub,int item,int a[])
{
int mid,flag=0;

if(lb<=ub)
{
mid=(lb+ub)/2;
if(item==a[mid])
{
flag=flag+1;
}
else if(item<a[mid])
{
return bins(lb,mid-1,item,a);
}
else
return bins(mid+1,ub,item,a);
}


if(flag==0)
printf("Number is not found.");
else
printf("Number is found at %d", mid+1);
}

   
Output
Enter the size of an array: 6
Enter the elements of the array: 90 95 1000 1001 1003 1006
Enter the number to be search: 95
Number is found at 2

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Wednesday, September 23, 2015

Find the maximum length of the subarray in increasing order.

 Sumit Kar     September 23, 2015     Array, Tricky     No comments   

For example we have an array {5,4,6,-2,-1,0,1,9}. The biggest sub-array in increasing order is: {-2,-1,0,1,9}. So the length is 5.

#include<stdio.h>
void main () {
int arr[8] = {5,4,6,-2,-1,0,1,9},i,arrn[8],count=1,j=0,max;
printf("The given array is: ");
for(i=0;i<8;i++)
printf(" %d" ,arr[i]); // printing the actual array - unnecessary step.
printf("\n");
for(i=0;i<7;i++){
if(arr[i]<arr[i+1])
{
count++;
}
else
{
arrn[j]=count; // adding the length of sub array
count=1;
j++;
}
}
arrn[j]=count; // adding the final length
max=arrn[0];
printf("Length of sub arrays in increasing order");
for(i=0;i<=j;i++){
if(max<arrn[i])
max=arrn[i];
printf(" %d",arrn[i]); // printing the new array - unnecessary step.
}
printf("\n Maximum Length of the substring: %d",max); // print max value
}

   
Output
The given array is: 5 4 6 -2 -1 0 1 9
Length of sub arrays in increasing order 1 2 5
Maximum Length of the substring: 5
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Spiral Matrix

 Sumit Kar     September 23, 2015     If Else, Matrix, Tricky, User Defined Function, While Loop     No comments   

#include <stdio.h>
#define R 3
#define C 3

void spiralPrint(int m, int n, int a[R][C])
{
int i, k = 0, l = 0;

/* k - starting row index
m - ending row index
l - starting column index
n - ending column index
i - iterator
*/

while (k < m && l < n)
{
/* Print the first row from the remaining rows */
for (i = l; i < n; ++i)
{
printf("%d ", a[k][i]);
}
k++;

/* Print the last column from the remaining columns */
for (i = k; i < m; ++i)
{
printf("%d ", a[i][n-1]);
}
n--;

/* Print the last row from the remaining rows */
if ( k < m)
{
for (i = n-1; i >= l; --i)
{
printf("%d ", a[m-1][i]);
}
m--;
}

/* Print the first column from the remaining columns */
if (l < n)
{
for (i = m-1; i >= k; --i)
{
printf("%d ", a[i][l]);
}
l++;
}
}
}

/* Program to test above functions */
int main()
{
int a[R][C] = { {1, 2, 3},
{8, 9, 4},
{7, 6, 5}
};

spiralPrint(R, C, a);
return 0;
}

   
Output
1 2 3 4 5 6 7 8 9
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Find the maximum occurrence of a character in a string

 Sumit Kar     September 23, 2015     Array, For Loop, If Else, Tricky     No comments   

#include<stdio.h>
#include<conio.h>

int main() {
char str[20], ch;
int count = 0, i,j=0 , max;
int arr[10];
printf("\nEnter a string : ");
scanf("%s", &str);

printf("\nEnter the character to be searched : ");
scanf("%c", &ch);
for (i = 0; str[i] != '\0'; i++) {
if (str[i] == ch)
count++;
else if(count != 0)
{
arr[j] = count;
j++;
count = 0;
}
}
arr[j]=count;
max = 0;
for(i=0;i<=j;i++)
if(max<arr[i])
max=arr[i];
if (max == 0)
printf("\nCharacter '%c'is not present", ch);
else
{
printf("\nMaximum occurrence of character '%c' : %d", ch, max);
}
return (0);
}

   

Output

Enter a string : aabbbaaab

Enter the character to be searched :
Maximum occurrence of character 'a' : 3

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Monday, August 17, 2015

Basic Structure of a C Program

 Sumit Kar     August 17, 2015     No comments   

A C program generally has the following parts:
§  Preprocessor Commands
§  Functions
§  Variables
§  Statements & Expressions
§  Comments

Let us consider a C Program:
#include<stdio.h>
void main()
{
printf("Hello, World!");
}

Preprocessor Commands: These commands tells the compiler to do some preprocessing before executing the actual compilation. For example, “#include <stdio.h>” is a preprocessor command which tells a C compiler to include stdio.h file before going to actual compilation.

Functions:  These are main building blocks of any C Program. Every C Program will at least have one function which is a mandatory function called main() function. This function is prefixed with keyword int or void or any other datatype. This defines the return type of the function. For int main() the program will return an integer value to the terminal (system).
The C Programming language provides a set of built-in functions. In the above example printf() is a C built-in function which is used to print anything on the screen.

Variables: These are used to hold numbers, strings and complex data for manipulation.

Statements & Expressions: Expressions combine variables and constants to create new values. Statements are expressions, assignments, function calls, or control flow statements which make up C programs.

Comments: are used to give additional useful information inside a C Program. All the comments will be put inside /*...*/

Note
•C is a case sensitive programming language. It means in C printf and Printf will have different meanings.
•C has a free-form line structure. End of each C statement must be marked with a semicolon.
•Multiple statements can be on the same line.
•White Spaces (ie tab space and space bar ) are ignored.
•Statements can continue over multiple lines.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Get your hands dirty

 Sumit Kar     August 17, 2015     Basic     No comments   

The only way to learn a new programming language is by writing programs in it. The first program to write is the same for all languages: Print the words hello, world!
In C, the program to print ``Hello, world!'' is
#include <stdio.h>
main()
{
printf("Hello, world!\n");
}
Just how to run this program depends on the system you are using.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Basics of C

 Sumit Kar     August 17, 2015     Basic     No comments   

What Is C?
C is a highly flexible and adaptable language. Since its creation in 1970, it's been used for a wide variety of programs including firmware for micro-controllers, operating systems, applications, and graphics programming.

When was C developed?
C was developed at Bell Laboratories in 1972 by Dennis Ritchie along with Ken Thompson. Many of its principles and ideas were taken from the earlier language B and B's earlier ancestors BCPL and CPL.

Who is the inventor of C?
Dennis Ritchie invented C, the computer-programming language that underlies Microsoft Windows, the Unix operating system and much of the other software running on computers around the world. Mr. Ritchie was a longtime research scientist at Bell Labs, originally AT&T's research division.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Monday, July 27, 2015

Accept Array elements

 Sumit Kar     July 27, 2015     Array, Basic, For Loop     No comments   

#include<stdio.h>
void main() {
int arr[10], i, j, k, size;
printf("\nEnter array size : ");
scanf("%d", &size);

printf("\nAccept Numbers : \n");
for (i = 0; i < size; i++)
{
printf("Data [%d]: ",i+1);
scanf("%d", &arr[i]);
}

printf("\nThe Array is : ");
for (i = 0; i < size; i++)
printf("%d ", arr[i]);

getch();
}

   

Output

Enter array size : 5

Accept Numbers :
Data [1]: 2
Data [2]: 6
Data [3]: 7
Data [4]: 1
Data [5]: 2

The Array is : 2 6 7 1 2

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Clear Screen without clrscr() function call

 Sumit Kar     July 27, 2015     Tricky, User Defined Function     No comments   

#include<stdio.h>
void clearmyscreen();
void main()
{
printf("Hello");
getch();
clearmyscreen();
printf("World");
getch();
}

void clearmyscreen()
{
system("cls");
}

   

Output
World

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Find Perimeter of a Circle. Take the value of the radius from user.

 Sumit Kar     July 27, 2015     Basic, Input, Macro     No comments   

#include<stdio.h>
#define pi 3.14

void main()
{
int r;
float p;
printf("Enter the value of radius: ");
scanf("%d", &r);
p=2*pi*r;
printf("Perimeter=%f",p);
}

   

Output
Enter the value of radius: 9
Perimeter=56.520000

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Use Macro to define the value of PI and Find the Perimeter of a Circle

 Sumit Kar     July 27, 2015     Basic, Macro     No comments   

#include<stdio.h>
#define pi 3.14
void main()
{
int r;
r=7;
printf("Perimeter=%f",2*pi*r);
}

   

Output
Perimeter=43.960000

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Saturday, July 25, 2015

Print Pattern 5 

 Sumit Kar     July 25, 2015     Basic, For Loop, Pattern     No comments   

#include <stdio.h>
void main()
{
int i, j, k;
for(i=5;i>=1;i--)
{
for(k=5;k>=i;k--)
{
printf(" ");
}
for(j=1;j<i;j++)
{
printf("*");
}

printf("\n");
}
getch();
}


   

Output

****
***
**
*

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Print Pattern 4 

 Sumit Kar     July 25, 2015     Basic, For Loop, Pattern     No comments   

#include <stdio.h>
void main()
{
int i, j, k;
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
printf("*");
printf("\n");
}
getch();
}

   

Output
*****
****
***
**
*

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Print Pattern 3 

 Sumit Kar     July 25, 2015     Basic, For Loop, Pattern     No comments   

#include <stdio.h>
void main()
{
int i, j, k;
for(i=5;i>=1;i--)
{
for(j=1;j<i;j++)
{
printf(" ");
}
for(k=5;k>=i;k--)
{
printf("*");
}
printf("\n");
}
getch();
}

   

Output

*
**
***
****
*****

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Print Pattern 2 

 Sumit Kar     July 25, 2015     Basic, For Loop, Pattern     No comments   

#include <stdio.h>
void main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}


   

Output
*
**
***
****
*****

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Friday, July 24, 2015

Print Pattern 1 

 Sumit Kar     July 24, 2015     Basic, For Loop, Pattern     No comments   

#include<stdio.h>
int main()
{
int num,r,c;
printf("Enter number of rows/columns: ");
scanf("%d",&num);
for(r=1; r<=num; r++)
{
for(c=1; c<=num; c++)
printf("* ");
printf("\n");
}
getch();
return 0;
}

   

Output
Enter number of rows/columns: 5
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp
Older Posts Home

Pages

  • Home

Trending Now

  • Write a Program to Add two 3x3 Matrix using C
    #include<stdio.h> void main () { int a [ 3 ][ 3 ], b [ 3 ][ 3 ], s [ 3 ][ 3 ], i , j ; printf ( "Enter the values of ...
  • C program for Unit Conversion
    /* Convert Celsius to Fahrenheit */ #include<stdio.h> void main() {     float c,f;     printf("Enter the temperature in Celcius: ...
  • Addition of two numbers on Server sent from Client [TCP] using C
    /* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #inc...
  • Write a Program to Print the Truth Table of Basic Gates using C
  • Write a Program to Add two 5x5 Matrix using C
    #include<stdio.h> void main() {   int a[5][5],b[5][5],c[5][5];   int i,j;   for(i=0;i<5;i++)   {     printf("\nEnter elements ...
  • Using the concept of Inheritance write a C++ Program to calculate the area and perimeter of rectangle
    /* C++ Program to calculate the area and perimeter of rectangles using concept of inheritance. */ #include using namespace std; class Re...
  • Concatenation of two strings sent from Client on the Server - [ TCP ] using C
    /* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #inc...
  • 8085 Programming: Exchange the contents of memory locations
    Exchange the contents of memory locations 2000H and 4000H. Program 1: LDA 2000H : Get the contents of memory location 2000H into accumulator...
  • Calculate Depreciation using C
    #include<conio.h> #include<stdio.h> void main () { float sv , pv , dep ; int yos ; clrscr (); printf ( "Enter the pu...
  • 8085 Programming: 1's COMPLEMENT OF A 16-BIT NUMBER
    The 16bit number is stored in C050,C051 The answer is stored in C052,C053   LXI H,C050   MOV A,M   CMA   STA C052   INX H   MOV ...

Blog Archive

  • ▼  2020 (1)
    • ▼  May (1)
      • Automating your deployments using Ansible
  • ►  2015 (92)
    • ►  October (4)
    • ►  September (3)
    • ►  August (3)
    • ►  July (9)
    • ►  June (9)
    • ►  May (20)
    • ►  April (7)
    • ►  March (22)
    • ►  February (7)
    • ►  January (8)
  • ►  2014 (158)
    • ►  November (70)
    • ►  October (6)
    • ►  September (82)
Powered by Blogger.

Categories

C - Programming Java Programming Basic Technology 8085 Assembly Programming For Loop Numerical Methods WhatsApp Algorithm Shell Programming Programming Networking Windows Android C++ Programming CPP If Else Tricky Internet Microsoft Pattern Photography Socket Program News While Loop Array DBMS DS Macro Recursion User Defined Function Conditional Operator Data Structure Durga Puja Earthquake Google Mela Nokia SQL Share Yahoo Airtel Bio Command Prompt Confused Facebook Finance Firefox Ganges Graph HokKolorob Input Kolkata MCQ Math Matrix NetNeutrality Oracle Religion Search Sumit Kar Survey Switch Case Viral Virus Visual Studio do-while featured featured_slider

Popular Programs

  • Write a Program to Add two 3x3 Matrix using C
    #include<stdio.h> void main () { int a [ 3 ][ 3 ], b [ 3 ][ 3 ], s [ 3 ][ 3 ], i , j ; printf ( "Enter the values of ...
  • C program for Unit Conversion
    /* Convert Celsius to Fahrenheit */ #include<stdio.h> void main() {     float c,f;     printf("Enter the temperature in Celcius: ...
  • Addition of two numbers on Server sent from Client [TCP] using C
    /* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #inc...
  • Write a Program to Print the Truth Table of Basic Gates using C
  • Write a Program to Add two 5x5 Matrix using C
    #include<stdio.h> void main() {   int a[5][5],b[5][5],c[5][5];   int i,j;   for(i=0;i<5;i++)   {     printf("\nEnter elements ...
  • Using the concept of Inheritance write a C++ Program to calculate the area and perimeter of rectangle
    /* C++ Program to calculate the area and perimeter of rectangles using concept of inheritance. */ #include using namespace std; class Re...
  • Concatenation of two strings sent from Client on the Server - [ TCP ] using C
    /* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #inc...
  • 8085 Programming: Exchange the contents of memory locations
    Exchange the contents of memory locations 2000H and 4000H. Program 1: LDA 2000H : Get the contents of memory location 2000H into accumulator...
  • Calculate Depreciation using C
    #include<conio.h> #include<stdio.h> void main () { float sv , pv , dep ; int yos ; clrscr (); printf ( "Enter the pu...
  • 8085 Programming: 1's COMPLEMENT OF A 16-BIT NUMBER
    The 16bit number is stored in C050,C051 The answer is stored in C052,C053   LXI H,C050   MOV A,M   CMA   STA C052   INX H   MOV ...

Daily Hits

Copyright © Sumit Kar