Skip to content

Instantly share code, notes, and snippets.

View snadahalli's full-sized avatar

Sandeepa Nadahalli snadahalli

View GitHub Profile
@snadahalli
snadahalli / evenoddsum.c
Created November 6, 2013 17:40
C Program to read ten integers from the keyboards and print the sum of even and odd numbers.
/***********************************************************
* 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 / sumofrange.c
Created November 8, 2013 14:09
C Program to find the number and sum of all integers from 100 to 200 which is divisible by 7.
/***********************************************************
* 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 / stddev.c
Created December 3, 2013 05:33
Function to calculate standard deviation.
float computeStandardDeviation(float a[], int n, float mean) {
float variance, deviation, sumsquare = 0;
int i;
for(i=0; i<n; i++) {
deviation = a[i] - mean;
sumsquare += deviation * deviation;
}
variance = sunsquare/(float)n;
@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);
@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);
/*
* 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 / 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;
@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 / 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);