c array programs

      Comments Off on c array programs

c array programs

c array programs

c array programs is collection of array in c language. Here I have attached programs like receiving multiple items from users and store into array. Sort array. Copy data from one array to another array. Simple addition and multiplication of array. String related operations array like addition of string at specific location or search for some character and replace it with other characters. Hope you will like this article.

Have you checked, PHP Tutorial?

c array programs Example 1

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	int a[5]={0},i;

		printf("\t\t\t : Array Value is :");
	for(i=0;i<5;i++)
		printf("\na[%d] = %d",i,a[i]);

	printf("\n\n\t\t\t : Now Enter Value for Array A : \n");

	for(i=0;i<5;i++)
	{
		printf("a[%d]",i);
		scanf("%d",&a[i]);
	}

	printf("\n\n\t\t\t : Now See New Value of Array A : ");

		for(i=0;i<5;i++)
			printf("\na[%d] = %d",i,a[i]);

	getch();
}

 

c array programs Example 2

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	char ch[10]={0},i;

		printf("\t\t\t : Array Value is :");

	puts(ch);

	printf("\n Now Enter Value for Array Ch : ");

	gets(ch);

	printf("\n\n\t\t\t : Now See New Value of Array Ch : \n\n");

	puts(ch);

	getch();
}

 

c array programs Example 3

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/
//find sum of all numbers

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	int a[10]={0},i,sum=0;

	printf("\n Now Enter Value for Array A : ");

	for(i=0;i<10;i++)
	{
		printf("a[%d] = ",i);
		scanf("%d",&a[i]);
	}


	for(i=0;i<10;i++)
		sum=sum+a[i];

	printf("\n\n\t The Sum of All Number is : %d",sum);


	getch();
}

 

c array programs Example 4

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/
//find total odd and even numbers

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	int a[10]={0},i,sum=0;

	printf("\n Now Enter Value for Array A : \n");

	for(i=0;i<10;i++)
	{
		printf("a[%d] = ",i);
		scanf("%d",&a[i]);
	}

	printf("\n\n\t\t : Odd Number is : ");

	for(i=0;i<10;i++)
	{
	 if(a[i]%2==1)
		printf("\na[%d] = %d",i,a[i]);
	}

	printf("\n\n\t\t : Even Number is : ");

	for(i=0;i<10;i++)
	{
	 if(a[i]%2==0)
		printf("\na[%d] = %d",i,a[i]);
	}

	getch();
}

 

c array programs Example 5

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in/
//simple addition of two array and store into c

#include <stdio.h>
#include <conio.h>
void main()
{
	clrscr();
	int a[5]={0},b[5]={0},c[5]={0},i;

	printf("\n Now Enter Value for Array A : \n");

	for(i=0;i<5;i++)
	{
		printf("a[%d] = ",i);
		scanf("%d",&a[i]);
	}

	printf("\n Now Enter Value for Array B : \n");

	for(i=0;i<5;i++)
	{
		printf("b[%d] = ",i);
		scanf("%d",&b[i]);
	}

	for(i=0;i<5;i++)
		c[i]=a[i]+b[i];

	printf("\n\t\t : Sum of A + B is Stored in C : ");
	printf("\n\t\t\t : See All C element :");

	for(i=0;i<5;i++)
		printf("\nc[%d] = %d",i,c[i]);


	getch();
}

 

c array programs Example | Download All Programs

[sociallocker]Download[/sociallocker]