SlideShare a Scribd company logo
1 of 3
C++ help!! Im not familiar with how to save/ read file so that the program works so i'd realllyy
appreaciate it if you wrote down the steps along with the code!
Solution
#include<fstream>
#include<iostream>
using namespace std;
int main()
{
int i,j;
int a[4][4],trans[4][4];
ifstream infile("Matrix_01.txt");//change the file name to test for matrix_02 it must be in the
same folder
if(!infile)
{
cout<<"Cannot open file1. ";
return
}
for(i=0;i<4;i++)//reads from the file
{
for(j=0;j<4;j++)
{
infile1>>a[i][j];
}
}
cout<<"Matrix:"<<endl;//displays the matrix
for(i=0; i<4; ++i)
{
for(j=0; j<4; ++j)
{
cout << " " << a[i][j];
}
cout<<endl;
}
cout<<"Transpose:"<<endl;
for(i=0; i<4; ++i)//calculates transpose
for(j=0; j<4; ++j)
{
trans[j][i]=a[i][j];
}
for(i=0; i<4; ++i)//prints transpose
{
for(j=0; j<4; ++j)
{
cout << " " << trans[i][j];
}
cout<<endl;
}
cout<<"Upper Triangle: ";
for (int i = 0; i < 4;i++)//prints upper traingle
{
for (int j = 0; j < (4- i); j++)
{
cout << a[i][j] << " ";
}
cout << " ";
}
cout<<"Lower Triangle: ";
for(i=0;i<4;i++)//prints lower triangle
{
for(j=0;j<=i;j++)
{
cout<<a[i][j]<<" ";
}
cout<<" ";
}
for ( i = 0 ; i < 4 ; i++ )//checks for transpose
{
for ( j = 0 ; j < 4 ; j++ )
{
if ( a[i][j] != trans[i][j] )
break;
}
if ( j != 4 )
break;
}
if ( i == 4 )
cout<<"It is a Symmetric matrix. ";
else
cout<<"It is not a Symmetric matrix. ";
}

More Related Content

Similar to C++ help!! Im not familiar with how to save- read file so that the pro.docx

Cs1123 10 file operations
Cs1123 10 file operationsCs1123 10 file operations
Cs1123 10 file operationsTAlha MAlik
 
Question 1 has already been posted to Chegg and I am waiting for the.pdf
Question 1 has already been posted to Chegg and I am waiting for the.pdfQuestion 1 has already been posted to Chegg and I am waiting for the.pdf
Question 1 has already been posted to Chegg and I am waiting for the.pdfanjandavid
 
File & Exception Handling in C++.pptx
File & Exception Handling in C++.pptxFile & Exception Handling in C++.pptx
File & Exception Handling in C++.pptxRutujaTandalwade
 
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docxtheodorelove43763
 
In C program, how to write two short programs one which hides a sho.pdf
In C program, how to write two short programs one which hides a sho.pdfIn C program, how to write two short programs one which hides a sho.pdf
In C program, how to write two short programs one which hides a sho.pdfboothlynntur11512
 
C-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdfC-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdfherminaherman
 
Chpater29 operation-on-file
Chpater29 operation-on-fileChpater29 operation-on-file
Chpater29 operation-on-fileDeepak Singh
 
Unit5 (2)
Unit5 (2)Unit5 (2)
Unit5 (2)mrecedu
 
streams and files
 streams and files streams and files
streams and filesMariam Butt
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfSANDEEPARIHANT
 

Similar to C++ help!! Im not familiar with how to save- read file so that the pro.docx (20)

Unit5 C
Unit5 C Unit5 C
Unit5 C
 
Cs1123 10 file operations
Cs1123 10 file operationsCs1123 10 file operations
Cs1123 10 file operations
 
java programming
java programmingjava programming
java programming
 
Question 1 has already been posted to Chegg and I am waiting for the.pdf
Question 1 has already been posted to Chegg and I am waiting for the.pdfQuestion 1 has already been posted to Chegg and I am waiting for the.pdf
Question 1 has already been posted to Chegg and I am waiting for the.pdf
 
File & Exception Handling in C++.pptx
File & Exception Handling in C++.pptxFile & Exception Handling in C++.pptx
File & Exception Handling in C++.pptx
 
slides3_077.ppt
slides3_077.pptslides3_077.ppt
slides3_077.ppt
 
file.ppt
file.pptfile.ppt
file.ppt
 
C++ Project 6
C++ Project 6C++ Project 6
C++ Project 6
 
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docx
 
