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

Contrast OOP and SOA. What are tenets of each?

1 Answers   Siebel Systems, Wipro,


What are the access specifiers avaible in c++?

4 Answers  


Whatis the difference between oop and object based language

3 Answers  


any one please tell me the purpose of operator overloading

0 Answers   Amazon,


WHAT'S THE OOPS BASIC OOPS CONCEPTS IN DOTNET

1 Answers  


What is a class?

32 Answers   Infosys, TCS, Thylak,


What is virtual class and friend class?

5 Answers   IBS, Intel, Wipro,


what is the use of mutable key word

3 Answers   HCL,


Write a program to multiply 3x3 matrics

1 Answers  


What normal C constructs work differently in C++?

2 Answers  


create a c++ program that will ask 10 numbers and display their sum using array.

1 Answers  


Pls...could any one tell me that whether we can access the public data memeber of a class from another class with in the same program. Awaiting for your response Thanku

4 Answers  


Categories