My Report

C Programming Practice Test 10


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following C code, if it is run on a 32 bit platform?

#include<stdio.h>
#pragma(1)
struct test
{
    int i;
    char j;
};
main()
{
    printf("%d",sizeof(struct test));
}

2. What will be the output of the following C code?

#include <stdio.h>
#define display( n ) printf( "a" #n " = %d", a##n )
int main()
{
   display(3);
}

3. Which of the following attributes is used to specify that the minimum required memory to be used to represent the types?

4. What will be the output of the following C code?

#include<time.h>
int main (void)
{
    float n = time(NULL);
    printf("%.2f\n" , n);
}

5. Choose the statement which is incorrect with respect to dynamic memory allocation.

6. The correct syntax of the attribute packed is _________

7. What will be the output of the following C code?

#include <stdio.h>
void inline func1(char b[10]) 
{
    printf ("%c\n",b[2]);
}
int main() 
{
     func1("sanfoundry");
     return 0;
}

8. The incorrect statement with respect to dangling pointers is ___________

9. What will be the output of the following C code?

#include <stdio.h>
#include <time.h>
int main ()
{
	double d;
	d = difftime (5,17);
	printf ("%.2f\n", d );
	return 0;
}

10. What will be the output of the following C code?

#include <stdio.h>
#include <limits.h>
int main() 
{
    printf("The minimum value of LONG = %lf\n", LONG_MIN);
    return 0;
}

 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.