473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Why my matrix array will stop working when I compile it??.

Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. #include<iomanip>
  3. using namespace std;
  4. int main(){
  5.     int a,b;
  6.     int Rowsize , Colsize ;
  7.     int A[Rowsize][Colsize];
  8.  
  9.     cout<<"Enter number of Row: ";
  10.     cin>>a;
  11.     Rowsize=a;
  12.     cout<<"Enter number of Colums ";
  13.     cin>>b;
  14.     Colsize=b;
  15.  
  16.     for(int Row = 0; Row < Rowsize; Row++)
  17.          for(int Col=0;Col<Colsize;Col++)
  18.     {
  19.                                 cout<<"\nEnter A [ "<<Row
  20.                                     <<"][" << Col <<"]: ";
  21.                                     cin>> A[Row][Col];
  22.                                     }
  23.  
  24.     cout<<"\nContents of matrix A:\n";
  25.     for(int Row= 0;Row < Rowsize; Row++)
  26.     {
  27.            for (int Col = 0; Col < Colsize;Col++)
  28.            cout<< setw(4) << A[Row][Col];
  29.            cout<< endl;
  30. }
  31. system("pause");
  32. return 0;
  33. }
Oct 8 '14 #1
1 1155
Banfa
9,065 Expert Mod 8TB
You need to give us more information when you post a question.
  • Do you mean it doesn't compile or the compiler produces errors or warnings? Then post the compiler output.
  • Do you mean it compiled (possibly with warnings)? Then if warns are produced post them otherwise post the output of your code when run.
  • Post something other than just your code to let us know what is happening, a detailed explaination of what is happening.

I notice that at line 6 you declare Rowsize and Colsize without initialising them, then at line 7 you declare the array A using Rowsize and Colsize as array sizes. This is an error, you have no idea what size the array A will be, anything from 0 to sqr(MAX_INT) including a lot of negative values which are just undefined behaviour.

Try moving the declaration of A to a point in the code after a value has been assigned to Rowsize and Colsize.
Oct 8 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Dave Smithz | last post by:
Hi there, A PHP application I built has a section which lists a number of members to a club whose names each appear with a check box beside them that can be ticked. These check boxes are part...
2
by: Adlai Stevenson | last post by:
Ok, the good news is the last kernel upgrade made bzflag stop working. The bad news is that mplayer, ogle and real player stopped working ! Is anybody in a similar boat? I am using Suse 9.1...
0
by: Adrian Stovold | last post by:
I've written an ASP.NET application in VB.NET. It works fine on all Windows platforms and browsers, but there's a problem on the Mac version of IE (v5.1.5) running on Mac OS 9.2. I can reproduce...
3
by: prakashsha | last post by:
HI, I've an asp.net page which has a button. On click of the button the program queries the database and gets the result and displays the same.Now assume that my program takes 2 minutes to get the...
7
by: z f | last post by:
Hi, i have a vb.net web application that uses validators. on my dev machine (Xp pro) it works fine. on the hosting machine (win2003) the validator (client side and server side ) stop working....
1
by: rebellion | last post by:
write a c++ program that will continuously accept a number. the loop will stop if the user enter a number which is less of equal than the previous. ex. if i input 2 then my next input is 4 ...
3
by: lds | last post by:
On our server we have both applications that have been migrated to use v2.0 of the framework as well as apps that have not yet been migrated and still use 1.1. When I tried to deploy my v2.0 app...
4
by: Adam Tippelt | last post by:
Situation: I'm using a continuous form to display a lot of information stored in a datasheet. I'm using the form because it allows me to display multiple rows of information per 'record' which is...
1
by: earthempire | last post by:
I'm a student now learning struct with array turbo c++ 4.5 and it crashed when compile this code no error message just crash. is the code wrong or anything please help. #include<stdio.h>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.