BreakInterview

1. Predict the output of the following code.
# include 
 int main()
{
   char str1[] = "BreakInterview";
   char str2[] = {'B', 'r', 'e', 'a', 'k', 'I', 'n', 't', 'e','r','v','i','e','w'};
   int n1 = sizeof(str1)/sizeof(str1[0]);
   int n2 = sizeof(str2)/sizeof(str2[0]);
   printf("n1 = %d, n2 = %d", n1, n2);
   return 0;
}

n1 = 14, n2 = 15
n1 = 14, n2 = 14
n1 = 15, n2 = 15
n1 = 15, n2 = 14

2. Predict the output of the following code.
int main()
{
    char *s1 = (char *)malloc(50);
    char *s2 = (char *)malloc(50);
    strcpy(s1, "Break");
    strcpy(s2, "Interview");
    strcat(s1, s2);
    printf("%s", s1);
    return 0;
}

BreakInterview
Break
Interview
InterviewBreak

3. Predict the output of the following code.
# include 
int main( )
{
    char s1[7] = "1234", *p;
    p = s1 + 2;
    *p = '0' ;
    printf ("%s", s1);
}

12
120400
1204
1034

4. Predict the output of the following code.
#include 
#if X == 3
    #define Y 3
#else
    #define Y 5
#endif
 
int main()
{
    printf("%d", Y);
    return 0;
}

3
5
Compiler Dependent
Compiler Error

5. Predict the output of the following code.
#include 
#define X 3
#if !X
    printf("Break");
#else
    printf("Interview");
 
#endif
int main()
{
        return 0;
}

Break
Interview
Compiler Error
Runtime Error

6. What is the return type of malloc() or calloc()

void*
pointer or allocated memory type
void**
int*

7. Predict the output of the following code
#include 
int main()
{
    int i = 3;
    switch (i)
    {
        case 0+1: printf("Break");
                break;
        case 1+2: printf("Interview");
                break;
        default: printf("BreakInterview");
    }
    return 0;
}

Break
Interview
BreakInterview
Compiler Error

8. Predict the output of the following code.
#include 
int main()
{
    int i = 3;
    while (i--)
    {
        int i = 100;
        i--;
        printf("%d ", i);
    }
    return 0;
}

Infinite Loop
99 99 99
99 98 97
2 2 2

9. In C, static storage class cannot be used with:

Global variable
Function parameter
Function name
Local variable

10. In the following program snippet, both s1 and s2 would be variables of structure type defined as below and there won't be any compilation issue.
typedef struct Student
{
 int rollno;
 int total;
} Student;
 
Student s1;
struct Student s2;

True
False