Probably that is because you try to use a variable called mark at line 9 and 10:
1 2
scanf("%d", &mark[a]);
int tot=mark[1]+mark[2]+mark[3];
But you don't create a variable called mark before you try to use it, so for the compiler the variable mark is indeed undefined.
You should either remove these lines or create an array of integers called mark somewhere before line 7.
please correct the code someone
i want to take output from user
for example
subject 1: 78 etc
and add them all and give output its sum.
using array and loops
I don't know C but in C++ you can use dynamic arrays with runtime size to do something like this. run it on cpp.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include<iostream>
int main()
{
int sum=0;
int ENTRY;
std::cout<<"Enter how many numbers you want to add: " ;
std::cin>>ENTRY;
int *input= newint[ENTRY];
for(int i=0; i<ENTRY; ++i)
{
std::cout<<"Enter entry no. "<<i+1<<"\n";
std::cin>>input[i];
sum+=input[i];
}
std::cout<<"Sum = "<<sum<<"\n";
delete[] input;
}