Sunday, August 2, 2009

C language help, I have this much of my code i just cant get the last part. please help?

a) Declare an array of 25 integers.





b) Write a line of C code that will print out the value of the 10th item in the array you declared in a).





c) Write C code that will print out every item in the array, in its order in the array (i.e. by index number), in 5 lines of 5 items each








a)


#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


void main()


{


int arr[25];





b)


clrscr();


//assign value to 10th item as


arr[10]=25;


printf("%d",arr[10]);


getch();


}





c)

C language help, I have this much of my code i just cant get the last part. please help?
#include%26lt;stdio.h%26gt;


//#include%26lt;conio.h%26gt;


int main()


{


int arr[25];


for(int i=0 ; i%26lt;25;i++)


arr[i]=0;





//clrscr();


//assign value to 10th item as


arr[10]=25;


printf("%d",arr[10]);


//getch();


for (int i=1 ;i%26lt;=5;i++){


for (int j= 1; j%26lt;=5;j++){


printf("%d\t", arr[i*j-1]);


}


printf("\n");


}


return 0;


}


No comments:

Post a Comment