C Programming

Find Output of Program

1. 

If the size of integer is 4bytes, What will be the output of the program?

#include<stdio.h>

int main()
{
    int arr[] = {12, 13, 14, 15, 16};
    printf("%d, %d, %d\n", sizeof(arr), sizeof(*arr), sizeof(arr[0]));
    return 0;
}


A. 10, 2, 4
B. 20, 4, 4
C. 16, 2, 2
D. 20, 2, 2
2. 

What will be the output of the program ?

#include<stdio.h>
#include<string.h>

int main()
{
    int i, n;
    char *x="Alice";
    n = strlen(x);
    *x = x[n];
    for(i=0; i<=n; i++)
    {
        printf("%s ", x);
        x++;
    }
    printf("\n", x);
    return 0;
}


A. Alice
B. ecilA
C. Alice lice ice ce e
D. Alice lice ice ce e
3. 

What will be the output of the program ?

#include<stdio.h>

int main()
{
    int i, a[] = {2, 4, 6, 8, 10};
    change(a, 5);
    for(i=0; i<=4; i++)
        printf("%d, ", a[i]);
    return 0;
}
void change(int *b, int n)
{
    int i;
    for(i=0; i<n; i++)
        *(b+1) = *(b+i)+5;
}


A. 7, 9, 11, 13, 15
B. 2, 15, 6, 8, 10
C. 2 4 6 8 10
D. 3, 1, -1, -3, -5
4. 

What will be the output of the program ?

#include<stdio.h>

int main()
{
    void *vp;
    char ch=74, *cp="JACK";
    int j=65;
    vp=&ch;
    printf("%c", *(char*)vp);
    vp=&j;
    printf("%c", *(int*)vp);
    vp=cp;
    printf("%s", (char*)vp+2);
    return 0;
}


A. JCK
B. J65K
C. JAK
D. JACK
5. 

What will be the output of the program ?

#include<stdio.h>
int *check(static int, static int);

int main()
{
    int *c;
    c = check(10, 20);
    printf("%d\n", c);
    return 0;
}
int *check(static int i, static int j)
{
    int *p, *q;
    p = &i;
    q = &j;
    if(i >= 45)
        return (p);
    else
        return (q);
}


A. 10
B. 20
C. Error: Non portable pointer conversion
D. Error: cannot use static for function parameters