You are on page 1of 4

/* C SECTION

--------- */
/*1)*/
#include<stdio.h>
main()
{
void swap(int *e,int *d);
int a,b,*p1,*p2;
a=3;
a=2;
p1=&a;
p2=&b;
printf("a=%d\nb=%d",a,b);
swap(p1,p2);
printf("a=%d\nb=%d",a,b);
}
void swap(int *d,int *r)
{
int *u;
u=d;
d=r;
r=u;
}
/*the output of the program is
a)a=3 b=2 a=3 b=� b)a=3 b=2 a=2 b=3
c)a=2 b=3 a=3 b=� d)a=3 b=3 a=2 b=2
2)
#include<stdio.h>
main()
{
int i,j,k;
k=5;
j=6;
i=j*=k;
printf("i=%d",i);
i==j*=k;
printf("i=%d",i);
}
the output is
a)i=30i=3� b)i=30i=� c)i=1i=3� d)i=30i=0
3)
#include<stdio.h>
main()
{
char *a="let's learn C";
printf("%c %c",a[6],*(a+6));
char b='5';
char *c="5";
printf("%d %c %s",b,b,c);
}
the output is
a)l l
5 5 5
b)l e
ASCII value of '5' 5 5�c)l l
5 5 5
d)l l
ASCII value of '5' 5 5
4)
#include<stdio.h>
main()
{
int x,y,z;
y=5;
x=(y==5)*6-(z=7);
printf("%d\n",x);
x*=6*z/9;
printf("%d",x);
}
the value of x printed in both cases is
a)23 9� b)-� -� c)-1 � d) 1 4
5)
#define print "scanf is %s"
#include<stdio.h>
main()
{
char a[]="scanf";
printf(print,a);
}
the output is
a)scanf is scan� b)scanf is %� c)scanf i� d)none of these
6)
#include<stdio.h>
main()
{
char b[]={'C','i','s',' ','f','u','n'};
free(b);
}
the amount of memory released by b is
a)depends on the machin� b)eight byte� c)seven byte� d)64 bytes
7)
#include<stdio.h>
main(int argc,char **argv)
{
if (argc==0)
exit(0);
else
{
printf("%s %s",argv[1],argv[2]);
printf("%s %c",argv[0],argv[3]);
}
the output when the file is called test.c and
this is typed at the prompt
K>test.c how do U do?
i� a)how do
do
b)how do
test.c
c)the program won't compile�d)how do
test.c U
8)
#define MACRO(i,k) i*k
#include<stdio.h>
main()
{
float j;
float x,y;
x=5;
y=10.5;
j=MACRO(x,y);
printf("%f\n",j);
j=x*y;
printf("%d",j);
� the output is
a)52.5,5� b)52,not define� c)52.5,not defined
d)error(the program won't compile)
9)
#include<stdio.h>
main()
{
long x,y,z;
y=5;
x=1;
printf("%d]\n",x);
z=(y==6||x==10);
printf("z=%d,x==%",z,x);
}
the output is
a)1,� b)1,� c)1,1� d)none of these
10)
#include<stdio.h>
void main()
{
long x;
x=90;
printf("%f\n",x);
{
x=1;
printf("%f\n",x);
{
x=30;
printf("%f\n",x);
}
printf("%f\n",x);
}
x==9;
printf("%f",x);
}
the output of the program is
a)90,1,90,3� b)90,1,30,1,� c)90,90,90,� d)none of these
ANSWERS
-------
1)� 2)� 3)� 4)� 5)� 6)� 7)� 8)� 9)� 10)b�

*/

You might also like