Skip to content

Instantly share code, notes, and snippets.

View snadahalli's full-sized avatar

Sandeepa Nadahalli snadahalli

View GitHub Profile
Verifying my Blockstack ID is secured with the address 1Gp1jqEktVpJzKbckjLgSZbyuzw4XCrm5 https://explorer.blockstack.org/address/1Gp1jqEktVpJzKbckjLgSZbyuzw4XCrm5

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 / number_to_words.c
Last active November 4, 2017 08:16
C Program to convert number to words
#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) {
@snadahalli
snadahalli / goto.c
Created October 9, 2017 12:17
Simple C program to demonstrate goto statement
#include <stdio.h>
#include <stdlib.h>
main()
{
char data[100];
double num1, num2;
printf("\nPlease enter a number ==> " );
gets(data);
@snadahalli
snadahalli / isLocked.cs
Created September 20, 2017 10:56
Check if a file is locked
public static bool IsFileLocked(FileInfo file) {
FileStream stream = null;
if(!file.Exists)
return false;
try {
stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None);
} catch (IOException) {
// the file is unavailable because it is:
@snadahalli
snadahalli / greed_coin_changer.c
Last active September 20, 2017 07:35
A simple solution for Change-making problem based on greedy method.
#include <stdio.h>
int main () {
int num_denominations, coin_list[100], use_these[100], i, owed;
printf("Enter number of denominations : ");
scanf("%d", &num_denominations);
printf("\nEnter the denominations in descending order: ");
for(i=0; i< num_denominations; i++) {
@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 / day_of_birth.c
Last active September 8, 2017 10:54
C Program to find the day(of week) of birth from a given Date of Birth.
#include<stdio.h>
#include<stdlib.h>
int main() {
int d, m, y, year, month, day, i;
printf("Enter date of birth (DD MM YYYY) :");
scanf("%d %d %d", &d, &m, &y);
if( (d > 31) || (m > 12) || (y < 1900 || y >= 2100) )
{
@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 / increment_decrement.c
Created September 5, 2017 17:56
C Program to demonstrate the working of increment and decrement operators.
/* C Program to demonstrate increment and decrement operators */
main()
{
/*
* ++i -> i incremented before i is used.
* --i -> i decremented before i is used.
* j++ -> j is incremented AFTER j has been used.
* j-- -> j is decremented AFTER j has been used.
*/