Saturday, July 5, 2025
Home Blog Page 11

jagged array | Jagged array in C# with example

Jagged array is an array of arrays.

If we want to hold different column values in different rows then we should prefer jagged array.

jagged array also   store  the data in the form of row  and column like, two dimensional array, but two dimensional array. all the row will be  having equal number of column where as jagged  array the column size different form row  to row.

Jagged array also known as array  of array   because  here  different single dimensional  array  between different signs combined together to form a new array.

Syntax

<type>[ ] [ ]<name>= new <type>[ rows] [];

Int [ ] [ ] arr = new int [3][ ];

Int[ ] [ ] arr = { list of values ];

NOTE

While  declaring  a jagged  array in  that initial declaration we can only specified no of row the new no of row to the array and then are need to specified the column to each row individual.

Initialization of jagged array

arr[0] = new int [ 4 ]

arr[0] = new int [ 6 ]

Benifit of jagged array

  • Minimise of space .
  • Minimize of code .

ADO tutorial

ADO Introduction

                      Pretty much every application deals with data in some manner, whether that data comes from memory, databases, XML files, text files, or something else. The location where we store the data can be called as a Data Source or Data Store where a Data Source can be a file, database, or indexing server etc.

                       Programming Languages cannot communicate with Data Sources directly because each Data Source adopts a different Protocol (set of rules) for communication, so to overcome this problem long back Microsoft has introduced intermediate technologies like JET, Odbc and Oledb which works like bridge between the Applications and Data Sources to communicate with each other.

The Microsoft Jet Database Engine is a database engine on which several Microsoft products have been built. A database engine is the underlying component of a database, a collection of information stored on a computer in a systematic way. The first version of Jet was developed in 1992, consisting of three modules which could be used to manipulate a database. JET stands for Joint Engine Technology, sometimes being referred to as Microsoft JET Engine or simply Jet. Microsoft Access and Excel uses Jet as their underlying database engine. Over the years, Jet has become almost synonymous with Microsoft Access, to the extent where many people refer to a Jet database as an “Access database”. MS developed Jet database system, a C-based interface allowing applications to access that data, and a selection of driver DLLs that allowed the same C interface to redirect input and output to databases. However, Jet did not use SQL; the interface was in C and consisted of data structures and function calls.

ODBC (Open Database Connectivity)

ODBC (Open Database Connectivity) is a standard C programming language middle ware API for accessing database management systems (DBMS). ODBC accomplishes DBMS independence by using an ODBC driver as a translation layer between the application and the DBMS. The application uses ODBC functions through an ODBC driver manager with which it is linked, and the driver passes the query to the DBMS. An ODBC driver will be providing a standard set of functions for the application to use, and implementing DBMS-specific functionality. An application that can use ODBC is referred to as “ODBC-compliant”. Any ODBC-compliant application can access any DBMS for which a driver is installed. Drivers exist for all major DBMSs as well as for many other data sources like Microsoft Excel, and even for text or CSV files. ODBC was originally developed by Microsoft during the early 1990s.

OLE DB (Object Linking and Embedding, Database)

OLE DB (Object Linking and Embedding, Database, sometimes written as OLEDB or OLE-DB), an API designed by Microsoft, allows accessing data from a variety of sources in a uniform manner. The API provides a set of interfaces implemented using the Component Object Model (COM). Microsoft originally intended OLE DB as a higher-level replacement for, and successor to, ODBC, extending its feature set to support a wider variety of non-relational databases, such as object databases and spreadsheets that do not necessarily implement SQL. OLE DB is conceptually divided into consumers and providers. The consumers are the applications that need access to the data, and the providers are the software components that implement the interface and thereby provide the data to the consumer. An OLE DB provider is a software component enabling an OLE DB consumer to interact with a data source. OLE DB providers are alike to ODBC drivers or JDBC drivers for Java. OLE DB providers can be created to access such simple data stores as a text file and spreadsheet, through to such complex databases as Oracle, Microsoft SQL Server, and many others. It can also provide access to hierarchical data stores.

