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

What is the purpose of polymorphism?

0 Answers  


What is advantage of inheritance?

0 Answers  


What are different oops concepts?

0 Answers  


What's the full form of STL?

2 Answers  


What are two types of polymorphism?

0 Answers  


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  


Write pseudo code for push in a stack?

2 Answers   emc2,


How do you explain polymorphism?

0 Answers  


is there any choice in opting subjects like 4 out of 7

0 Answers  


i^=j; j^=i; i^=j; value of i,j

1 Answers  


What is a friend function & its advantage?

1 Answers   MIT,


Will I be able to get a picture in D drive to the c++ program? If so, help me out?

0 Answers  


Categories