getting wrong ans

giving
is
it
why
wrong
wrong-answer

#1

#include<stdio.h>
#include<conio.h>
int tri(int,int,int);
int a[100][100];
int s1,s2,val;

main()
{
	int n,m,i,j,sum,k;
	scanf("%d",&m);
	for(k=1;k<=m;k++)
	{
		scanf("%d",&n);

		for(i=0;i<n;i++)
		{
			for(j=0;j<=i;j++)
			scanf("%d",&a*[j]);
			printf("

");

		}
sum=tri(0,0,n);
printf("%d

",sum);
}
getch();

}

int tri(int i,int j,int n)
{
if(i>=(n-1))
{
val= a*[j];}
else
{
	s1=a*[j]+tri(i+1,j,n);
	s2=a*[j]+tri(i+1,j+1,n);
if(s1>s2)
val=s1;
  val=s2;
  } 
return val;
	
}

#2

Since you have not specified which question this code is for, let’s assume it’s for Life,the Universe and Everything. Now in this question you have to print all numbers until you encounter the number 42 but you are just doing some random operations on a 2D array which is difficult to understand !!! That’s why WA.

Ok on a serious note Please give the question link and (hopefully) a more commented code and we will be glad to help. I tried finding the question from your profile but you have not solved anything for 2 months so it was no help!


#3

C programming language provides a data structure called the array, which can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. and also to make use of array you need to put a for loop or any loop and to give its body you need to put braces {} in the first image the braces is missing


#4

he above statement will take 10th element from the array and assign the value to salary variable. Following is an example which will use all the above mentioned three concepts viz. declaration, assignment and accessing arrays:

#include <stdio.h>

int main ()
{
int n[ 10 ]; /* n is an array of 10 integers */
int i,j;

/* initialize elements of array n to 0 /
for ( i = 0; i < 10; i++ )
{
n[ i ] = i + 100; /
set element at location i to i + 100 */
}

/* output each array element’s value */
for (j = 0; j < 10; j++ )
{
printf("Element[%d] = %d
", j, n[j] );
}

return 0;
}
When the above code is compiled and executed, it produces the following result:

Element[0] = 100
Element[1] = 101
Element[2] = 102
Element[3] = 103
Element[4] = 104
Element[5] = 105
Element[6] = 106
Element[7] = 107
Element[8] = 108
Element[9] = 109


to pass a value in a function … you need to use some formal variables which are in main() function for eg
main()
{

func(int a, int b)
}
int func (int x,int y)
{

so here when the calculation in your self defined function gets over the value of x which is for function only which is considered as ‘a’ variable in main()
gets transferred to a

means…
a=x x value goes to a after calculation

b=y;
same thing … now check your program and read a C book again