The Fastest WordPress Theme

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc imperdiet rhoncus arcu non aliquet. Sed tempor mauris a purus porttitor, ac convallis arcu venenatis. Donec lorem erat, ornare in augue at, pharetra cursus mauris. Cras commodo orci vel scelerisque convallis. Fusce sollicitudin feugiat placerat. Aenean magna massa, vehicula at efficitur ac, vestibulum non felis. Aliquam quis feugiat sapien, eu sodales mauris.

Phasellus at auctor nibh. Morbi feugiat finibus nulla, et semper ipsum sodales a. Fusce at lacus vestibulum, luctus sapien quis, dictum erat. Phasellus orci sem, pretium nec blandit sed, faucibus eget massa. Aliquam lobortis sapien augue. Nullam dignissim elit ac libero egestas egestas. Vestibulum et convallis urna, fermentum porta mauris. Nam pellentesque lectus varius, facilisis metus at, elementum augue. Pellentesque suscipit enim massa. Curabitur elementum lorem neque, non accumsan orci vulputate placerat. Vestibulum nec mauris at dui mattis blandit. Duis nec lacinia lacus. Fusce consectetur, sapien posuere lobortis maximus, velit orci ornare felis, id elementum ex ipsum at enim. Integer lacinia ipsum nec purus sodales tristique. Curabitur iaculis at nisl et commodo.

Praesent mattis purus magna, ac iaculis tellus elementum blandit. Nullam massa ante, egestas non porta consequat, sodales ac elit. Phasellus vitae erat id massa volutpat tincidunt. Sed suscipit sed dui quis efficitur. Mauris consectetur placerat urna, ac pharetra libero suscipit ut. Mauris accumsan magna pretium ante imperdiet, ac varius augue interdum. Proin id congue leo. Curabitur eu nulla risus. Phasellus a sodales leo. Donec blandit massa et egestas dapibus. Phasellus non justo mi. Mauris leo sapien, molestie a auctor non, venenatis finibus purus.

Top 10 Contact Form Plugins

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc imperdiet rhoncus arcu non aliquet. Sed tempor mauris a purus porttitor, ac convallis arcu venenatis. Donec lorem erat, ornare in augue at, pharetra cursus mauris. Cras commodo orci vel scelerisque convallis. Fusce sollicitudin feugiat placerat. Aenean magna massa, vehicula at efficitur ac, vestibulum non felis. Aliquam quis feugiat sapien, eu sodales mauris.

Phasellus at auctor nibh. Morbi feugiat finibus nulla, et semper ipsum sodales a. Fusce at lacus vestibulum, luctus sapien quis, dictum erat. Phasellus orci sem, pretium nec blandit sed, faucibus eget massa. Aliquam lobortis sapien augue. Nullam dignissim elit ac libero egestas egestas. Vestibulum et convallis urna, fermentum porta mauris. Nam pellentesque lectus varius, facilisis metus at, elementum augue. Pellentesque suscipit enim massa. Curabitur elementum lorem neque, non accumsan orci vulputate placerat. Vestibulum nec mauris at dui mattis blandit. Duis nec lacinia lacus. Fusce consectetur, sapien posuere lobortis maximus, velit orci ornare felis, id elementum ex ipsum at enim. Integer lacinia ipsum nec purus sodales tristique. Curabitur iaculis at nisl et commodo.

Praesent mattis purus magna, ac iaculis tellus elementum blandit. Nullam massa ante, egestas non porta consequat, sodales ac elit. Phasellus vitae erat id massa volutpat tincidunt. Sed suscipit sed dui quis efficitur. Mauris consectetur placerat urna, ac pharetra libero suscipit ut. Mauris accumsan magna pretium ante imperdiet, ac varius augue interdum. Proin id congue leo. Curabitur eu nulla risus. Phasellus a sodales leo. Donec blandit massa et egestas dapibus. Phasellus non justo mi. Mauris leo sapien, molestie a auctor non, venenatis finibus purus.

