C program to cyclically permute the elements of an array.

Example programs to solve the problems of Arrays in C. In This program we, cyclically permute the array elements i.e. arr[0] becomes arr[1], arr[1] becomes arr[2]…so ..on. Read more about C Programming Language .

/***********************************************************
* 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 [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include <stdio.h>

void main ()
{
int i,n,number[30];
printf("Enter the value of the n = ");
scanf ("%d", &n);
printf ("Enter the numbersn");
for (i=0; i<n; ++i)
{
scanf ("%d", &number[i]);
}
number[n] = number[0];

for (i=0; i<n; ++i)
{
number[i] = number[i+1];
}
printf ("Cyclically permted numbers are given below n");
for (i=0; i<n; ++i)
printf ("%dn", number[i]);
}
Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to delete the specified integer from the Array.

Example programs to solve the problems of Arrays in C. In This program we, delete the Array Element, if entered element is in the Array, Else gives the Error message. Read more about C Programming Language .

/***********************************************************
* 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 [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

*/

#include <stdio.h>

void main()
{
int vectx[10];
int i, n, pos, element, found = 0;

printf("Enter how many elementsn");
scanf("%d", &n);

printf("Enter the elementsn");
for(i=0; i<n; i++)
{
scanf("%d", &vectx[i]);
}

printf("Input array elements aren");
for(i=0; i<n; i++)
{
printf("%dn", vectx[i]);
}

printf("Enter the element to be deletedn");
scanf("%d",&element);

for(i=0; i<n; i++)
{
if ( vectx[i] == element)
{
found = 1;
pos = i;
break;
}
}

if (found == 1)
{
for(i=pos; i< n-1; i++)
{
vectx[i] = vectx[i+1];
}

printf("The resultant vector is n");
for(i=0; i<n-1; i++)
{
printf("%dn",vectx[i]);
}
}
else
printf("Element %d is not found in the vectorn", element);

}
Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to split the array from perticular position

Example programs to solve the problems of Arrays in C. In This program we, cyclically permute the array elements i.e. arr[0] becomes arr[1], arr[1] becomes arr[2]…so ..on. Read more about C Programming Language .

/***********************************************************
* 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 [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/



#include <stdio.h>

void main ()
{
int number[30];
int i,n,a,j;

printf ("Enter the value of nn");
scanf ("%d",&n);

printf ("enter the numbersn");
for (i=0; i<n; ++i)
scanf ("%d", &number[i]);

printf ("Enter the position of the element to split the array n");
scanf ("%d",&a);

for (i=0; i<a; ++i)
{
number[n] = number[0];

for (j=0; j<n; ++j)
{
number[j] = number[j+1];
}
}

printf("The resultant array isn");
for (i=0; i<n; ++i)
{
printf ("%dn",number[i]);
}
}
Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to find size-of an array.

Example programs to solve the problems of Arrays in C. In This program we, find the size of the array using sizeof() operator. Read more about C Programming Language .

/***********************************************************
* 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 [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include <stdio.h>
int main( )
{

int i,num;
printf("nEnter the hoe many elements you want?n");
scanf("%d",&num);

int a[num];
printf("nEnter the %d elements:n",num);
for(i=0;i<num;i++)
{
scanf("%d",&a[i]);
}
printf("Elements in array are:n");
for(i=0;i<num;i++)
{
printf("%dn",a[i]);
}
printf(" The size of the array is: %d Bytes.",(int)sizeof(a));

return 0 ;
}
Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program to implement the Newton- Gregory forward interpolation

C Program to implement the Newton- Gregory forward interpolation. Newtons – Gregory forward difference formula is a finite difference identity capable of giving an interpolated value between the tabulated points {fk} in terms of the first value f0 and powers of the forward difference Δ. In this program we used the multidimensional arrays and arrays in c. Read more about C Programming Language .

/***********************************************************
* 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 [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/



#include<stdio.h>
#include<conio.h>
#define MaxN 100
#define Order_of_diff 4

void main ()
{
float arr_x[MaxN+1], arr_y[MaxN+1], numerator=1.0, denominator=1.0, x, y, p, h, diff_table[MaxN+1][Order_of_diff+1];
int i,j,n,k;
clrscr();

printf("Enter the value of n n");
scanf("%d",&n);
printf("Enter the values of x and y");

for(i=0; i<=n; i++)
scanf("%f%f", &arr_x[i], &arr_y[i]);
printf("Enter the value of x at which value of y is to be calculated");
scanf("%f", &x);
h=arr_x[1]-arr_x[0];

for(i=0; i<=n-1; i++)
diff_table[i][1]=arr_y[i+1]-arr_y[i];/*Creating the difference table and calculating first order differences*/
for(j=2; j<=Order_of_diff; j++)/*Calculating higher order differences*/
for(i=0; i<=n-j; i++)
diff_table[i][j]=diff_table[i+1][j-1] - diff_table[i][j-1];
i=0;

