Skip to content

Instantly share code, notes, and snippets.

View array_initialization_1.c
int Age [5] = {30, 22, 33, 44, 25};
int Age [5];
Age [0]=30;
Age [1]=22;
Age [2]=33;
Age [3]=44;
Age [4]=25;
View array_definition_1.h
#define NUM_EMPLOYEE 10
int Age[NUM_EMPLOYEE];
View array.c
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#define NUM_EMPLOYEE 10
int main(int argc, char *argv[]) {
int Salary[NUM_EMPLOYEE], lCount=0, gCount=0, i=0;
printf( "Enter employee salary (Max 10)\n" );
View example4.c
while(low <= high)
{
mid = (low + high) / 2;
if (target < list[mid]) {
high = mid - 1;
}
else if (target > list[mid]) {
low = mid + 1;
View example3.c
for(i=0; i < N; i++)
{
for(j=0; j < N;j++)
{
statement;
}
}
View example2.c
for(i=0; i < N; i++)
{
some statement;
}
View example_square_of_n_2.c
/*
we have to calculate the square of n
*/
return n*n;
View example_square_of_n_1.c
/*
we have to calculate the square of n
*/
for i=1 to n
do n = n + n
// when the loop ends n will hold its square
return n
View example_sum.c
/* n is the length of array a[] */
int sum(int a[], int n)
{
int x = 0; // 4 bytes for x
for( int i = 0; i < n; i++ ) // 4 bytes for i
{
x = x + a[i];
}
return(x);
}
You can’t perform that action at this time.