# I wrote a c program and it arent work correctly

I've made a program to make arrays and their summations, it works but the outputs are not arranged! I wondered what is the problem ?!

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

int main() {

int numbers1,numbers2,results;
int x,y,z,a,b;
int c;

for ( x=0,y=0,z=0  ;  x<=3,y<=3,z<=3  ;  x++,y++,z++ ){
a,b=0;
printf("enter your %d number in the first array: ",x+1);
scanf("%d",&a);
printf("enter your %d number in the secod array: ",y+1);
scanf("%d",&b);

numbers1[x]= a;
numbers2[x]= b;
results[x]= a + b;
printf("============================================================");
printf("%d + %d = %d \n", numbers1[x], numbers2[x], results[x]);

}

for( c=0 ; c<=3 ; c++){

printf("%d + %d = %d \n", numbers1[c], numbers2[c], results[c]);

}

system("PAUSE");

return 0;
}

#include <conio.h>

int main() {

int numbers1,numbers2,results;
int x,y,z,a,b;
int c;

for ( x=0;x<3;x++){

printf("enter your %d number in the first array: ",x+1);
scanf("%d",&a);
printf("enter your %d number in the secod array: ",x+1);
scanf("%d",&b);

numbers1[x]= a;
numbers2[x]= b;
results[x]= a + b;
printf("============================================================");
printf("%d + %d = %d \n", numbers1[x], numbers2[x], results[x]);

}

for( c=0 ; c<3 ; c++){

printf("%d + %d = %d \n", numbers1[c], numbers2[c], results[c]);

}
}
answered Mar 4 by (140 points)
///use this one

#include <conio.h>

int main() {

int numbers1,numbers2,results;
int x,y,z,a,b;
int c;

for ( x=0;x<3;x++){

printf("enter your %d number in the first array: ",x+1);
scanf("%d",&a);
printf("enter your %d number in the secod array: ",x+1);
scanf("%d",&b);

numbers1[x]= a;
numbers2[x]= b;
results[x]= a + b;
printf("============================================================");
printf("%d + %d = %d \n", numbers1[x], numbers2[x], results[x]);

}

for( c=0 ; c<3 ; c++){

printf("%d + %d = %d \n", numbers1[c], numbers2[c], results[c]);

}
}
answered Mar 5 by (240 points)
Hint: Your arrays declaration is wrong.
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int a,b,c,i,j;
cout<<"Enter elements for the first matrix"<<endl;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
cin>>a[i][j];
}
}
cout<<"Enter elements for the second matrix"<<endl;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
cin>>b[i][j];
}
}
cout<<"The sum of the two matrix is : "<<endl;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=0;
c[i][j]=a[i][j]+b[i][j];
}
}
for(i=0;i<2;i++)
{
cout<<"\n";
for(j=0;j<2;j++)
{
cout<<c[i][j]<<"\t";
}
}
return 0;
}