3 Awesome Security Plugins for WordPress

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc imperdiet rhoncus arcu non aliquet. Sed tempor mauris a purus porttitor, ac convallis arcu venenatis. Donec lorem erat, ornare in augue at, pharetra cursus mauris. Cras commodo orci vel scelerisque convallis. Fusce sollicitudin feugiat placerat. Aenean magna massa, vehicula at efficitur ac, vestibulum non felis. Aliquam quis feugiat sapien, eu sodales mauris.

Phasellus at auctor nibh. Morbi feugiat finibus nulla, et semper ipsum sodales a. Fusce at lacus vestibulum, luctus sapien quis, dictum erat. Phasellus orci sem, pretium nec blandit sed, faucibus eget massa. Aliquam lobortis sapien augue. Nullam dignissim elit ac libero egestas egestas. Vestibulum et convallis urna, fermentum porta mauris. Nam pellentesque lectus varius, facilisis metus at, elementum augue. Pellentesque suscipit enim massa. Curabitur elementum lorem neque, non accumsan orci vulputate placerat. Vestibulum nec mauris at dui mattis blandit. Duis nec lacinia lacus. Fusce consectetur, sapien posuere lobortis maximus, velit orci ornare felis, id elementum ex ipsum at enim. Integer lacinia ipsum nec purus sodales tristique. Curabitur iaculis at nisl et commodo.

Praesent mattis purus magna, ac iaculis tellus elementum blandit. Nullam massa ante, egestas non porta consequat, sodales ac elit. Phasellus vitae erat id massa volutpat tincidunt. Sed suscipit sed dui quis efficitur. Mauris consectetur placerat urna, ac pharetra libero suscipit ut. Mauris accumsan magna pretium ante imperdiet, ac varius augue interdum. Proin id congue leo. Curabitur eu nulla risus. Phasellus a sodales leo. Donec blandit massa et egestas dapibus. Phasellus non justo mi. Mauris leo sapien, molestie a auctor non, venenatis finibus purus.

.net framework tutorial

.NET FRAMEWORK  is the software that is required for execution of the dot net applications on any machine. This software asks the functionalities of an operating system and makes the code do execute on its control providing the benefits. Like:

  1. Platform independency
  2. Security
  3. Automatic memory management


The code which is runs on the under the control of the framework is referred as managed code and the code which runs on the operating system (machine code) is referred as un-managed code.

click here – .net framework latest version download

DEVELOPMENT OF .NET FRAMEWORK:

The development of the dot net framework has been started in the late 90s. Originally under the name NGSW (next generation windows services).

The framework has been developed following a set up specification referred as CLI specification:

CLI specifications are open specifications that are standardizes an ISO and ECMA (European Computer Manufacturer Association).giving a chance to third party to develop the third party.

CLI Specification takes 4 major things:  

CLS (Common Language Specification)

CTS (Common Type System)

BCL (Base Class Library)

VES (Virtual execution System)

ASP.NET DataList Control

ASP.NET DataList Control  Introduction:

The DataList control is, like the Repeater control, used to display a repeated list of items that are bound to the control. However, the DataList control adds a table around the data items by default. The DataList control may be bound to a database table, an XML file, or another list of items.

OR

The DataList control like the Repeater control is a template driven, light weight control, and acts as a container of repeated data items. The templates in this control are used to define the data that it will contain. It is flexible in the sense that you can easily customize the display of one or more records that are displayed in the control.

OR

The DataList Web server control displays data in a format that you can define using templates and styles. The DataList control is useful for data in any repeating structure, such as a table. The DataList control can display rows in different layouts, such as ordering them in columns or rows.

 

When the web page is in execution with the data bound to it using the Page_Load event, the data in the DataList control is rendered as DataListItem objects, that is, each item displayed is actually a DataListItem. Similar to the Repeater control, the DataList control supports Editing and Deleting features whereas Repeater does not support. The DataList control does not have Paging and Sorting functionalities built into it similar to Repeater control.

