Code:
int sum (int p, int q)
{
int result;
result=p+q;
return result;
}
You need to actually give the result back.
Code:
int c[10];
int i;
for(i=0; i<10; i++)
c[i]=0;
Missing semicolons, you need the number 0 not the letter o, and there are 10 ints in the array, 0 through 9, so 10 is out of bounds.
Code:
int *ptrl;
int number=5;
ptrl=&number;
printf("the value pointed by ptrl is %d\n", *ptrl);
You want to assign the ADDRESS of number to the pointer (ptrl is a pointer, so it stores an address.) You CAN'T do *ptrl = number; this copies number into the place pointed at by ptrl -- but ptrl is an uninitialized pointer, dereferencing it yields undefined behavior. The line ptrl=&number; initializes the pointer (by making it point to the memory location of "number". After that, you can dereference it successfully in the next statement.
Code:
switch (code)
{
case 1:
printf("the number is 4\n");
break;
case 2:
printf("the number is 8\n");
break;
default:
printf("the number is not for or 8\n");
break:
}