while(!(arr_x[i]>x)) /* Finding x0 */
i++;
i--;
p=(x-arr_x[i])/h;
y=arr_y[i];

for (k=1; k<=Order_of_diff; k++)
{
numerator *=p-k+1;
denominator *=k;
y +=(numerator/denominator)*diff_table[i][k];
}
printf("When x=%6.1f, y=%6.2fn",x, y);
getch();
}

Read more Similar C Programs
Learn C Programming

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program for Stack Operations using arrays.

Data structures using C,
Stack is a data structure in which the objects are arranged in a non linear order. In stack, elements are added or deleted from only one end, i.e. top of the stack. Here we implement the PUSH, POP, DISPLAY stack operations using the array. Read more about C Programming Language .

/***********************************************************
* 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 [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/
#include<stdio.h>
#define SIZE 5 /* Size of Stack */
int s[SIZE], top = -1; /* Global declarations */

push(int elem) { /* Function for PUSH operation */
if (Sfull())
printf("nn Overflow!!!!nn");
else {
++top;
s[top] = elem;
}
}

int pop() { /* Function for POP operation */
int elem;
if (Sempty()) {
printf("nnUnderflow!!!!nn");
return (-1);
} else {
elem = s[top];
top--;
return (elem);
}
}

int Sfull() { /* Function to Check Stack Full */
if (top == SIZE - 1)
return 1;
return 0;
}

int Sempty() { /* Function to Check Stack Empty */
if (top == -1)
return 1;
return 0;
}

display() { /* Function to display status of Stack */
int i;
if (Sempty())
printf(" n Empty Stackn");
else {
for (i = 0; i <= top; i++)
printf("%dn", s[i]);
printf("^Top");
}
}

main() { /* Main Program */
int opn, elem;
do {
clrscr();
printf("n ### Stack Operations ### nn");
printf("n Press 1-Push, 2-Pop,3-Display,4-Exitn");
printf("n Your option ? ");
scanf("%d", &opn);
switch (opn) {
case 1:
printf("nnRead the element to be pushed ?");
scanf("%d", &elem);
push(elem);
break;
case 2:
elem = pop();
if (elem != -1)
printf("nnPopped Element is %d n", elem);
break;
case 3:
printf("nnStatus of Stacknn");
display();
break;
case 4:
printf("nn Terminating nn");
break;
default:
printf("nnInvalid Option !!! Try Again !! nn");
break;
}
printf("nnnn Press a Key to Continue . . . ");
getch();
} while (opn != 4);
}

Read more Similar C Programs
Data Structures

Learn C Programming

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to find the sum of two-dimensional arrays using Dynamic Memory Allocation.

Arrays in C
C Program to find the sum of two-dimensional arrays using Dynamic Memory Allocation. The malloc() function allocates the dynamic memory to variables of specified bytes.Read more about C Programming Language .