Also, DataList has RepeatDirection, RepeatColumns and RepeatLayout properties, which are unique for DataList control. These properties are useful when you need to create presentation with more than one record per row, like Image Gallery, Product Catalogue etc. For example, let say you are creating an image gallery and want to show 5 images per row. Repeater would require checking of record position and manipulating HTML. With DataList, just use RepeatDirection=”Horizontal” and RepeatColumns=”5″. RepeatLayout could be Table or Flow, depending of do you need HTML table structure in layout. These features are not possible using any other data controls.

The DataList Control includes a rich set of properties that we can use to format the HTML rendered by the control whereas Repeater Controls doesn’t not support this feature. If we want to associate Cascading Style Sheet rules with various elements of the DataList, then we can take advantage of any of the following properties:

CssClass: It enables us to associate a CSS class with the DataList.

 HeaderStyle: It enables us to format the header row of the DataList.

 FooterStyle: It enables us to format the footer row of the DataList.

 ItemStyle: It enables us to format each row displayed by the DataList.

AlternatingItemStyle: It enables us to format every other row of the DataList.

EditItemStyle: It enables us to format the DataList row selected for editing.

SelectedItemStyle: It enables us to format the selected row in the DataList.

SeparatorStyle: It enables us to format the row separator displayed by the DataList.

When formatting the DataList, we also need to work with the following properties:

GridLines: It enables us to add rules around the cells in the DataList. Possible values are None, Horizontal, Vertical, and Both.

ShowFooter: It enables us to show or hide the footer row.

ShowHeader: It enables us to show or hide the header row.

UseAccessibleHeader: It enables us to render HTML <th> tags instead of <td> tags for the cells in the header row.

Using the DataList Control:

To use this control, drag and drop the control in the design view of the web form onto a web form from the toolbox and corresponding markup will be generated automatically in the source view of a web form as following:

<asp:DataList ID=”DataList1″ runat=”server”></asp:DataList>

The Templates are as follows: 

HeaderTemplate   –  HeaderStyle

FooterTemplate   –  FooterStyle

ItemTemplate   –  ItemStyle

AlternatingItemTemplate  –  AlternatingItemStyle

EditItemTemplate   –  EditItemStyle

SelectedItemTemplate  –  SelectedItemStyle

SeparatorTemplate   –  SeperatorStyle

Events of DataList Controls:

ItemCreated: Occurs on the server when an item in the System.Web.UI.WebControls.DataList control is created.

ItemCommand: Occurs when any button is clicked in the System.Web.UI.WebControls.DataList control.

ItemDataBound: Occurs when an item is data bound to the System.Web.UI.WebControls.DataList control.

EditCommand: Occurs when the Edit button is clicked for an item in the System.Web.UI.WebControls.DataList control.

UpdateCommand: Occurs when the Update button is clicked for an item in the System.Web.UI.WebControls.DataList control.

DeleteCommand: Occurs when the Delete button is clicked for an item in the System.Web.UI.WebControls.DataList control.

CancelCommand: Occurs when the Cancel button is clicked for an item in the System.Web.UI.WebControls.DataList control.

SelectedIndexChanged: Occurs when a different item is selected in a data listing control between posts to the server.

 

 

