need help with some problems, please help
Having trouble with these 3 problems, one problem is figuring out what the output is
1.
1 2 3 4 5 6 7 8 9

int x =5, y;
while (x >= 2) {
y=1;
while (y <= x) {
printf ( ā * ā );
y++; }
x;
printf ( ā\nā ); }

after going through it, I think it outputs
*****
****
***
**
*
2. Trying to write a function for this main program
1 2 3 4 5

void xyz ( int [ ], int );
int main ( ) {
int A [10 ] = {1,2, . . . ., 10}; int n; \\ n refers to 10 elements.
xyz ( A, n );
return 0; }

Here is what i got
1 2 3 4 5 6 7

void xyz(inta[], int n){
int total=0;
int i;
for (i=0;i< n; i++){
total = a[i]
}
}

3. write main program for function
1 2 3 4 5 6 7

int xyz ( int x, int y, int y ) {
int a, b;
a = x + y + z:
b = a/3;
return b; }

here is what I've written
1 2 3 4 5 6

int xyz (int x int y int z)
int x y z;
int main()
{
printf("enter values for x y z");
scanf("%d %d %d", &x, &y, &z);

not sure what to do after this.
Last edited on
figured out number one
*****
****
***
**
still having trouble with other two
for number four would i add at the end?
total=total+x+y+z;
count=count+1;
of course declaring total and count in the beginning.
Topic archived. No new replies allowed.