Multidimensional array in c

A multinational company has hired 3 sales persons for marketing/selling its 3 different products in Kathmandu .Each sales person sells each of these products. Write a c program to read number of each product sold by all sales-persons. Calculate total sells of each item and the total sells of each sales-person . Use array

C Program source code

#include <stdio.h>
#include <conio.h>
#include <string.h>
int main()
{
 int pro[3][3],sum=0;
 int j ,i  ;
 char per[3][10]={ "first","second","third"};
 for (i=0 ; i<3 ; i++)
 {
  for(j=0 ; j<3 ; j++)
  {
      
    printf("enter number of selling of %s person %s product:" , per[i] ,per[j] );
    scanf("%d", &pro[i][j]);
       printf("\n");

  }
 }
 

  for (i=0 ; i<3 ; i++)
 { 
  for(j=0 ; j<3 ; j++)
  {
   
   sum = sum + pro[j][i];
   
  }
 printf("Total sell of %s item is:%d\n",per[i], sum);
 sum=0; 
   }
   for (i=0 ; i<3 ; i++)
 { 
  for(j=0 ; j<3 ; j++)
  {
   
   sum = sum + pro[i][j];
   
  }
 printf("Total sell of %s person is:%d\n",per[i], sum);
 sum=0; 
   } 
getch();
return(0); 
}



You can Browse related article below for more information and program code related to string function

 Does above is helpful , Post you views in comment

DO NOT MISS OTHER C PROGRAMMING TUTORIAL

* indicates required


Multidimensional array in c

Comments

Popular posts from this blog

Copy Constructor

Print pattern in c - explore new perspectives in pattern printing

C program to check if the supplied year is leap year or not.