Can any one help me with this code?
hi to all
please can u help me to find the problems in this program
this program will find the min element in quarter1 of square array and the max element of quarter3 and replace them
q1 , q2
q4 , q3
please can u help me to find the problems in this program
this program will find the min element in quarter1 of square array and the max element of quarter3 and replace them
q1 , q2
q4 , q3
#includemain() { int a[10][10],i,j,min,max,lmin,lmax,n,m ; scanf("%d",&n) ; scanf("%d",&m) ; for (i=0;i a[i][j] ) a[i][j]=min ; lmin=a[i][j] ; for(i=n/2;i
thank u
Replies
-
silverscorpionah, you seem to have messed up the program in many places. I'll indicate the mistakes. Convince yourself that they are wrong..
Lines 10,11,12 are not required. If they are executed, they'll simply assign a[n/2,m/2]
to be the minimum number, which is not true. Instead, initialise min to a high number. Similarly for lines 18,19,20. Remove them and set max to a small number, say zero at the start.
line 16: It should be min=a[j];
line 17: It should be lmin=min;
line 25: It should be max=a[j];
line 26 is not required.
there are many more. I'm posting the correct version of this program below.. Check it up. -
silverscorpion
#include
main()
{
int a[10][10],i,j,min=99,max=-99,lmin,lmax,n,m ;
scanf("%d",&n); scanf("%d",&m) ;
for (i=0;ifor (j=0;j scanf("%d",&a[j]) ;
for(i=0;ifor(j=0;j if ( min > a[j] )
min=a[j];
lmin=min;
for(i=n/2;ifor(j=m/2;j if ( max < a[j] )
max=a[j] ;
lmax=max;
for(i=0;i{
for(j=0;jprintf("%d\t",a[j] ) ;
printf("\n") ;
}
for(i=0;ifor(j=0;j if(a[j]==lmin)
a[j]=lmax;
for(i=n/2;ifor(j=m/2;j if(a[j]==lmax)
a[j]=lmin;
printf("\n\n\n") ;
for(i=0;i{
for(j=0;jprintf("%d\t",a[j] ) ;
printf("\n") ;
}
}
I've not commented the code as i'm sure you can understand it without trouble.
Cheers!!
You are reading an archived discussion.
Related Posts
hello there 😛
myself Rahul from Faridabad, Haryana. I am pursuing b.tech it, 2nd year. i have to do summer training just after the vacations going to be held after...
This group is exclusive for CEans with 500+ posts. Following are the official members of CE Silver Club -
The_Big_K
ash
gohm
shalini_goel14
raj87verma88
mayurpathak
sauravgoswami
crazyboy
durga
xheavenlyx
English-Scared...
Hello Guys,
Here i am going to Post Some Topics on that you can give the seminar..
Here i will post the some definition of seminar and some work you...
Hey all, its been quite a while since i last visited CE. The last thing i remember something about CE messenger and now i can't even find it 😔.
Please...
You want to get through a security door, where you have to enter 3 digits as password, where each digit can be any from 0 to 9. The checking mechanism...