Addition of array elements, C/C++ Programming

Addition of array elements:

#define rows 3

#define cols 3

void main()

{

                int i=0,j=0,sum=0;

                int arr[rows][cols];

                for (i=0; i<=rows-1; i++)

                                for(j=0;j<=cols-1;j++)

                                {

                                                printf("Enter elements (%d,%d)\n",(i+1),(j+1));

 

                                                scanf("%d",&arr[i][j]);

                                }

                for (i=0; i<=rows-1; i++)

                {

                                printf("\t");       

                                for(j=0;j<3;j++)

                                                {

                                                printf("%3d  ",arr[i][j]);

                                                }

                                                printf("\n");

                }

                printf("\n Sum of matrix\n");

                for(i=0;i<=rows-1;i++)

                                for(j=0;j<=cols-1;j++)

                                {

 

                                                sum=sum+arr[i][j];

                                }

printf("\tsum=%d\n",sum);                       

}

 

Posted Date: 9/29/2012 7:22:30 AM | Location : United States







Related Discussions:- Addition of array elements, Assignment Help, Ask Question on Addition of array elements, Get Answer, Expert's Help, Addition of array elements Discussions

Write discussion on Addition of array elements
Your posts are moderated
Related Questions
Problem 1 What is the difference between function declaration and function definition? 2 Write a recursive function to find sum of even numbers from 2 to 10. 3 List some

write a promgram using object oriented peramid

Project Description: We are seeking online invoice OCR solution. That will help us to automate accounts payable function. User should be able to use the offered pdf file or s

Ask question # Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particu

Luminous Jewels - The Polishing Game Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various lum

A: this is a procedure during exception handling while the destructor is called for all local objects in the stack among the place where the exception was thrown & where this is ca

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Project Description: My project is about telephone billing system. This project was my project in my college life. The project is quite easy, i needed C++ programming language..

PROCEDUAL PROGRAMMING INTRODUCTION

ABC Car Dealership needs your help to update the ordering system. This car dealer is selling four types of vehicles: Sedan, Truck, SUV, and mini Van. And each type of vehicle can h