Skip to content

Instantly share code, notes, and snippets.

View snadahalli's full-sized avatar

Sandeepa Nadahalli snadahalli

View GitHub Profile
@snadahalli
snadahalli / magic_square.c
Last active February 15, 2024 16:25
C Program to check if a given matrix is a magic square matrix or not.
#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);
@snadahalli
snadahalli / evaluate.c
Created November 3, 2013 09:31
C Program to evaluate the following series. f(x)=x-x3/3! + x5/5!-x7/7!.....into given numbers of terms.
/***********************************************************
* 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 / bfs.c
Created September 11, 2017 13:21
Breadth First Search(BFS) Program in 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++]);
@snadahalli
snadahalli / binary_to_octal_decimal_hexadecimal.c
Last active August 26, 2022 09:57
C Program To convert a given binary number to equivalent octal, decimal & hexadecimal number
#include <stdio.h>
/*
* Function to convert a given decimal number to its
* hexadecimal equivalent.
*/
int decimal_to_hex(long number, char *hexstr, int pos) {
long i;
int new_position, n;
char hexchar;
@snadahalli
snadahalli / binary_to_decimal.c
Created August 11, 2017 12:17
Binary to Decimal C Program
#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;
Verifying my Blockstack ID is secured with the address 1Gp1jqEktVpJzKbckjLgSZbyuzw4XCrm5 https://explorer.blockstack.org/address/1Gp1jqEktVpJzKbckjLgSZbyuzw4XCrm5
@snadahalli
snadahalli / BinomialCoefficients.c
Last active October 17, 2019 08:52
C Program to find Binomial coefficients without using recursion
// 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);

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 14:20
C program to sort an integer array using bubble sort.
/***********************************************************
* 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 March 1, 2018 09:35
C program to implement a simple calculator using switch statement.
/***********************************************************
* 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
***********************************************************/