Skip to content

Instantly share code, notes, and snippets.

View snadahalli's full-sized avatar

Sandeepa Nadahalli snadahalli

View GitHub Profile
@snadahalli
snadahalli / vowel.c
Created October 23, 2013 04:02
C program to check whether a given character is vowel or consonant.
/***********************************************************
* 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 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 / 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 / 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.
*/
@snadahalli
snadahalli / palindrome.c
Last active August 9, 2017 10:59
C Program to check whether a given 5 digit number is palindrome or not.
/* C program to check whether a given 5 digit number is palindrome or not
* (c) www.c-program-example.com
*/
#include<stdio.h>
int main() {
int num, rem, i, rev = 0, num1, count = 0;
printf("Enter a five digit number:\n");
/*
* C Program to convert a given infix expression to postfix expression and evaluate it.
* (c) www.c-program-example.com
*/
#define SIZE 50 /* Size of Stack */
#include <ctype.h>
#include <stdio.h>
char s[SIZE];
@snadahalli
snadahalli / Linear_array_search.c
Last active August 6, 2017 15:33
C Program to demonstrate the working of linear search. We take an array of integers and search it for a given key.
#include <stdio.h>
#include <conio.h>
void main()
{
int array[10];
int i, N, keynum, found=0;
printf("Enter the value of N\n");
scanf("%d",&N);