In C program, how to write two short programs one which hides a sho.pdf
In C program, how to write two short programs one which hides a sho.pdfIn C program, how to write two short programs one which hides a sho.pdf
In C program, how to write two short programs one which hides a sho.pdf
 
C-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdfC-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdf
 
Chpater29 operation-on-file
Chpater29 operation-on-fileChpater29 operation-on-file
Chpater29 operation-on-file
 
C Language Unit-5
C Language Unit-5C Language Unit-5
C Language Unit-5
 
File Organization & processing Mid term summer 2014 - modelanswer
File Organization & processing Mid term summer 2014 - modelanswerFile Organization & processing Mid term summer 2014 - modelanswer
File Organization & processing Mid term summer 2014 - modelanswer
 
Unit5 (2)
Unit5 (2)Unit5 (2)
Unit5 (2)
 
streams and files
 streams and files streams and files
streams and files
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdf
 
File operations
File operationsFile operations
File operations
 
C
CC
C
 
Programming in C
Programming in CProgramming in C
Programming in C
 

More from marions12

C++ program Revising the Array-Based List ADT Given the data structure.docx
C++ program Revising the Array-Based List ADT Given the data structure.docxC++ program Revising the Array-Based List ADT Given the data structure.docx
C++ program Revising the Array-Based List ADT Given the data structure.docxmarions12
 
c++ computer architecture and memory What is fragmentation- Briefly ex.docx
c++ computer architecture and memory What is fragmentation- Briefly ex.docxc++ computer architecture and memory What is fragmentation- Briefly ex.docx
c++ computer architecture and memory What is fragmentation- Briefly ex.docxmarions12
 
C# There are two schools of thought on the use of implicitly typed var.docx
C# There are two schools of thought on the use of implicitly typed var.docxC# There are two schools of thought on the use of implicitly typed var.docx
C# There are two schools of thought on the use of implicitly typed var.docxmarions12
 
Brief introduction of the WorldComSolutionWorldCom was started by Bill.docx
Brief introduction of the WorldComSolutionWorldCom was started by Bill.docxBrief introduction of the WorldComSolutionWorldCom was started by Bill.docx
Brief introduction of the WorldComSolutionWorldCom was started by Bill.docxmarions12
 
Brief Exercise 5-5 Crane Corporation has the following accounts includ.docx
Brief Exercise 5-5 Crane Corporation has the following accounts includ.docxBrief Exercise 5-5 Crane Corporation has the following accounts includ.docx
Brief Exercise 5-5 Crane Corporation has the following accounts includ.docxmarions12
 
Briefly describe some of the similarities and differences between U-S-.docx
Briefly describe some of the similarities and differences between U-S-.docxBriefly describe some of the similarities and differences between U-S-.docx
Briefly describe some of the similarities and differences between U-S-.docxmarions12
 
Briefly describe what the query evaluation engine performs inside a DB.docx
Briefly describe what the query evaluation engine performs inside a DB.docxBriefly describe what the query evaluation engine performs inside a DB.docx
Briefly describe what the query evaluation engine performs inside a DB.docxmarions12
 
Briefly explain the purposes of adjustments Briefly explain the purp.docx
Briefly explain the purposes of adjustments   Briefly explain the purp.docxBriefly explain the purposes of adjustments   Briefly explain the purp.docx
Briefly explain the purposes of adjustments Briefly explain the purp.docxmarions12
 
Budget Martin Corporation granted a nonqualified stock option to e.docx
Budget    Martin Corporation granted a nonqualified stock option to  e.docxBudget    Martin Corporation granted a nonqualified stock option to  e.docx
Budget Martin Corporation granted a nonqualified stock option to e.docxmarions12
 
Calculate fost of goods sold and ending inventory and analyze effect o (1).docx
Calculate fost of goods sold and ending inventory and analyze effect o (1).docxCalculate fost of goods sold and ending inventory and analyze effect o (1).docx
Calculate fost of goods sold and ending inventory and analyze effect o (1).docxmarions12
 
Calculate fost of goods sold and ending inventory and analyze effect o.docx
Calculate fost of goods sold and ending inventory and analyze effect o.docxCalculate fost of goods sold and ending inventory and analyze effect o.docx
Calculate fost of goods sold and ending inventory and analyze effect o.docxmarions12
 
Ca(OH)2 is insoluble- What is the total concentration of ions if 2M of.docx
Ca(OH)2 is insoluble- What is the total concentration of ions if 2M of.docxCa(OH)2 is insoluble- What is the total concentration of ions if 2M of.docx
Ca(OH)2 is insoluble- What is the total concentration of ions if 2M of.docxmarions12
 
