adplus-dvertising

Welcome to the Data Types,Operators and Expressions in C MCQs Page

Dive deep into the fascinating world of Data Types,Operators and Expressions in C with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Data Types,Operators and Expressions in C, a crucial aspect of C Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Data Types,Operators and Expressions in C, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Data Types,Operators and Expressions in C. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Data Types,Operators and Expressions in C. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Data Types,Operators and Expressions in C MCQs | Page 38 of 66

Q371.
What will be the output of the program?
#include<stdio.h>

int main()
{
    printf("%d %d\n", 32<<1, 32<<0);
    printf("%d %d\n", 32<<-1, 32<<-0);
    printf("%d %d\n", 32>>1, 32>>0);
    printf("%d %d\n", 32>>-1, 32>>-0);
    return 0;
}
Discuss
Answer: (b).64 320 3216 320 32
Q372.
What will be the output of the program?
#include<stdio.h>

int main()
{
    unsigned int res;
    res = (64 >>(2+1-2)) & (~(1<<2));
    printf("%d\n", res);
    return 0;
}
Discuss
Answer: (a).32
Q373.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    int i=4, j=8;
    printf("%d, %d, %d\n", i|j&j|i, i|j&&j|i, i^j);
    return 0;
}
Discuss
Answer: (c).12, 1, 12
Q374.
Which of the following statements are correct about the program?
#include<stdio.h>

int main()
{
    unsigned int num;
    int i;
    scanf("%u", &num);
    for(i=0; i<16; i++)
    {
        printf("%d", (num<<i & 1<<15)?1:0);
    }
    return 0;
}
Discuss
Answer: (c).It prints binary equivalent num
Q375.
Which of the following statements are correct about the program?
#include<stdio.h>

int main()
{
    unsigned int num;
    int c=0;
    scanf("%u", &num);
    for(;num;num>>=1)
    {
        if(num & 1)
            c++;
    }
    printf("%d", c);
    return 0;
}
Discuss
Answer: (a).It counts the number of bits that are ON (1) in the number num.
Q376.
Which of the following statements are correct about the program?
#include<stdio.h>
char *fun(unsigned int num, int base);

int main()
{
    char *s;
    s=fun(128, 2);
    s=fun(128, 16);
    printf("%s\n",s);
    return 0;
}
char *fun(unsigned int num, int base)
{
    static char buff[33];
    char *ptr = &buff[sizeof(buff)-1];
    *ptr = '\0';
    do
    {
        *--ptr = "0123456789abcdef"[num %base];
        num /=base;
    }while(num!=0);
    return ptr;
}
Discuss
Answer: (a).It converts a number to a given base.
Q377.
Which of the following statements are correct about the program?
#include<stdio.h>

int main()
{
    unsigned int m[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
    unsigned char n, i;
    scanf("%d", &n);
    for(i=0; i<=7; i++)
    {
        if(n & m[i])
            printf("yes");
    }
    return 0;
}
Discuss
Answer: (b).It will test whether the individual bits of n are ON or OFF
Q378.
What will be the output of the program?
#include<stdio.h>
#include<stdarg.h>
void fun(char *msg, ...);

int main()
{
    fun("CompSciBits", 1, 4, 7, 11, 0);
    return 0;
}
void fun(char *msg, ...)
{
    va_list ptr;
    int num;
    va_start(ptr, msg);
    num = va_arg(ptr, int);
    num = va_arg(ptr, int);
    printf("%d", num);
}
Discuss
Answer: (c).4
Q379.
What will be the output of the program?
#include<stdio.h>
#include<stdarg.h>
void fun1(char, int, int *, float *, char *);
void fun2(char ch, ...);
void (*p1)(char, int, int *, float *, char *);
void (*p2)(char ch, ...);

int main()
{
    char ch='A'; int i=10;
    float f=3.14; char *p="Hello";
    p1=fun1;
    p2=fun2;
    (*p1)(ch, i, &i, &f, p);
    (*p2)(ch, i, &i, &f, p);
    return 0;
}
void fun1(char ch, int i, int *pi, float *pf, char *p)
{
    printf("%c %d %d %f %s \n", ch, i, *pi, *pf, p);
}
void fun2(char ch, ...)
{
    int i, *pi; float *pf; char *p;
    va_list list;
    printf("%c ", ch);
    va_start(list, ch);
    i = va_arg(list, int);
    printf("%d ", i);
    
    pi = va_arg(list, int*);
    printf("%d ", *pi);
    pf = va_arg(list, float*);
    printf("%f ", *pf);
    p = va_arg(list, char *);
    printf("%s", p);
}
Discuss
Answer: (b).A 10 10 3.140000 HelloA 10 10 3.140000 Hello
Q380.
What will be the output of the program?
#include<stdio.h>
#include<stdarg.h>
void dumplist(int, ...);

int main()
{
    dumplist(2, 4, 8);
    dumplist(3, 6, 9, 7);
    return 0;
}
void dumplist(int n, ...)
{
    va_list p; int i;
    va_start(p, n);

    while(n-->0)
    {
        i = va_arg(p, int);
        printf("%d", i);
    }
    va_end(p);
    printf("\n");
}
Discuss
Answer: (c).4 86 9 7

Suggested Topics

Are you eager to expand your knowledge beyond C Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!