ajax tutorial

   Introduction: Ajax is shorthand for “Asynchronous JavaScript and XML”. It is a web development technique for creating interactive web application. Ajax is a latest boom in the web development world (Either we develop web application using classic ASP, or PHP, or Servlet / JSP, or ASP.NET). Ajax can be used in these all web technologies to create interactive web applications. Ajax meant to increase the web pages interactivity, speed, and usability. Ajax can be used for creating rich web based applications that look and works like a desktop applications (Standalone application). Ajax is a group of interrelated web development techniques used on the client side to create asynchronous web applications. Ajax is of the most important technology for the development of highly interactive web application and due to its features it has become extremely popular in web development world. Ajax is not a new technology but a new way to use existing standards it is basically a web development technique which uses existing technologies like JavaScript and XML. In traditional ASP.NET web application, when user submits a form (web form), they have to wait around for the page to reload before seeing the results. With AJAX our application can dynamically populate a page (For ex. Retrieve data from a database) without having to reload the whole page. With AJAX web application can send data to and retrieve data from a server asynchronously (In the background) without interfering with the display and behavior of the existing page. Data can be retrieved using XmlHttpRequest object. AJAX uses a group of technologies such as JavaScript, XML as well as HTML, CSS, XHTML also. JavaScript is mainly used to dynamically display and to allow the user to interact with the information presented (JavaScript and XmlHttpRequest object provide a method for exchanging data asynchronously between browser and server to avoid full page reloads) AJAX can be used to make RIA (Rich Internet Application) technologies. AJAX is a web browser technology independent of web server software. AJAX Is Based On Open Standards: Browser based presentation using HTML and CSS. Data stored in XML format and fetched from the server. Data fetches using XmlHttpRequest objects in the browser. JavaScript to make everything happen (Populating dynamically data)  Prerequisites Of AJAX: HTML / CSS XHTML JavaScript / DOM  How AJAX Works: When HTML page event occurred, it is served by a proxy component. In the most recent AJAX solutions, the proxy component is based on XMLHttpRequest object. The XMLHttpRequest object sends a regular HTTP request and waits for it to be fully served. When the response data is ready, the proxy invokes a user defined JavaScript call back function to refresh any portion of the page that needs updating.  The AJAX Core Engine: The AJAX is not a particular technology it refers to a number of client features and related development techniques that make web applications look like desktop applications. AJAX does not require any plug-in. Virtually any browser released in the past five to six years can serve as great host for AJAX based applications because these all browsers have support for XMLHttpRequest object. When user makes an initial request and in response the page with the AJAX engine is loaded, there after the user sends all requests to the AJAX engine through JavaScript call back function, while the AJAX engine forwards request to the server, parses the response, and displays the HTML in the browser. XMLHttpRequest Object: The XMLHttpRequest object originally introduced with Internet Explorer with 5.0. It is an internal object that the browser publishes to its scripting engine. This object allows script code to send HTTTRequest and handle their response. The XMLHttpRequest object created by Microsoft and adopted soon thereafter by Mozilla. (This object is supported by majority of web browser today in the real world) AJAX Browser Support: All the available browsers cannot support AJAX. These are the following major browsers with support AJAX: Mozilla Firefox 1.0 and above Netscape version 7.1 and above Apple Safari 1.2 and above Microsoft Internet Explorer 5.0 and above Opera 7.6 and above. Note: When we are saying that browser does not support AJAX, it means the browser does not support creation of JavaScript object that is “XMLHttpRequest Object”. AJAX can run in on type of common browsers but there is a conflict in older (Such as IE5, IE6) and newer browsers (Such as Mozilla, Netscape, IE7+, Chrome, Safari, Opera etc). So in order to avoid this problem, we must create an object of XMLHttpRequest based on different browsers. For new browsers: var xmlhttp; xmlhttp=new XMLHttpRequest(); For older browsers: var xmlhttp; xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”); The XMLHttpRequest Object Provides Following Properties And Methods: Properties: ready State: This property returns values that indicate a current state of the object. These values from 0 to 4 during a request cycle: 0: The request is not initialised. 1: The request has been setup. (Connection established) 2: The request has been sent. (Request received) 3: The request is in process. (Request processing) 4: The request is completed. (Finished and response is ready) status: This property provides status code of the response from the server. 200: Ok 404: Page not found statusText: This property returns status message as a string. (e.g. “Page not found” or “Ok”) onreadystatechange: This property required event handler that fires when the state of the request object change. (Callback method assigned via this attribute) responseText: It holds the response data as a string of characters from the server. responseXML: It holds the response data as XML data from the server. Methods: open(mode, url, boolean): mode: Type of request either using GET or POST. url: The location of the file. Boolean: true (asynchronous), or false (synchronous). Send(“data”): This method is used to sends an HTTP request to the server and receives response. When we use to make request using GET command, then send method should be used with null parameter because data to be send via QueryString. When we used to make a request using POST command, then data to be send using send method only with specified parameter.  Readystate Property Values Of XMLHttpRequest Object To Be Used In Following Sequence: ReadyState=0: After you have created the XMLHttpRequest object but before the open() method. ReadyState=1: After you have called the open() method but the send(). ReadyState=2: After we have called the send(). ReadyState=3: After the browser has established a communication with the server but before the server has completed the response. ReadyState=4: After the request has been completed and the response data have been completely received from the server.  These Are The Following Steps Which We Follow While Writing AJAX Program: A client event occurs. An XMLHttpRequest object is created. The XMLHttpRequest object is configured. The XMLHttpRequest object makes an asynchronous request. Web server returns the result containing text or XML document. The XMLHttpRequest object calls the callback() function and the HTML DOM is updated.