/***********************************************************
* 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 [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/
#include <stdio.h>
#include <alloc.h>
#include <stdlib.h>

void main()
{
int i,n;
int *a,*b,*c;

printf("How many Elements in each array...n");
scanf("%d", &n);

a = (int *) malloc(n*sizeof(int));
b = (int *) malloc(n*sizeof(int));
c =( int *) malloc(n*sizeof(int));

printf("Enter Elements of First Listn");
for(i=0;i<n;i++)
{
scanf("%d",a+i);
}

printf("Enter Elements of Second Listn");
for(i=0;i<n;i++)
{
scanf("%d",b+i);
}

for(i=0;i<n;i++)
{
*(c+i) = *(a+i) + *(b+i);
}

printf("Resultant List isn");
for(i=0;i<n;i++)
{
printf("%dn",*(c+i));
}

} /* End of main() */
Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program: Insert into an array

Arrays in C
Write a C program to insert a particular element in a specified position in a given array.Read more about C Programming Language .

/***********************************************************
* 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 [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

*/

#include <stdio.h>
#include <conio.h>

void main()
{
int x[10];
int i, j, n, m, temp, key, pos;

clrscr();

printf("Enter how many elementsn");
scanf("%d", &n);

printf("Enter the elementsn");
for(i=0; i<n; i++)
{
scanf("%d", &x[i]);
}

printf("Input array elements aren");
for(i=0; i<n; i++)
{
printf("%dn", x[i]);
}

for(i=0; i< n; i++)
{
for(j=i+1; j<n; j++)
{
if (x[i] > x[j])
{
temp = x[i];
x[i] = x[j];
x[j] = temp;
}
}
}

printf("Sorted list isn");
for(i=0; i<n; i++)
{
printf("%dn", x[i]);
}

printf("Enter the element to be insertedn");
scanf("%d",&key);

for(i=0; i<n; i++)
{
if ( key < x[i] )
{
pos = i;
break;
}
}

m = n - pos + 1 ;

for(i=0; i<= m ; i++)
{
x[n-i+2] = x[n-i+1] ;
}

x[pos] = key;

printf("Final list isn");
for(i=0; i<n+1; i++)
{
printf("%dn", x[i]);
}
} /* End of main() */
Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program: Array Summation Using Pointers

Arrays in C.
Write a C program to read N integers and store them in an array A, and so find the sum of all these elements using pointer. Output the given array and and the computed sum with suitable heading. Read more about C Programming Language .

/***********************************************************
* 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 [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/



#include <stdio.h>
#include <conio.h>
#include <malloc.h>

void main()
{
int i,n,sum=0;
int *a;

clrscr();

printf("Enter the size of array An");
scanf("%d", &n);

a=(int *) malloc(n*sizeof(int)); /*Dynamix Memory Allocation */

printf("Enter Elements of First Listn");
for(i=0;i<n;i++)
{
scanf("%d",a+i);
}

/*Compute the sum of all elements in the given array*/
for(i=0;i<n;i++)
{
sum = sum + *(a+i);
}

printf("Sum of all elements in array = %dn", sum);

} /* End of main() */
Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed! and the computed sum with suitable heading. Read more about C Programming Language .

(c) www.c-program-example.com

C Program To Demonstrate Linear search

Write a C program to input N numbers (integers or reals) and store them in an array. Conduct a linear search for a given key number and report success or failure in the form of a suitable message.
Linear search is the basic searching algorithm, also called as sequential search. Algorithm search’s the element by comparing the each element in the list, until the desired element found. Read more about C Programming Language.

/***********************************************************
* 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 [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/


#include <stdio.h>
#include <conio.h>

void main()
{
int array[10];
int i, N, keynum, found=0;

clrscr();

printf("Enter the value of Nn");
scanf("%d",&N);

printf("Enter the elements one by onen");
for(i=0; i<N ; i++)
{
scanf("%d",&array[i]);
}
printf("Input array isn");
for(i=0; i<N ; i++)
{
printf("%dn",array[i]);
}
printf("Enter the element to be searchedn");
scanf("%d", &keynum);

/* Linear search begins */
for ( i=0; i < N ; i++)
{
if( keynum == array[i] )
{
found = 1;
break;
}
}
if ( found == 1)
printf("SUCCESSFUL SEARCHn");
else
printf("Search is FAILEDn");

} /* End of main */
Read more Similar C Programs
C Basic

Search Algorithms.

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com