write a c++ code of diagonal matrix.

Answers were Sorted based on User's Feedback



write a c++ code of diagonal matrix. ..

Answer / senthil.k,arasur

void main()
{
int a,b,c;
cout<<"Diagonal matrix";
for(a=1;a<=3;a++)
{
for(b=1;b<=3;b++)
{
c=1;
if(c==b)
{
cout<<c;
}
else
{
cout<<"0";
}
}
c++;
cout<<"\n";
}
}
output:

1 0 0
0 2 0
0 0 3

Is This Answer Correct ?    38 Yes 52 No

write a c++ code of diagonal matrix. ..

Answer / md.ekramul kabir

#include<stdio.h>


void main(void)
{
int row=0,column=0;

int data[4][4];

for(row=0;row<=3;row++)
{

for(column=0;column<=3;column++)
{

scanf("%d",&data[row][column]);
}
}



printf("\nYour Matrix is : \n");


for(row=0;row<=3;row++)
{

for(column=0;column<=3;column++)
{

printf("%d\t",data[row][column]);
}

printf("\n");
}

}

Is This Answer Correct ?    13 Yes 30 No

Post New Answer

More OOPS Interview Questions

I hv a same function name,arguments in both base class and dervied class, but the return type is different. Can we call this as a function overloading? Explain?

3 Answers  


how to find the largest of given numbers in an array

2 Answers  


what is polymorpsim? what are its types?

8 Answers  


In what situation factory design patterns,DAO design patterns,singleton design patterns should be applied.?

2 Answers  


What is and I oop mean?

0 Answers  






what is abstract class ? when is used in real time ? give a exp

5 Answers  


What do you mean by inheritance?

0 Answers   IBS,


what type of questions

0 Answers   IBM,


1. Strong name 2. how to prevent a class from being inherited 3. delegates 4. default modifier for interface 5. default modifier for class 6. base class for exception 7. diff bet trigger and view in sql 8. how to exchange values from one page to another page 9. can multiple catch block ll be executed at same time 10. can u store different data types in an array & array list 11. when we ll use trigger 12. try,catch,finally usage

2 Answers  


what is the drawback of classical methods in oops?

0 Answers  


What is byval and byref? What are differences between them?

0 Answers   HCL, Wipro,


program for insertion ,deletion,sorting in double link list

0 Answers  


Categories