Skip to content

Latest commit

 

History

History
57 lines (53 loc) · 1.05 KB

111110.mkd

File metadata and controls

57 lines (53 loc) · 1.05 KB

C

What will happen for the following C code

// part-1
#include <stdio.h>
int main()
{
    int a=1;
    switch(a)
    {
        int b=20;
        case 1:
        printf("b is %d\n",b);
        break;
        default:
        printf("b is
                %d\n",b);
        break;
    }
    return 0;
}

// part-2
#include <stdio.h>
int main()
{
    int i;
    i = 10;
    printf("i : %d\n",i);
    printf("sizeof(i++) is: %d\n",sizeof(i++));
    printf("i : %d\n",i);
    return 0;
}

// part-3
#define PrintInt(expr) printf("%s : %dn",#expr,(expr))
int main()
{
    int y = 100;
    int *p;
    p = malloc(sizeof(int));
    *p = 10;
    y = y/*p; /*dividing y by *p */;
    PrintInt(y);
    return 0;
}

// part-4
#include <stdio.h>
int main()
{
    char dummy[80];
    printf("Enter a string:\n");
    scanf("%[^r]",dummy);
    printf("%s\n",dummy);
    return 0;
}