c programming practice questions

c programming practice questions

What is the output of the following code? 

1.

#include<stdio.h>

main()

{

int i;

for(i=0;i<5;i++)

{

static int a=0;

int b=0;

a++;

b++;

printf(“\na=%d”,a);

printf(“,b=%d”,b);

}

return 0;

}

Ans:

a=1

b=1

a=2

b=1

a=3

b=1

a=4

b=1

a=5

b=1

2.

#include<stdio.h>

main()

{

static int s;

++s;

printf(“\n%d”,s);

if(s<=3)

main();

printf(“\n%d”,s);

return 0;

}

Ans: 1 2 3 4 4 4 4 4

3.

#include<stdio.h>

extern int a;

main()

{

printf(“\na=%d”,a);

return 0;

}

Ans: Linking Error undefined symbol _a

4.

#include<stdio.h>

int a;

main()

{

printf(“\n a = %d”,a);

return 0;

}

Ans: a=0

5.

#include<stdio.h>

extern int a;

main()

{

printf(“\n a = %d”,a);

return 0;

}int a;

Ans: a=0

6.

#include<stdio.h>

extern int a;

main()

{

printf(“\n a = %d”,a);

return 0;

}

int a=5;

Ans: a=5

7.

#include<stdio.h>

extern int a=5;

main()

{

void fun();

printf(“\n a = %d”,a);

fun();

return 0;

}

int a;

void fun()

{

printf(“\n in fun a = %d”,a);

}

Ans: a=5,a=5

8.

#include<stdio.h>

extern int a;

main()

{

void fun();

printf(“\n a = %d”,a);

fun();

return 0;

}

int a=7;

void fun()

{

printf(“\n in fun a = %d”,a);

}

Ans: a=7,a=7

9.

#include<stdio.h>

extern int a=5;

main()

{

void fun();

printf(“\n a = %d”,a);

fun();

return 0;

}

int a;

void fun()

{

printf(“\n in fun a = %d”,a);

}

Ans: a=5,a=5

10.

#include<stdio.h>

void fun(int _)

{

printf(“%d”,_);

}

main()

{

fun(23);

return 0;

}

Ans: 23

11.

#include<stdio.h>

main()

{

auto a;

register r;

static s;

extern e;

printf(“\n%d”,sizeof a);

printf(“\n%d”,sizeof r);

printf(“\n%d”,sizeof s);

printf(“\n%d”,sizeof e);

return 0;

}

Ans: 2 2 2 2

Identify the compiler error in the following code?

#include<stdio.h>

void fun(auto int _)

{

printf(“%d”,_);

}

main()

{

fun(23);

return 0;   }

Ans: Error

Identify the compiler error in the following code?

#include<stdio.h>

void fun(static int _)

{

printf(“%d”,_);

}

main()

{

fun(23);

return 0;

}

Ans: Error

Identify the compiler error in the following code?

#include<stdio.h>

void fun( extern int _)

{

printf(“%d”,_);

}

main()

{

fun(23);

return 0;

}

Ans: Error

Identify the compiler error in the following code?

#include<stdio.h>

void fun(register int _)

