ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
write a program to print sum of each row of a 2D array.
 Question Submitted By :: Priyanka
I also faced this Question!!     Rank Answer Posted By  
 
  Re: write a program to print sum of each row of a 2D array.
Answer
# 1
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 ?    2 Yes 3 No
Poornima
 
  Re: write a program to print sum of each row of a 2D array.
Answer
# 2
first ordinary logic.
                      LOGIC 1
#include<stdio.h>
#include<conio.h>
void main()
{
int a[50][50],k,row,column;
printf("enter the number of rows and columns of 2D array :");
scanf("%d%d",&row,&column);
for(int i=0;i<row;i++)
{
for(int q=0;q<column;q++)
{
scanf("%d",&a[i][q]);
}
}
for(i=0;i<row;i++)
{
k=0;
for(q=0;q<column;q++)
{
k=k+a[i][q];
}
printf("%d\n",k);
}
getch();
}
 
Is This Answer Correct ?    2 Yes 3 No
Vignesh1988i
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
How can I prevent other programmers from violating encapsulation by seeing the private parts of my class?  1
write an algorithm to get a sentence and reverse it in the following format: input : I am here opuput: Here Am I note: first letter of every word is capiatlised  2
write a c program to find biggest of 3 number without relational operator? Wipro2
helllo sir give me some information of the basic information the c as printf ,scanf , %d ,%f and why is the main use of these.  3
write a C code to reverse a string using a recursive function, without swapping or using an extra memory. Motorola2
a number is perfect if it is equal to the sum of its proper divisor.. 6 is perfect number coz its proper divisors are 1,2 and three.. and 1+2+3=6... a number is deficient if the sum of its proper divisor is less than the number.. sample: 8 is deficient, coz its proper divisors are 1,2 and 4, and 1+2+4=7. abundant number, if the sum of its proper divisor is greater than the number.. sample..12 is abundant coz 1+2+3+4+6=16 which is geater than 12. now write a program that prompts the user for a number, then determines whether the number is perfect,deficient and abundant..  1
What is the difference between big endian form and little endian form? write a code to convert big endian form to little endian and vice versa.. Aricent4
how does printf function work  1
#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x=%d",sqr(x+1)); } What is the value of x? Oracle13
what is link list?  2
What's the difference between a linked list and an array?  11
difference between memcpy and strcpy  1
52.write a “Hello World” program in “c” without using a semicolon? 53.Give a method to count the number of ones in a 32 bit number? 54.write a program that print itself even if the source file is deleted? 55.Given an unsigned integer, find if the number is power of 2?  6
what is the use of a array in c  4
Toggle nth bit in a given integer - num Qualcomm2
what is diff b/w huge & far & near pointer?? HCL1
how to find a 5th bit is set in c program IBM3
how many times does the loop iterated ? for (i=0;i=10;i+=2) printf("Hi\n"); TCS7
Program to write some contents into a file using file operations with proper error messages.  1
convert 0.9375 to binary CTS1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com