Contents
- 1 What is the output?
- 2 What will be the output?
- 3 what is the output?
- 4 What will be the output?
- 5 What will be the output?
- 6 What will be the output?
- 7 With every use of a memory allocation function, what function should be used to release allocated memory which is no longer needed?
- 8 What value does testarray[2][1][0] in the sample code above contain?
- 9 What is the output of the following program?
- 10 Referring to the sample bellow, what is MAX_NUM?
- 11 What is the output of the following code.
- 12 What is importance of free() function?
- 13 What is a macro?
What is the output?
#include <stdio.h>
int main()
{
int a[]={1,2,3,4,5,6,7};
char c[]={‘a’, ‘x’,’h’,’0′,’k’};
printf(“%d %d”,(&a[3]-&a[0]), (&c[3]-&c[0]));
return 0;
}
Ans: 3 3
What will be the output?
#include <stdio.h>
int main()
{
int val = 5;
int* ptr = &val;
printf(“%d %d”, ++val, *ptr);
}
Ans: 6 5
what is the output?
#include <stdio.h>
void main()
{
char s1[]=”ravi”;
char s2[]=”rama”;
s1=s2;
printf(“%s”,s1);
}
Ans: Error
What will be the output?
#include <stdio.h>
int main()
{
int val = 5;
int* ptr = &val;
printf(“%d %d”, val, *ptr++);
}
OP: 5 5
What will be the output?
#include <stdio.h>
int main()
{
int val = 5;
int* ptr = &val;
printf(“%d %d”, val, ++*ptr);
}
OP: 6 6
Attend Free Demo and Learn C LANGUAGE ONLINE TRAINING by Real-Time Expert
What will be the output?
void main()
{
char *p;
p = “Hello”;
printf(“%c”,*&*p);
}
- Hello
- H
- Some address will be printed
- None of these
Ans: 2
With every use of a memory allocation function, what function should be used to release allocated memory which is no longer needed?
- unalloc()
- dealloc()
- release()
- free()
Ans: Option 4
What value does testarray[2][1][0] in the sample code above contain?
int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
Ans: 11
What is the output of the following program?
void main()
{
int *p;
int a=5;
*p++;
printf(“%d”,a);
return 0;
}
Ans: 5
Referring to the sample bellow, what is MAX_NUM?
#define MAX_NUM 15
Ans: Macro
Q:11. What is the output of the following code?
char *array[4] = {“abcdefgh”}
printf(“%d”,&array[4]-(array));
Ans: 4
What is the output of the following code.
#define sq(a) (a*a)
printf (“%d”,sq(3+2));
Ans: 11
What is importance of free() function?
Ans: It deal locates dynamic memory allocation
What is a macro?
Ans: Substitution text or replacement text defined by #define