Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Iterative statement



Comment



" ; " after loop



Test expression



Working with switch case




Array 2_D - in small shop - there 5 salesman where each have to sall 3 products calculate ( 1 ) the total sales by each salesman and ( 2 ) total sales of each product




// AHF C PROGRAM SOLVING

//solving here 2_D   ARRAY 	programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { int man[5][3],i,j,total_sales=0,pos; // INPUT DATA pf("ENTER DATA."); for(i=0;i < 5;i++) { pf("\n"); pf("\nEnter the sales product of 3 items by salesman %d :\t",i); for(j=0;j < 3;j++) scanf("%d",&man[i][j]); } //PRINT TOTAL SALES BY EACH SALESMAN for(i=0;i < 5;i++) { total_sales=0; for(j=0;j < 3;j++) total_sales+=man[i][j]; pf("\nTotal product sales by salesman %d = %d",i,total_sales); } //TOTAL SALES OF EACH ITEMS for(i=0;i < 3;i++) { total_sales=0; for(j=0;j < 5;j++) total_sales+=man[j][i]; pf("\nTotal sales of item %d = %d",i,total_sales); } return 0; }
OUTPUT:


© 2018 - All rights reserved