c- Since BEEF hooks to Metasploit- is there any safe way to use the we.docx
c- Since BEEF hooks to Metasploit- is there any safe way to use the we.docxc- Since BEEF hooks to Metasploit- is there any safe way to use the we.docx
c- Since BEEF hooks to Metasploit- is there any safe way to use the we.docxmarions12
 
9- Fill in the following table with names or formulas- as appropriate-.docx
9- Fill in the following table with names or formulas- as appropriate-.docx9- Fill in the following table with names or formulas- as appropriate-.docx
9- Fill in the following table with names or formulas- as appropriate-.docxmarions12
 
9- A combination of sand- salt- and water is an example of a A) homoge.docx
9- A combination of sand- salt- and water is an example of a A) homoge.docx9- A combination of sand- salt- and water is an example of a A) homoge.docx
9- A combination of sand- salt- and water is an example of a A) homoge.docxmarions12
 
8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx
8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx
8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docxmarions12
 
870 The plates of a capacitor are not quite parallel- the distance bet.docx
870 The plates of a capacitor are not quite parallel- the distance bet.docx870 The plates of a capacitor are not quite parallel- the distance bet.docx
870 The plates of a capacitor are not quite parallel- the distance bet.docxmarions12
 
8- What are concurrency design patterns- Explain-Solution8) we have fi.docx
8- What are concurrency design patterns- Explain-Solution8) we have fi.docx8- What are concurrency design patterns- Explain-Solution8) we have fi.docx
8- What are concurrency design patterns- Explain-Solution8) we have fi.docxmarions12
 
8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx
8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx
8- Calculate the distance from the donor (D) to the acceptor (A) in th.docxmarions12
 
7- You want to create an SSIS package that copies data from a source t.docx
7- You want to create an SSIS package that copies data from a source t.docx7- You want to create an SSIS package that copies data from a source t.docx
7- You want to create an SSIS package that copies data from a source t.docxmarions12
 

More from marions12 (20)

C++ program Revising the Array-Based List ADT Given the data structure.docx
C++ program Revising the Array-Based List ADT Given the data structure.docxC++ program Revising the Array-Based List ADT Given the data structure.docx
C++ program Revising the Array-Based List ADT Given the data structure.docx
 
c++ computer architecture and memory What is fragmentation- Briefly ex.docx
c++ computer architecture and memory What is fragmentation- Briefly ex.docxc++ computer architecture and memory What is fragmentation- Briefly ex.docx
c++ computer architecture and memory What is fragmentation- Briefly ex.docx
 
C# There are two schools of thought on the use of implicitly typed var.docx
C# There are two schools of thought on the use of implicitly typed var.docxC# There are two schools of thought on the use of implicitly typed var.docx
C# There are two schools of thought on the use of implicitly typed var.docx
 
Brief introduction of the WorldComSolutionWorldCom was started by Bill.docx
Brief introduction of the WorldComSolutionWorldCom was started by Bill.docxBrief introduction of the WorldComSolutionWorldCom was started by Bill.docx
Brief introduction of the WorldComSolutionWorldCom was started by Bill.docx
 
Brief Exercise 5-5 Crane Corporation has the following accounts includ.docx
Brief Exercise 5-5 Crane Corporation has the following accounts includ.docxBrief Exercise 5-5 Crane Corporation has the following accounts includ.docx
Brief Exercise 5-5 Crane Corporation has the following accounts includ.docx
 
Briefly describe some of the similarities and differences between U-S-.docx
Briefly describe some of the similarities and differences between U-S-.docxBriefly describe some of the similarities and differences between U-S-.docx
Briefly describe some of the similarities and differences between U-S-.docx
 
Briefly describe what the query evaluation engine performs inside a DB.docx
Briefly describe what the query evaluation engine performs inside a DB.docxBriefly describe what the query evaluation engine performs inside a DB.docx
Briefly describe what the query evaluation engine performs inside a DB.docx
 
Briefly explain the purposes of adjustments Briefly explain the purp.docx
Briefly explain the purposes of adjustments   Briefly explain the purp.docxBriefly explain the purposes of adjustments   Briefly explain the purp.docx
Briefly explain the purposes of adjustments Briefly explain the purp.docx
 
Budget Martin Corporation granted a nonqualified stock option to e.docx
Budget    Martin Corporation granted a nonqualified stock option to  e.docxBudget    Martin Corporation granted a nonqualified stock option to  e.docx
Budget Martin Corporation granted a nonqualified stock option to e.docx
 
Calculate fost of goods sold and ending inventory and analyze effect o (1).docx
Calculate fost of goods sold and ending inventory and analyze effect o (1).docxCalculate fost of goods sold and ending inventory and analyze effect o (1).docx
Calculate fost of goods sold and ending inventory and analyze effect o (1).docx
 
