Consider the macro definitions
#define squa
![]()
Practice C Preprocessor – Consider the macro definitions
#define square (x) x*x
and #define square (x) (x*x)
when used in a program statement B=++square(C)
![]()
Practice C Preprocessor – Consider the macro definitions
#define square (x) x*x
and #define square (x) (x*x)
when used in a program statement B=++square(C)
![]()
Practice Arrays – What is the output of the following problem ?
int main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("
%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
return 0;
} ![]()
Practice C Preprocessor – # define max (x, y)x = (x > y)? x : y is a macro definition.
Which can find the maximum of two numbers x and y if
![]()
Practice Functions – What is the output of the following problem ?
#include
int main() {
int factorial(int n);
int i,ans;
ans = factorial(5);
printf("
Factorial by recursion = %d
", ans);
return 0;
}
int factorial(int n)
{
if (n <= 1)
return (1);
else
return ( n * factorial(n-1));
} ![]()
Practice Declarations and Initializations – What is the output of the following program?
void main()
{
int x,y, z;
x=2; y=1; z = 1;
if(x > y + z)
printf("Hello!
");
else if (x < y+ z)
printf ("Hi!
");
else
printf("Hey!
");
} ![]()
Practice Structures, Unions, Enums – What is the output of the following problem ?
#include
struct {
int x;
int y;
union {
int id_no;
char *name;
}b;
}s,*st;
int main()
{
st = &s;
st->x=10;
st->b.id_no = 101;
printf("%d %d
",s.x,s.b.id_no);
return 0;
} ![]()
Practice Control Instructions – What is the output of the following problem ?
#include
int main()
{
int i;
for (i=9;i<13; i++)
printf("%d %0x ",i,i);
return 0;
} ![]()
Practice Arrays – What is the output of the following problem ?
#include
int main()
{
func(1);
return 0;
}
func(int i){
static char *str[] = {"One","Two", "Three", "Four"};
printf("%s
",str[i++]);
return;
} ![]()
Practice Strings – What is the output of the following problem ?
#include
int main()
{
int len=4;
char *st="12345678";
st = st + len;
printf("%c
",*st);
return 0;
} ![]()
Practice C Preprocessor – What will be output of the following “c” code?
#include
#define max(a,b) (a>b)? a:b
int main()
{
int a,b; a=3; b=4;
printf("%d",max(a,b));
return 0;
} ![]()
Practice Strings – What is the output of the following problem ?
#include
int main()
{
char *str = "12345";
printf("%c %c %c
", *str, *(str++), *(str++));
return 0;
} ![]()
Practice Variable Number of Arguments – What will be output of the following “c” code?
#include
int main()
{
float i, j;
scanf(%f %f, &i, &j);
printf(%.2f %.3f, i, j);
return 0;
}
What will be the output for the give input 12.342 and 123.4568
![]()
Practice Declarations and Initializations – What will be output of the following “c” code?
#include
void main ( )
{
int a=500, b=100,c;
if( !(a>=400))
b=200;
c=200;
printf( "%d %d", b,c);
} ![]()
Practice Structures, Unions, Enums – What is the output of the following program ?
#include
int main() {
union {
int a;
int b;
int c;
} u,v;
u.a = 10;
u.b = 20;
printf("%d %d
",u.a,u.b);
return 0;
} ![]()
Practice Declarations and Initializations – What will be output of the following “c” code?
#include
void main ( )
{
int i;
for( i=0; i<10; i++,printf("%d", i));
}