{

printf(“%d”,_);

}

main()

{

fun(23);

return 0;

}

Ans: 23

Identify the compiler error in the following code?

#include<stdio.h>

void fun(typedef int _)

{

printf(“%d”,_);

}

main()

{

fun(23);

return 0;

}

Ans: Error

Identify the error in the following code?
static extern

int a=5;

static int b = 6;

main()

{

printf(“\n%d”,a); printf(“\n%d”,b);

return 0;

}

Ans: 5 6
Identify the error in the following code?

#include<stdio.h>

main()

{

extern int a=5;

printf(“\n %d”,a);

return 0;

}

Ans: 5

Is it possible to declare static function in c language?

Ans: yes it become file scope function

Can we return more than one value by using return statement?

Ans: No

How to return more than one value from a function?

Ans: call by address

Can we use more than one return statement in one function?

Ans: yes

Give an example for function returning void but contains return statement?

Ans:

void abc()

{

printf(“Hello abc”);

return;

}

void main()

{

abc();

}

What is the differences between K&R C style and ANSI C style?

Ans:

K&R-C

int sum(a,b) int a; int b;

{

return (a+b);

}

ANSII-C

int sum(int a,int b)

{

return (a+b);

}

Write a small ‘c’ function to receive any number of arguments?

array program in c

/*writer array  program in c  to accept elements in two single dimension 2D array  and add them into third array */

 

# include<stdio.h>
main()
{
	int arr1[5], arr2[5], arr3[5];
	int i=0;
	printf("\n Enter elements for first array");
	for(i=0;i<=4;i++)         // First for loop to accept first array elements.
	{
		printf("\nEnter number:");
		scanf("%d",&arr1[i]);
	}
	printf("\n Enter elements for second array");
	for(i=0;i<=4;i++)    	// Second for loop to accept second array elements
	{
		printf("\nEnter number:");
		scanf("%d",&arr2[i]);
	}
	printf("\n addition stored in third array");
	for(i=0;i<=4;i++)      // Third for loop to add elements of array into third.
	{
		arr3[i]=arr1[i]+arr2[i];  // Putting added elements of arr1 and arr2 into arr3 at ith location.
		printf("\n arr3[%d]=%d ",i, arr3[i]);
	}
	getch();
}

 

write a array program in c to add and subtract two 3X3 matrices

# include<stdio.h>
main()
{
	int arr1[3][3], arr2[3][3];
	int arradd[3][3], arrsub[3][3];
	int i=0,j=0;
	clrscr();
	printf("\n Enter elements of first array\n");
	for(i=0;i<=1;i++)
	{
		printf("\n");
		for(j=0;j<=2;j++)
		{
			printf("Enter arr[%d][%d]:\t", i,j);
			scanf("%d", &arr1[i][j]); // Accepting array elements for first array arr1.
		}
	}
	printf("\n Enter elements of second array\n");
	for(i=0;i<=2;i++)
	{
		printf("\n");
		for(j=0;j<=2;j++)	 	// Accepting array elements for second array arr2.
		{
			printf("Enter arr[%d][%d]:\t", i,j);
			scanf("%d", &arr2[i][j]);
		}
	}
	for(i=0;i<=2;i++)
	{
		for(j=0;j<=2;j++)
		{
			arradd[i][j]=arr1[i][j]+arr2[i][j];	

			arrsub[i][j]=arr1[i][j]-arr2[i][j];	
		}
	}
	printf("\n Addition of two matrices\n\n");
	for(i=0;i<=2;i++)
	{
		for(j=0;j<=2;j++)
		{
			printf("arradd[%d[%d]=%d\t", i, j, arradd[i][j]); 	
		}
		printf("\n");
	}
	printf("\n Subtraction of two matrices\n\n");     
	for(i=0;i<=2;i++)
	{
		for(j=0;j<=2;j++)
		{
			printf("arradd[%d[%d]=%d\t",i,j,arrsub[i][j]);   	
		}
		printf("\n");
	}
	getch();
}