Advertisements

Search results for sizeof

Example:[1]

            What will be the output of the following program?
#include <stdio.h>
int main(){
char arr[5][10] = {
"white",
"red",
"green",
"yellow",
"blue"
};
printf("%d",sizeof(arr));
}
          
Option A:

            10
            
Option B:

            5
            
Option C:

            50
            
Option D:

            38
            
Correct Answer: option C
Example:[2]

            What is the output of the following program?
#include <stdio.h> 
#include <string.h> 
void main ()  
{  
    char s[10];
    strcpy(s,"friend");
    printf("%d,%d\n", strlen(s),sizeof(s));
}
          
Option A:

            6,6
            
Option B:

            5,9
            
Option C:

            7,10
            
Option D:

            6,10
            
Correct Answer: option D
Example:[3]

            What is the output of the following program?
#include "stdio.h"
int main(void)
{
  char str[2][15] =
  {
    "Mbed",
    "Technologies"
  };
  printf("%d,%s,%c\n",sizeof(str),str[1],str[0][0]);
}
          
Option A:

            30,M,Technologies
            
Option B:

            30,Technologies,M
            
Option C:

            30,T,M
            
Option D:

            30,e,M
            
Correct Answer: option B
Example:[4]

            What is the output of the following program?
#include "stdio.h"
int main(void)
{
  char *str[] =
  {
    "Mbed",
    "Technologies"
  };
  printf("%d,%s,%c\n",sizeof(str),str[1],str[0][0]);
}
          
Option A:

            18,Technologies,M
            
Option B:

            8,Technologies,M
            
Option C:

            8,T,M
            
Option D:

            30,e,M
            
Correct Answer: option B
Example:[5]

            ptr is ____ pointer after executing the following program?
#include <stdio.h>  
#include <stdlib.h>
void main()  
{  
   int *ptr = (int *)malloc(sizeof(int));  
   int a = 5;  
   ptr = &a; 
   printf("%d\n", *ptr); 
   free(ptr); 
}
          
Option A:

            NULL pointer
            
Option B:

            Void pointer
            
Option C:

            Dangling pointer
            
Option D:

            None of the above
            
Correct Answer: option C
Example:[6]

            What will be error the following program will face during execution?
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#define BUFSIZE 2
void main() 
{
    char *buf;
    buf = (char *)malloc(sizeof(char)*BUFSIZE);
    strcpy(buf, "Hello world\n");
}
          
Option A:

            Stack overflow
            
Option B:

            Heap overflow
            
Option C:

            Frozen memory
            
Option D:

            Memory leak
            
Correct Answer: option B
Example:[7]

            What will be the output of the following program if int takes 4 bytes and char takes 1 byte?
#include <stdio.h>
union mass
{
   	unsigned int a;
   	char b;
};
void main()
{
	union mass u;
    printf("%d\n", sizeof(u));
}
          
Option A:

            1
            
Option B:

            5
            
Option C:

            4
            
Option D:

            6
            
Correct Answer: option C
Example:[8]

            What will be the output of the following program if int takes 4 bytes and char takes 1 byte?
#include <stdio.h>
struct student
{
   	int a;
   	char b;
};
void main()
{
	struct student s;
    printf("%d\n", sizeof(s));
}
          
Option A:

            1
            
Option B:

            5
            
Option C:

            4
            
Option D:

            6
            
Correct Answer: option B
Example:[9]

            What will be the output of the following program?
#include <stdio.h>
struct fiddle
{
	unsigned int itals :1; 
	unsigned int body  :2; 
	unsigned int color :2;
	unsigned int       :3; 
};
void main()
{
	printf("%d\n", sizeof(struct fiddle));
}
          
Option A:

            4
            
Option B:

            16
            
Option C:

            8
            
Option D:

            None of the mentioned.
            
Correct Answer: option A

 Search Links


 Popular C search MCQs


 Popular C search examples