1.#define p 2*2
2. void main()
3. {
4. #define p 4*4
5. printf("%d",p);
6. }
a . Error: In line no.1
b . Error: In line no.4
c . 4
d . 16
Q. 2 . Find the correct output
void main()
{
int p=7,q=9;
p=p^q;
q=q^p;
printf("%d %d",p,q);
}
a . 7 9
b . 9 7
c . 18 9
d . 14 7
Q. 3 . which of the following is a Manifest?
a . #define Lakshya 15
b . #defin Lakshya 15
c . #define Lakshya =15
d . #define Lakshya 15;
Q. 4 . Find out the output
void main()
{
float x=2.8,y=4;
if(x%=y)
printf("Both are equal");
else
printf("Not equal");
}
a . Both are equal
b . Not equal
c . Error
d . None of these
Q. 5 . Find the correct output
void main()
{
int a=2,b=0,c=-2;
if(b,a,c)
printf("Lack of C knowledge");
else
printf("Beginner");
}
a . Lack of C knowledge
b . Beginner
c . Compile time error
d . Run time error
Q. 6 . Find the correct output
#define SWAP(type,i,j) {type t=i;i=j;j=t;}
void main()
{
int s=5,t=2;
SWAP(int,s,t);
printf("%d %d",s,t);
}
a . 5 2
b . 2 5
c . 5 5
d . None
Q. 7 . Find the correct output
void main()
{
struct stu
{
int roll;
char name[10];
};
struct stu s={10,"Tuni"};
call(s);
}
call(struct stu s)
{
printf("%d %s",s.roll,s.name);
}
a . 10 Tuni
b . Compilation Error
c . Runtime Error
d . None of these
Q. 8 . Find the o/p
void main()
{
int x=5,y=3;
if(x>y)
printf("HOT");
else;
printf("COLD");
}
a . HOT
b . COLD
c . HOTCOLD
d . Compilation error
Q. 9 . The main function of shared memory is to
a . use primary memory efficiently.
b . do inter process communication.
c . do intra process communication.
d . none of these
Q. 10 . Switch case is very useful in
a . Yes-no problem
b . Menu-driven program
c . Game programming
d . All the above
Q. 11 . Find out the output.
#define PR(x) printf("%d ",x);
#define NULL printf("error");
MCQ of c programming 7
Q. 1 . Find the correct output
void main()
{
void show();
show();
}
void show()
{
char c[]="Lakshya\0\0";
int i,*p;
p=c;
for(i=0;*p;i++)
printf("%c",*p++);
}
a . Lakshya0
b . Lkha
c . Lkha0
d . Error
Q. 2 . Find the output
void main()
{
int x=2,y=3,z;
z=x++y++&&x++;
printf("%d %d %d",x,y,z);
}
a . 3 3 1
b . 4 4 1
c . 4 3 1
d . None of these
Q. 3 . An I/O stream is
a . a text stream
b . a binary stream
c . Both a and b
d . None of these
Q. 4 . Find out the output
void main()
{
int k=2,j=3,p=0;
p=(k,j,k);
k=p;
j=k;
printf("%d\n",p);
}
a . 2
b . Error
c . 0
d . 3
Q. 5 . Find the output.
void main()
{
int x=5,y=6;
change(&x, &y);
printf("%d %d", x, y);
}
change(int *x, int *y)
{
int temp=1;
temp^=*x;
*x^=*y;
*y^=temp;
}
a . 5 6
b . 6 5
c . 3 2
d . None of these
Q. 6 . Which of the following is an optical ROM?
a . ROM
b . PROM
c . EPROM
d . CDROM
Q. 7 . Find out the output
void e(int );
main()
{
int a;
a=3;
e(a);
}
void e(int n)
{
if(n>0)
{
e(--n);
printf("%d" , n);
e(--n);
}
}
a . 0 1 2 0
b . 0 1 2 1
c . 1 2 0 1
d . 1 2 0 1
Q. 8 . Find the output.
void main()
{
int array[]={1,3,5,7,9},*p,i;
p=array[0];
for(i=0;i<5;i++)
c="65;" c="(!="c);" c="scanf(" y="Academy" i="3;i">=1;i--)
for(j=i;j>=1;j--)
printf("%d",i);
}
a . 321211
b . 333221
c . 332211
d . 123233
Q. 15 . Find the incorrect one for ‘typedef ’ srorage class
a . Permits descriptive names for datatypes.
b . Renaming existing datatype
c . Modification of the program is easier when host machine is changed.
d . All of the above
Q. 16 . Find the output
void main()
{
printf("%d %d",sizeof(‘a’), sizeof(‘a1’)) ;
}
a . 1 2
b . 1 1
c . 2 1
d . None of these
Q. 17 . Find the correct output
void main()
{
int a=2,b=4,c;
c=a>b?printf("2>=4"):puts("2<4");>=4
b . 2<4 a="100;" i="0;i<3;i++);" x="5;">
void main()
{
unsigned int a=-1;
printf("%d",~1);
}
a . -3
b . -1
c . -2
d . 1
Q. 29 . Which of the following is/are numeric type constants?
a . integer constant and character constant
b . integer constant and floating-point constant
c . character constant and floating-point constant
d . character constant and string constant
Q. 30 . Find the correct output
void main()
{
struct emp
{
int eid;
char ename[20];
};
struct emp e={010,"Deepak"};
show(s);
}
show(struct{int eid;char ename[20];}e)
{
printf("%d %s",e.roll,e.name);
}
a . Compilation Error
b . 010
c . 010 Deepak
d . None of these
for(j=i;j>=1;j--)
printf("%d",i);
}
a . 321211
b . 333221
c . 332211
d . 123233
Q. 15 . Find the incorrect one for ‘typedef ’ srorage class
a . Permits descriptive names for datatypes.
b . Renaming existing datatype
c . Modification of the program is easier when host machine is changed.
d . All of the above
Q. 16 . Find the output
void main()
{
printf("%d %d",sizeof(‘a’), sizeof(‘a1’)) ;
}
a . 1 2
b . 1 1
c . 2 1
d . None of these
Q. 17 . Find the correct output
void main()
{
int a=2,b=4,c;
c=a>b?printf("2>=4"):puts("2<4");>=4
b . 2<4 a="100;" i="0;i<3;i++);" x="5;">
void main()
{
unsigned int a=-1;
printf("%d",~1);
}
a . -3
b . -1
c . -2
d . 1
Q. 29 . Which of the following is/are numeric type constants?
a . integer constant and character constant
b . integer constant and floating-point constant
c . character constant and floating-point constant
d . character constant and string constant
Q. 30 . Find the correct output
void main()
{
struct emp
{
int eid;
char ename[20];
};
struct emp e={010,"Deepak"};
show(s);
}
show(struct{int eid;char ename[20];}e)
{
printf("%d %s",e.roll,e.name);
}
a . Compilation Error
b . 010
c . 010 Deepak
d . None of these
No comments:
Post a Comment