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
Why doesnt long int work?
Write a program to know whether the input number is an armstrong number.
What standard functions are available to manipulate strings?
What is function and its example?
Write a program to check whether a number is prime or not using c?
How many keywords (reserve words) are in c?
int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer
What are the salient features of c languages?
Hi can anyone tell what is a start up code?
What does d mean?
a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list
Explain what is the best way to comment out a section of code that contains comments?
write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...
write a c program to calculate sum of digits till it reduces to a single digit using recursion
what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values