Point Out Correct Statements

Question 6 :

Which of the statements is correct about the program?

#include < stdio.h >
int main()
{
    int arr[3][3] = {1, 2, 3, 4};
    printf("%d\n", *(*(*(arr))));
    return 0;
}


A). Output: Garbage value
B). Output: 1
C). Output: 3
D). Error: Invalid indirection
Answer : Option D

Question 7 :

Which statement will you add to the following program to ensure that the program outputs "IndiaPARINAM" on execution?

#include < stdio.h >
int main()
{
    char s[] = "IndiaPARINAM";
    char t[25];
    char *ps, *pt;
    ps = s;
    pt = t;
    while(*ps)
        *pt++ = *ps++;
    /* Add a statement here */
    printf("%s\n", t);
    return 0;
}


A). *pt='';
B). pt='\0';
C). pt='\n';
D). *pt='\0';
Answer : Option D

Question 8 :

In the following program add a statement in the function fact() such that the factorial gets stored in j.

#include < stdio.h >
void fact(int*);
int main()
{
    int i=5;
    fact(&i);
    printf("%d\n", i);
    return 0;
}
void fact(int *j)
{
    static int s=1;
    if(*j!=0)
    {
        s = s**j;
        *j = *j-1;
        fact(j);
        /* Add a statement here */
    }
}


A). j=s;
B). *j=s;
C). *j=&s;
D). &j=s;
Answer : Option B