read array
Posted Date Unknown Johnson Augustine 4 Comments

In C language i have a statement to read and print two dimen matrix using array .

 for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
// A is an integer array
//no is also decl as int

printf("Enter number");
int a[i][j]=scanf("%d",&no) 
printf("%d",a[i][j]);

}
printf("ln");
}

and i given input to the program in two way first i given values seperated by space like 10 20 30 40  and get the output in a matrix form

in second case i given input by presssing enter each time

10
20
30
40
and got out put in 
10
20
30
40

My doubt is that what process is happened in first case ? The compiler is using any stack or any data structure ?

Why the printf statement works only ones or not ?  , the reason for getting matrix form in first case .  ?

thanks in-advance

See All Responses Below...
Author
Message Rating
Posted on: 23/11/2012
What value is returning for this expression?

int a[i][j]=scanf("%d",&no) ;
printf("%d",a[i][j]);

Can you explain what your intention here?

Tom
Posted on: 24/11/2012
Hi,

 Don't stick with the code , i just try to explain what i am try to do ,[Ignore syntax ]

I just try to know the difference between inputing values in to a program  . in the following way

1) type value and press enter
2) Input all values separated by a space

How the compiler interrupt these values , thats only ,Matrix and somthing somthing is just for an example 


Share this page across other social networking sites



Posted on: 24/11/2012

Hi,

 From my knowledge it is handled by a stream buffer , and interpreted by  Language compiler

is it right? 
Posted on: 24/11/2012
Yes I think the implementation is also compiler dependent. I had observed different behavior for the same scenario like this for Turbo C++ and Visual C++ compilers..

Tom

Share this page across other social networking sites



Please Login to Post Your Comments
Name (Max. 100 characters)
Please post your comments here
Select Language
Comments
   Design  HTML
Attach File(Max. Size: 2 MB)
A few simple rules when posting your Comments,
  1. Please post only answers relevant to the topic of discussion.
  2. Please dont misuse this site or do not be abusive, offensive, inappropriate,harass anyone on the boards or post ads or spam. Doing so will delete your inappropriate messages and will block or delete your account on this site. 

TekTipsDownload
GateExam
Academic Projects
TekTipsExperts



 
Site optimized for IE7, 1280 X 768 and above. Copyright © 2010 - 2018 KTS InfoTech
Site Developed Using KTS WebCloud