write a program to print sum of each row of a 2D array.
Answer Posted / poornima
int b[20];
int main()
{
int a[20][20],row,col,i,j;
printf("Row & col : ");
scanf("%d %d",&row,&col);
printf("\nEnter elements : ");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\nElements are\n");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
b[i] +=a[i][j];
}
}
for(i=0;i<row;i++)
{
printf("Sum of row %d is %d\n",(i+1),b[i]);
}
return 0;
}
| Is This Answer Correct ? | 43 Yes | 35 No |
Post New Answer View All Answers
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
Which is better pointer or array?
What does s c mean in text?
Why main is used in c?
Explain how can I write functions that take a variable number of arguments?
Explain why can’t constant values be used to define an array’s initial size?
What does struct node * mean?
What is the difference between memcpy and memmove?
what is the role you expect in software industry?
What is conio h in c?
The program will first compute the tax you owe based on your income. User is prompted to enter income. Program will compute the total amount of tax owed based on the following: Income Tax 0 - $45,000 = 0.15 x income $45,001 - $90,000 = 6750 + 0.20 x (income – 45000) $90,001 - $140,000 = 15750 + 0.26 x (income – 90000) $140,001 - $200,000 = 28750 + 0.29 x (income – 140000) Greater than $200,000 = 46150 + 0.33 x (income – 200000) Dollar amounts should be in dollars and cents (float point numbers with two decimals shown). Tax is displayed on the screen.
What is the difference between #include and #include 'file' ?
What are the valid places to have keyword “break”?
How are Structure passing and returning implemented by the complier?
what will be maximum number of comparisons when number of elements are given?