Calculate fost of goods sold and ending inventory and analyze effect o.docx
Calculate fost of goods sold and ending inventory and analyze effect o.docxCalculate fost of goods sold and ending inventory and analyze effect o.docx
Calculate fost of goods sold and ending inventory and analyze effect o.docx
 
Ca(OH)2 is insoluble- What is the total concentration of ions if 2M of.docx
Ca(OH)2 is insoluble- What is the total concentration of ions if 2M of.docxCa(OH)2 is insoluble- What is the total concentration of ions if 2M of.docx
Ca(OH)2 is insoluble- What is the total concentration of ions if 2M of.docx
 
c- Since BEEF hooks to Metasploit- is there any safe way to use the we.docx
c- Since BEEF hooks to Metasploit- is there any safe way to use the we.docxc- Since BEEF hooks to Metasploit- is there any safe way to use the we.docx
c- Since BEEF hooks to Metasploit- is there any safe way to use the we.docx
 
9- Fill in the following table with names or formulas- as appropriate-.docx
9- Fill in the following table with names or formulas- as appropriate-.docx9- Fill in the following table with names or formulas- as appropriate-.docx
9- Fill in the following table with names or formulas- as appropriate-.docx
 
9- A combination of sand- salt- and water is an example of a A) homoge.docx
9- A combination of sand- salt- and water is an example of a A) homoge.docx9- A combination of sand- salt- and water is an example of a A) homoge.docx
9- A combination of sand- salt- and water is an example of a A) homoge.docx
 
8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx
8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx
8-6- Which of the highlighted elements in Figure P8-6 has the greatest.docx
 
870 The plates of a capacitor are not quite parallel- the distance bet.docx
870 The plates of a capacitor are not quite parallel- the distance bet.docx870 The plates of a capacitor are not quite parallel- the distance bet.docx
870 The plates of a capacitor are not quite parallel- the distance bet.docx
 
8- What are concurrency design patterns- Explain-Solution8) we have fi.docx
8- What are concurrency design patterns- Explain-Solution8) we have fi.docx8- What are concurrency design patterns- Explain-Solution8) we have fi.docx
8- What are concurrency design patterns- Explain-Solution8) we have fi.docx
 
8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx
8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx
8- Calculate the distance from the donor (D) to the acceptor (A) in th.docx
 
7- You want to create an SSIS package that copies data from a source t.docx
7- You want to create an SSIS package that copies data from a source t.docx7- You want to create an SSIS package that copies data from a source t.docx
7- You want to create an SSIS package that copies data from a source t.docx
 

Recently uploaded

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

C++ help!! Im not familiar with how to save- read file so that the pro.docx

  • 1. C++ help!! Im not familiar with how to save/ read file so that the program works so i'd realllyy appreaciate it if you wrote down the steps along with the code! Solution #include<fstream> #include<iostream> using namespace std; int main() { int i,j; int a[4][4],trans[4][4]; ifstream infile("Matrix_01.txt");//change the file name to test for matrix_02 it must be in the same folder if(!infile) { cout<<"Cannot open file1. "; return } for(i=0;i<4;i++)//reads from the file { for(j=0;j<4;j++) { infile1>>a[i][j]; } } cout<<"Matrix:"<<endl;//displays the matrix for(i=0; i<4; ++i) { for(j=0; j<4; ++j) { cout << " " << a[i][j]; } cout<<endl; }
  • 2. cout<<"Transpose:"<<endl; for(i=0; i<4; ++i)//calculates transpose for(j=0; j<4; ++j) { trans[j][i]=a[i][j]; } for(i=0; i<4; ++i)//prints transpose { for(j=0; j<4; ++j) { cout << " " << trans[i][j]; } cout<<endl; } cout<<"Upper Triangle: "; for (int i = 0; i < 4;i++)//prints upper traingle { for (int j = 0; j < (4- i); j++) { cout << a[i][j] << " "; } cout << " "; } cout<<"Lower Triangle: "; for(i=0;i<4;i++)//prints lower triangle { for(j=0;j<=i;j++) { cout<<a[i][j]<<" "; } cout<<" "; } for ( i = 0 ; i < 4 ; i++ )//checks for transpose { for ( j = 0 ; j < 4 ; j++ ) { if ( a[i][j] != trans[i][j] ) break; } if ( j != 4 ) break; } if ( i == 4 ) cout<<"It is a Symmetric matrix. ";
  • 3. else cout<<"It is not a Symmetric matrix. "; }