Skip to content

Instantly share code, notes, and snippets.

@snadahalli
snadahalli / binary_to_decimal.c
Created Aug 11, 2017
Binary to Decimal C Program
View binary_to_decimal.c
#include<stdio.h>
/*
* Function to convert a given binary number to
* its decimal equivalent.
*/
int binary_to_decimal(int num) {
int rem, base = 1, decimal_number = 0;
while( num > 0) {
rem = num % 10;
@snadahalli
snadahalli / bfs.c
Created Sep 11, 2017
Breadth First Search(BFS) Program in C.
View bfs.c
#include<stdio.h>
int a[20][20], q[20], visited[20], n, i, j, f = 0, r = -1;
void bfs(int v) {
for(i = 1; i <= n; i++)
if(a[v][i] && !visited[i])
q[++r] = i;
if(f <= r) {
visited[q[f]] = 1;
bfs(q[f++]);
View gist:906427512f8387dbcd877f2cc9643ada
Verifying my Blockstack ID is secured with the address 1Gp1jqEktVpJzKbckjLgSZbyuzw4XCrm5 https://explorer.blockstack.org/address/1Gp1jqEktVpJzKbckjLgSZbyuzw4XCrm5
@snadahalli
snadahalli / BinomialCoefficients.c
Last active Oct 17, 2019
C Program to find Binomial coefficients without using recursion
View BinomialCoefficients.c
// C program to find the Binomial coefficient. Downloaded from www.c-program-example.com
#include<stdio.h>
void main() {
int i, j, n, k, min, c[20][20]={0};
printf("This program is brought to you by www.c-program-example.com\n" );
printf("\n Enter the value of n: ");
scanf("%d", &n);
printf("\n Enter the value of k: ");
scanf("%d", &k);
@snadahalli
snadahalli / magic_square.c
Last active Dec 12, 2018
C Program to check if a given matrix is a magic square matrix or not.
View magic_square.c
#include <stdio.h>
void main() {
int A[50][50];
int i, j, M, N;
int size;
int rowsum, columnsum, diagonalsum;
int magic = 0;
printf("Enter the order of the matrix:\n");
scanf("%d %d", &M, &N);
View keybase.md

Keybase proof

I hereby claim:

  • I am snadahalli on github.
  • I am snadahalli (https://keybase.io/snadahalli) on keybase.
  • I have a public key ASC9T8GbT8mh26-3Ueg0xikukd4b6iI8GhO8gFlH7AB8Two

To claim this, I am signing this object:

@snadahalli
snadahalli / bubble_sort.c
Last active May 16, 2018
C program to sort an integer array using bubble sort.
View bubble_sort.c
/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use
* the programs for commercial purposes,
* contact info@c-program-example.com
* To find more C programs, do visit www.c-program-example.com
* and browse!
* Happy Coding
***********************************************************/
@snadahalli
snadahalli / calculator.c
Last active Mar 1, 2018
C program to implement a simple calculator using switch statement.
View calculator.c
/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use
* the programs for commercial purposes,
* contact info@c-program-example.com
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/
@snadahalli
snadahalli / vowel.c
Created Oct 23, 2013
C program to check whether a given character is vowel or consonant.
View vowel.c
/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact info@c-program-example.com
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/
@snadahalli
snadahalli / number_to_words.c
Last active Nov 4, 2017
C Program to convert number to words
View number_to_words.c
#include<stdlib.h>
#include<stdio.h>
void main() {
long num, div, n1;
int flag, digit, pos, tot_dig;
printf("\nEnter a number: ");
scanf("%ld", &num);
if(num == 0) {