Program to find permutation

Program to find permutation


#include "stdio.h"

#include "stdlib.h"
int lev=-1,n,val[50],a[50];
void main()
{
int i,j;
clrscr();
printf("Enter how many numbers");
scanf("%d",&n);
for(i=0;i
{
val[i]=0;
j=i+1;
scanf("%d",&a[j]);
}
visit(0);
getch();
}
visit(int k)
{
int i;
val[k]=++lev;
if(lev==n)
{
for(i=0;i
printf("%2d",a[val[i]]);
printf(" ");
}
for(i=0;i
if(val[i]==0)
visit(i);
lev--;
val[k]=0;
}

Related Links :

Program to create simple paint brush software in C

void main(){

static char *s[3]={"math","phy","che"};

typedef char *( *ppp)[3];

static ppp p1=&s,p2=&s,p3=&s;

char * (*(*array[3]))[3]={&p1,&p2,&p3};

char * (*(*(*ptr)[3]))[3]=&array;

p2+=1;

p3+=2;

printf("%s",(***ptr[0])[2]);

}

Related Links :

MCQ of c programming , Multiple Choice Questions , Objective Questions On C

Q. 1 . TurboC 3.0 is based on
a . DOS
b . UNIX
c . Windows
d . none
Q. 2 . Find the output.
void main()
{
int a=4,b=5;
printit(a, b);
}
printit(int b, int a)
{
printf("%d %d", a, b);
{
int a=0;
int b=1;
printf("%d %d", a, b);
}
}
a . 4 5 0 1
b . 5 4 0 1
c . 5 4 5 4
d . None of these
Q. 3 . Find the output
void main()
{
int const x=4;
int i,a[x]={1,2,3,4};
for(i=0;i<4;i++) x="1.5" y="1.5f" z="1.5" a="b=" c="10;" a="10;" a="call(a=" i="printf(" a="sizeof(int)/sizeof(float))" a="=" a="{2.5};" b="a;" a="5,*p;" p="&a;" i="15;" x="16384,y=" ptr="&one_d;" i="1;i<=" i="=" i="1;i<=" i="=" p="Hai Bye" i="3;">0)
{
int i=5;
printf("%d",i);
i--;
}
}
a . 5 4 3 2 1
b . Error, multiple declaration for i
c . 3 2 1
d . Infinite loop
Q. 28 . The contents of a file will be lost if it is opened in
a . a mode
b . a- mode
c . w+ mode
d . a+ mode
Q. 29 . Find the output.
void main()
{
int i=1,j=2,k=3;
if(i==1)
if(j==2)
if(k==3)
{
printf("ok");
break;
}
else
printf("continue");
printf("bye");
}
a . ok
b . okbye
c . Misplaced break
d . None of these
Q. 30 . Find the output
void main()
{
printf("Lakshya\C\Academy");
}
a . LakshyaCAcademy
b . LakshyaAcademy
c . Lakshya
d . Lakshyacademy

MCQ of c programming 2



Q. 1 . Find out the output
void main()
{
int val=1234;
int *ptr=&val;
printf("%d %d",++val,(*(int *)ptr)--);
}
a . 1234 1233
b . 1235 1234
c . 1234 1234
d . None of these
Q. 2 . Find the correct output
void main()
{
int a=0;
for(a;++a;a<=100) printf("%d",a); } a . Print 1 to 99 infinite times b . Print 1 to 99 c . Print some garbage values d . Infinite loop Q. 3 . Find the output void main() { char c[6+4]="kill me"; printf("2%s",c); } a . ki b . me c . kill me d . 2kill me Q. 4 . Find out the output main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); } a . Infinite loop b . 0 1 c . 1 d . Stop after printing upto INT_MAX Q. 5 . Find out the output. int main(int k) { if(k<5) a="5,b=" c="2;">b=2?z>3?1:2:3:4);
}
a . 1
b . 2
c . 3
d . 4
Q. 14 . Find the correct output
void main()
{
int i,j=6;
for(;i=j;j-=2)
printf("%d",j);
}
a . Error
b . Garbage values
c . 642
d . 6420
Q. 15 . State the correct statement.
a . In a while loop the control conditional check is performed n times.
b . In a do-while loop the control conditional check is performed n+1 times.
c . Break is a keyword used with if and switch case.
d . None of these.
Q. 16 . Find out the output
void main()
{
printf("3","%f",4);
}
a . 34.000000
b . 4
c . 3
d . Error
Q. 17 . What happens when subscript used for an array exceeds the array size?
a . Compiler gives an error message
b . Simply placed excess data outside the array
c . Simply placed excess data on top of other data or on the program itself.
d . The program must be compiled.
Q. 18 . The order of evaluation of operators having same precedence is decided by
a . Associativity rule
b . Precedence rule
c . Left-right rule
d . Right-left rule
Q. 19 . The set of routines stored in ROM that enable a computer to start the O.S and to communicate with the various devices in the system is known as
a . device driver
b . boot parameter
c . bios
d . none of these
Q. 20 . Find the output
struct main
{
int n;
int (*p)();
};
void main()
{
struct main m;
int fun();
m.p=fun();
*(m.p);
}
fun()
{
printf("Hallo");
}
a . Hallo
b . HalloHallo
c . Error
d . No output
Q. 21 . Find the output
union uni
{
int x;
int a:8;
char b:8;
}
void main()
{
union uni u={48};
printf("%d %c", u.a,u.b);
}
a . Invalid initialization
b . 48 0
c . 48 48
d . 0 0
Q. 22 . An AND gate
a . implements logical addition
b . is equivalent to a series switching circuit
c . implements logical subtractions
d . is equivalent to a parallel switching circuit
Q. 23 . Find the output
void main()
{
goto cite;
{
static int a=10;
cite: printf("%d",a);
}
}
a . 10
b . Warning, unreachable code
c . Error
d . Garbage value
Q. 24 . Find out the output
void main()
{
int i=3,j=2,k=1;
printf("%d / %d");
}
a . 1
b . 0
c . 3/2
d . 1/2
Q. 25 . The ‘continue’ statement is used to
a . Continue the next iteration of a loop construct.
b . Exit the block where it exists and continues after.
c . Exit the outermost block even if it occurs inside the innermost.
d . Continue the compilation even an error occurs in a program.
Q. 26 . which of the following declaration is incomplete type?
(1) struct tag;
(2) struct tag {int a };
(3) typedef struct{int a:}abc
a . 1 only
b . 1 and 2 only
c . 1 and 3 only
d . 2 and 3 only
Q. 27 . Find the odd one out
a . #elif
b . #line
c . #else
d . #ifdef
Q. 28 . The ‘continue’ statement is used to
a . Continue the next iteration of a loop construct.
b . Exit the block where it exists and continues after.
c . Exit the outermost block even if it occurs inside the innermost.
d . Continue the compilation even an error occurs in a program.
Q. 29 . What is the value of EOF which is declared in "stdio.h"?
a . 0
b . -1
c . Any positive value
d . None of these
Q. 30 . Which data type behaves like both integer type and character type?
a . short int
b . signed int
c . char
d . enum
MCQ of c programming 3


Q. 1 . Find the correct output
#include"string.h"
void main()
{
struct node
{
int data;
struct node *next;
};
struct node *p,*q;
p=(struct node *)malloc(sizeof(struct node));
q=(struct node *)malloc(sizeof(struct node));
p->data=10;
q->data=20;
p->next=q;
q->next=NULL;
printf("%d",p->data);
p=p->next;
printf("%d",p->data);
}
a . 10 20
b . 10 Garbage value
c . 20 Garbage value
d . None of these
Q. 2 . Find out the output
void main()
{
int x=2,*y=&x;
printf("%d",x*y);
}
a . 4
b . Garbage
c . Prints result of multiplication of address of x and x
d . Error
Q. 3 . Which of the following function is appropriate to read one character at a time?
a . fscanf()
b . fgetc()
c . read()
d . fgets()
Q. 4 . Find out the output
main()
{
const int x=get();
printf("%d",x);
}
get()
{
return(20);
}
a . 20
b . Garbage value
c . Error
d . 0
Q. 5 . Which format specifier is used to find out the offset address of a variable?
a . %o
b . %p
c . %h
d . %d
Q. 6 . Find out the output.
#define fool !1 - -1
void main()
{
printf("Hi!");
if (fool)
printf("Bye");
}
a . Lvalue required
b . Hi!
c . Bye
d . Hi!Bye
Q. 7 . Find out the output
void main()
{
char str[20];
static int i;
for(;;)
{
i++[str]= 'a'+15;
if(i==19)
break;
i++;
}
i[str]='\0';
printf("%s",str);
}
a . Error
b . Garbage value
c . p
d . pppppppppppppppppppp
Q. 8 . When loop looses its stop value then it is called
I. Odd loop
II. Even loop
III. Unknown loop
IV. User friendly loop
a . only I
b . I & III
c . III & IV
d . II & IV
Q. 9 . Find the correct output
void main()
{
int x=10,y=20,p,q;
p=add(x,y);
q=add(x,y);
printf("%d %d",p,q);
}
add(int a,int b)
{
a+=a;
b+=b;
return(a);
return(b);
}
a . 10 10
b . 20 20
c . 10 20
d . 20 10
Q. 10 . Find out the output
main()
{
int a[5] = {1,2,3,4,5};
int *ptr = (int*)(&a+1);
printf("%d %d" ,*(a+1),*(ptr-1));
}
a . 2 2
b . 2 1
c . 2 5
d . None of the above
Q. 11 . The area or scope of the variable depends on its
a . Date type
b . Storage class
c . System type
d . None of these
Q. 12 . Each case statement in switch is separated by
a . break
b . continue
c . exit()
d . goto
Q. 13 . Find out the output
main()
{
const int x=get();
printf("%d",x);
}
get()
{
return(20);
}
a . 20
b . Garbage value
c . Error
d . 0
Q. 14 . Find out the output
void main()
{
int a[5]={1,2,3};
int j;
for(j=0;j<5;j++) x1="5.74,x2=" x1="5.74" x2="23.78" opname =" Xstr(OP);" p="c;" p="lakshya" x="10;" x="callme(x);" i="5;" x="x/2-3;" s="’\dx’;" i="2;">>1)
{
default: i++;
case 1: ;
case 2: ;
}
printf("%d",i);
}
a . 2
b . 1
c . Expression syntax error
d . None of these
Q. 29 . Find the correct output
void main()
{
int a,b,c;
c=scanf("%d%d",&a,&b);
printf("\n%d",c);
}
a . 1
b . 2
c . 0
d . None of these
Q. 30 . Which of the following is known as auxillary memory?
a . RAM
b . ROM
c . HARD DISK
d . BIOS


MCQ of c programming 4


Q. 1 . Choose the wrong one
a . A structure can be nested within same structure
b . A value of one structure variable can be assigned to another structure variable
of same or different type.
c . It is illegal to use the structure itself as its member.
d . In self referential structure one member must be a pointer type.
Q. 2 . Find out the output
void main()
{
register int x;
scanf("%d",&x);
printf("%d",x);
}
If the value x is given 5 then output will be
a . 5
b . 0
c . Garbage
d . Error
Q. 3 . Find the output
#define float int
void main()
{
int x=10;
float y=3;
y=x%y;
printf("%f",y);
}
a . 0
b . 1
c . 1.000000
d . Error, floating point format not linked
Q. 4 . Which of the following is a miscellaneous directive?
a . #undef
b . #error
c . #elif
d . #include
Q. 5 . State the correct statement.
a . Linker combines different source files before compilation.
b . Linker combines different object files before execution.
c . Linker expands different source files before compilation.
d . none of these
Q. 6 . Find out the output.
void main()
{
int n=5;
if(n==5?printf("Hallo"):printf("Hai"),printf("Bye"));
}
a . HalloBye
b . Hallo
c . Expression syntax error
d . HaiBye
Q. 7 . Find the output
int x,y;
void main()
{
show(&x,&y);
printf("%d %d",x,y);
}
show(int *x,int *y)
{
*x++;
*y++;
}
a . 0 0
b . 1 1
c . Garbage output
d . None of these
Q. 8 . The different models used to organize data in the secondary memory are collectively called as
a . File structures
b . Data structures
c . Self referential structures
d . None of these
Q. 9 . Find the output
void main()
{
printf("%f",(float)9/5);
}
a . 1.8
b . 1.0
c . 2.0
d . None of these
Q. 10 . Find out the output
void main()
{
int static auto x;
x=5;
printf("%d",++x);
x--;
printf("%d",x);
}
a . Too many storage classes in declaration
b . 6 5
c . 6 6
d . None of these
Q. 11 . Find the output.
void main()
{
int x=5;
char a[x]={‘a’,’b’,’d’};
printf("%c",++1[a]);
}
a . b
b . c
c . d
d . None of these
Q. 12 . Addresses in Memory always stored in ABCD order but data is stored in
a . ABCD order
b . DCBA order
c . Depends on system type
d . None of these
Q. 13 . A bit field can be of
a . int
b . float
c . double
d . All of these
Q. 14 . The synonym for an existing data type can be created using
a . typedef
b . structure
c . enum
d . All of the above
Q. 15 . Which of the following is best suited for memory optimization
a . Union
b . Self referential structure
c . Array
d . Linked list
Q. 16 . Find out the output
#include"fcntl.h"
#include"sys\stat.h"
void main()
{
int x;
x=open("raja.txt",O_CREATO_TEXT, S_IWRITE);
printf("%d",x);
}
a . 5
b . 6
c . 7
d . None of these
Q. 17 . All structure variables are created in
a . Code area
b . Stack area
c . Uninitialized data area
d . Initialized data area
Q. 18 . Cast operator returns
a . Lvalue
b . Rvalue
c . Integral value
d . None
Q. 19 . Find the output
void main()
{
int i;
for(i=1;i<=3;i++) { print: printf("C"); printf("%d",i); } } a . Error,':' tag not allowed within the loop b . 1 2 3 c . C 1 C 2 C 3 d . Garbage value Q. 20 . Find the correct output void main() { int i=100; float f=5.413; print(i,f); } print(i,f) { printf("%d %f",i,f); } a . 100 5.413 b . 100 5.000 c . 100 0.000 d . Error Q. 21 . Find out the output void main(void) { char numbers[5][6]={"Zero","One","Two","Three","Four"}; int *ptr=(int *)numbers; for(;*ptr!=0;) printf("%c",*ptr++); } a . eoOeToTreFu b . Zero c . Zr d . Compile time error Q. 22 . Find out the output void main() { int a[]={1,2,3,4,5}; int j; for(j=0;j<5;j++) x="10,y;" y="choose(x);">=5)
return(y);
else
return(0);
}
a . 10
b . 0
c . Can’t determine
d . Error
Q. 24 . Find the correct output
#define div(x) x/x
void main()
{
printf("%d",div(16)*16);
}
a . 1
b . 16
c . 256
d . None of these
Q. 25 . What is the formula to find real address from 16-bit physical address?
a . segment address*16+offset address
b . segment address+offset address *16
c . segment address*10+offset address
d . segment address+offset address *10
Q. 26 . Which of the following function is appropriate to read one character at a time?
a . fscanf()
b . fgetc()
c . read()
d . fgets()
Q. 27 . Find the correct output
void main()
{
int a;
char b;
float c;
printf("%d",sizeof(a+sizeof(b+c));
}
a . 2
b . 1
c . 4
d . Error
Q. 28 . Find the output.
void main()
{
int x=5;
for (;x<=5;if(x==5)) printf("%d",++x); } a . 5 b . 6 c . Error d . No output Q. 29 . Find the output void main() { int i=-3,j=2,k=0,m; m=++i && j++ && ++k; printf("\n%d, %d, %d, %d",i,j,k,m); } a . -2,-3, 1,1 b . -3, 2, 0,1 c . -2, 3, 0,1 d . -2, 3, 1,1 Q. 30 . Find out the output. void main() { char *s="Rani"; printf("%s\r%s",s,s); } a . Rani b . RaniRani c . Rani\0 d . Ranii MCQ of c programming 5 Q. 1 . Choose the wrong one a . A structure can be nested within same structure b . A value of one structure variable can be assigned to another structure variable of same or different type. c . It is illegal to use the structure itself as its member. d . In self referential structure one member must be a pointer type. Q. 2 . Find out the output void main() { register int x; scanf("%d",&x); printf("%d",x); } If the value x is given 5 then output will be a . 5 b . 0 c . Garbage d . Error Q. 3 . Find the output #define float int void main() { int x=10; float y=3; y=x%y; printf("%f",y); } a . 0 b . 1 c . 1.000000 d . Error, floating point format not linked Q. 4 . Which of the following is a miscellaneous directive? a . #undef b . #error c . #elif d . #include Q. 5 . State the correct statement. a . Linker combines different source files before compilation. b . Linker combines different object files before execution. c . Linker expands different source files before compilation. d . none of these Q. 6 . Find out the output. void main() { int n=5; if(n==5?printf("Hallo"):printf("Hai"),printf("Bye")); } a . HalloBye b . Hallo c . Expression syntax error d . HaiBye Q. 7 . Find the output int x,y; void main() { show(&x,&y); printf("%d %d",x,y); } show(int *x,int *y) { *x++; *y++; } a . 0 0 b . 1 1 c . Garbage output d . None of these Q. 8 . The different models used to organize data in the secondary memory are collectively called as a . File structures b . Data structures c . Self referential structures d . None of these Q. 9 . Find the output void main() { printf("%f",(float)9/5); } a . 1.8 b . 1.0 c . 2.0 d . None of these Q. 10 . Find out the output void main() { int static auto x; x=5; printf("%d",++x); x--; printf("%d",x); } a . Too many storage classes in declaration b . 6 5 c . 6 6 d . None of these Q. 11 . Find the output. void main() { int x=5; char a[x]={‘a’,’b’,’d’}; printf("%c",++1[a]); } a . b b . c c . d d . None of these Q. 12 . Addresses in Memory always stored in ABCD order but data is stored in a . ABCD order b . DCBA order c . Depends on system type d . None of these Q. 13 . A bit field can be of a . int b . float c . double d . All of these Q. 14 . The synonym for an existing data type can be created using a . typedef b . structure c . enum d . All of the above Q. 15 . Which of the following is best suited for memory optimization a . Union b . Self referential structure c . Array d . Linked list Q. 16 . Find out the output #include"fcntl.h" #include"sys\stat.h" void main() { int x; x=open("raja.txt",O_CREATO_TEXT, S_IWRITE); printf("%d",x); } a . 5 b . 6 c . 7 d . None of these Q. 17 . All structure variables are created in a . Code area b . Stack area c . Uninitialized data area d . Initialized data area Q. 18 . Cast operator returns a . Lvalue b . Rvalue c . Integral value d . None Q. 19 . Find the output void main() { int i; for(i=1;i<=3;i++) { print: printf("C"); printf("%d",i); } } a . Error,':' tag not allowed within the loop b . 1 2 3 c . C 1 C 2 C 3 d . Garbage value Q. 20 . Find the correct output void main() { int i=100; float f=5.413; print(i,f); } print(i,f) { printf("%d %f",i,f); } a . 100 5.413 b . 100 5.000 c . 100 0.000 d . Error Q. 21 . Find out the output void main(void) { char numbers[5][6]={"Zero","One","Two","Three","Four"}; int *ptr=(int *)numbers; for(;*ptr!=0;) printf("%c",*ptr++); } a . eoOeToTreFu b . Zero c . Zr d . Compile time error Q. 22 . Find out the output void main() { int a[]={1,2,3,4,5}; int j; for(j=0;j<5;j++) x="10,y;" y="choose(x);">=5)
return(y);
else
return(0);
}
a . 10
b . 0
c . Can’t determine
d . Error
Q. 24 . Find the correct output
#define div(x) x/x
void main()
{
printf("%d",div(16)*16);
}
a . 1
b . 16
c . 256
d . None of these
Q. 25 . What is the formula to find real address from 16-bit physical address?
a . segment address*16+offset address
b . segment address+offset address *16
c . segment address*10+offset address
d . segment address+offset address *10
Q. 26 . Which of the following function is appropriate to read one character at a time?
a . fscanf()
b . fgetc()
c . read()
d . fgets()
Q. 27 . Find the correct output
void main()
{
int a;
char b;
float c;
printf("%d",sizeof(a+sizeof(b+c));
}
a . 2
b . 1
c . 4
d . Error
Q. 28 . Find the output.
void main()
{
int x=5;
for (;x<=5;if(x==5)) printf("%d",++x); } a . 5 b . 6 c . Error d . No output Q. 29 . Find the output void main() { int i=-3,j=2,k=0,m; m=++i && j++ && ++k; printf("\n%d, %d, %d, %d",i,j,k,m); } a . -2,-3, 1,1 b . -3, 2, 0,1 c . -2, 3, 0,1 d . -2, 3, 1,1 Q. 30 . Find out the output. void main() { char *s="Rani"; printf("%s\r%s",s,s); } a . Rani b . RaniRani c . Rani\0 d . Ranii MCQ of c programming 6 Q. 1 . How many times the loop will be executed? void main() { char c; for(c=1;c<=127;c++) printf("Lakshya"); } a . 127 times b . 126 times c . Only once d . None of these Q. 2 . Find the correct output void main() { int a[]={1,2,3,4,5}; int *p=(int *)(&a+1); printf("%d %d",*(a+1),*(p-1)); } a . 2 0 b . 1 0 c . 2 5 d . 1 garbage Q. 3 . Find the output void main() { char *p="hello"; printf ("%.3s", p); } a . hel b . llo c . 3hello d . None of these Q. 4 . put these stages of compilation in order, a) link b) compilation c) execute d) Precompilation a . a,b,c,d b . d,b,a,c c . d,c,b,a d . a,c,b,d Q. 5 . Find the correct output void main() { struct node { int data; struct node *link; }; struct node *p,*q; p=malloc(sizeof(struct node)); q=malloc(sizeof(struct node)); printf("%d %d",sizeof(p),sizeof(q)); } a . 4 4 b . 2 2 c . 1 1 d . None of these Q. 6 . Size of the physical address of 80x86 microprocessor is a . 16 bits b . 20 bits c . 24 bits d . 32 bits Q. 7 . 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. 8 . Find the correct output void main () { for(clrscr();printf ("CITE");getch()) {} } a . Print CITE infinite times b . Print CITE for one time c . Print CITE as long as long as a keyboard is hit d . Print CITE for one time then print some garbage values. Q. 9 . Find out the output void paws(int *apple,int *ball) { *apple=*apple+*ball; *ball=*apple-*ball; *apple=*apple-*ball; } void main() { int apple=3617283450; int ball=3617283449; paws(&apple,&ball); printf("%d %d",apple,ball); } a . 23929 23930 b . 23322 23323 c . 23939 23940 d . Error Q. 10 . What happens when far address is incremented? a . Only segment address is incremented. b . Only offset address is incremented. c . Both segment and offset address are incremented. d . None of these Q. 11 . Find out the output void main() { char *p="rama"; char *q=0; char *r="\bsita"; strcpy(q,p); strcat(q,r); printf("%s",q); } a . ramsita b . ramasita c . rama\sita d . None of these Q. 12 . Find the output. void main() { int a=4,b=5; printit(a, b); } printit(int b, int a) { printf("%d %d", a, b); { int a=0; int b=1; printf("%d %d", a, b); } } a . 4 5 0 1 b . 5 4 0 1 c . 5 4 5 4 d . None of these Q. 13 . Find out the output. void main() { int a=5,b=7; int *p; p=&a; p--; *p=10; printf("%d %d",a,b); } a . 5 7 b . 5 10 c . 10 7 d . Garbage 7 Q. 14 . The address of all ISR is kept in a . IVT b . Page table c . Segmentation table d . None of these Q. 15 . Find the output. void main() { int x=5,y=6; do{ x=x+y; y=x-y; x=x-y; }while(x=0)
j++;
}
a . 5 times
b . 6 times
c . Infinite times
d . None of these
Q. 30 . Find out the output
void main()
{
printf("%u",main);
}
a . Garbage value
b . Run time error
c . Printing starting address of function main
d . Infinite loop
MCQ of c programming 7

Q. 1 . Find the correct output
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");
#define PRINT(x1,x2) PR(x1); PR(x2); NULL
void main()
{
int x=5,y=10;
PRINT(x,y);
}
a . 5 10 error
b . 10 5 error
c . 5 10
d . 10 5
Q. 12 . Find the output
#define MAX(x,y) x>y?x:y
void main()
{
int x=2,y=3;
printf("%d",MAX(++x,++y));
}
a . 4
b . 5
c . Error
d . None of these
Q. 13 . Find out the output
void main()
{
unsigned int a=65536;
if(!a)
printf("%d",a,++a);
else
printf("%d",a,++a);
}
a . 0
b . 1
c . 65536
d . 65537
Q. 14 . x%y is equal to
a . y-(x/y)*x
b . x-(x/y)*y
c . x-(y/x)*x
d . y-(y/x)*y
Q. 15 . #define dprintf(e) printf(#e " = %d\n",'e')
void main()
{
int x=8;
int y=3;
dprintf(x/y);
}
a . expr=2
b . expr=101
c . x/y=101
d . None of the Above.
Q. 16 . Find out the output
void main()
{
int x=6,y=4,z=0;
if((x>=y)(z=y))
z-=2;
printf("%d",z);
}
a . 0
b . 2
c . -2
d . None of these
Q. 17 . Self referential structure
a . Used to create a memory link.
b . Plays an important role in linked list creation.
c . Contains the object of same structure which is of pointer type.
d . All the above
Q. 18 . Find out the output
typedef struct boy
{
float height;
char name:9;
int age:16;
}boy;
void main()
{
boy b={5.8,"Praveen kumar",24};
printf("%f %s %d",b.height,b.name,b.age);
}
a . 5.8 Praveen k 24
b . 5.8 Praveen kumar 24
c . 5.8 Praveen k 16
d . None of these
Q. 19 . Switch-case statement does not implement on
a . non exclusive case
b . mutually exclusive case
c . mutually non exclusive case
d . exclusive case
Q. 20 . Find out the output
void main()
{
unsigned int i=2;
i=(((i<<6)-1)^127); i="15;">y? x:y
void main()
{
int a,b;
a=MAX(1,2)+3;
b=MAX(4,3)+5;
printf("%d %d",a,b);
}
a . 5 4
b . 5 9
c . 5 8
d . None of these
Q. 24 . Find the output
void main()
{
*(char*)65=’a’;
printf ("%c",*(char*)65);
}
a . a
b . A
c . Error
d . None of these
Q. 25 . The function ftell(fp) returns
a . The beginning position of the file represented by fp.
b . The end position of the file represented by fp.
c . The current position of the file represented by fp.
d . None of these
Q. 26 . Find out the output
void paws(int *apple,int *ball)
{
*apple=*apple+*ball;
*ball=*apple-*ball;
*apple=*apple-*ball;
}
void main()
{
int apple=3617283450;
int ball=3617283449;
paws(&apple,&ball);
printf("%d %d",apple,ball);
}
a . 23929 23930
b . 23322 23323
c . 23939 23940
d . Error
Q. 27 . Find the correct output
void main()
{
char a[4]="rama";
char b[]="shyama";
printf("%d %d", sizeof(a),sizeof( b)) ;
}
a . 4 7
b . 5 6
c . 5 7
d . 4 6
Q. 28 . Find the correct output
typedef struct tag
{
int i;
char c;
}tag;
void main()
{
struct tag t1={1,’C’};
tag t2={2,’A’};
printf("%d%c ",t1.i,t1.c);
printf("%d%c ",t2.i,t2.c);
}
a . Error in first printf() statement.
b . Error in second printf() statement.
c . 1C 2A
d . None of these
Q. 29 . Find the correct output
void main()
{
int i=5;
i=++i + ++i + i++;
printf("%d",i);
}
a . 21
b . 22
c . 19
d . None of these
Q. 30 . What will be the value of ‘x’ after execution of the following program?
void main()
{
int x=!0*20;
}
a . 10
b . 20
c . 1
d . 0

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="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
MCQ of c programming 8

Q. 1 . void main()
{
int i,j;
for(i=0,j=0;i<2,j<2;i++,j++) i="5;" a="1,b=" a="=" b="=" x="2,y=" t="x;" x="*y;" y="t;" i="9;" i="0;i<3;i++)" x="3.7;" y="1.5;">1.5)
printf("fool");
else
printf("stupid");
}
a . fool
b . stupid
c . garbage value
d . None of these
Q. 11 . Most of the errors blamed on a computer are actually due to
a . programming errors
b . hardware damage
c . data entry errors
d . physical conditions
Q. 12 . Find the output.
void main()
{
int i;
for(i=-9;!i;i++);
printf("%d",-i);
}
a . 8
b . 9
c . 0
d . 1
Q. 13 . Switch-case statement does not implement on
a . non exclusive case
b . mutually exclusive case
c . mutually non exclusive case
d . exclusive case
Q. 14 . Find out the output.
void main()
{
int i=98;
while(100-i++)
printf("%u",i);
switch(i)
case ‘e’:
printf("Fool");
}
a . 98 99 100
b . 99 100
c . 99 100 Fool
d . Expression syntax error
Q. 15 . Find out the output
void main()
{
if("lakshya"=="lakshya")
printf("equal");
else
printf("not equal");
}
a . equal
b . not equal
c . Compile time error
d . None of these
Q. 16 . Find the output.
void main()
{
char s=’A’;
char a=’a’;
printf("%d",s-a);
}
a . -32
b . -18
c . Error
d . None of these
Q. 17 . Find out the true statement.
a . A union variable can be assigned to another union variable.
b . The address of union variable can be extracted by using & operator.
c . A function can return a pointer to the union.
d . All the above
Q. 18 . Find out the output
#define min(a,b) ((a)<(b))?(a):(b) main() { int i=0,a[20],*ptr; ptr=a; while(min(ptr++,&a[9])<&a[8]) i=i+1; printf("i=%d\n",i); } a . 7 b . 6 c . 5 d . compile time erro Q. 19 . To flush all output streams we can write a . fflush(stdout) b . fflush(NULL) c . fflush(ALL) d . None of these Q. 20 . Find the correct output void main() { int a[]={1,2,3,4,5},i; for(i=0;i<5;i++) p="hai" p="’H’;" q="’B’" a="10;" a="(*a)*(*a);" x="12;" y="x;" i="1;" c="’l’;" p="strchr(s,c);" x="(y=" a="5,b=" c="10;">b) ? &a : &b) = (a+b>c);
printf("%d\t%d",a,b);
}
a . 5 4
b . Error, lvalue required
c . 0 4
d . 4 0
MCQ of c programming 9

Q. 1 . Find the correct output
void main()
{
int i;
for(i=1;i<=3;i++) { if(i==3) break; printf("%d",i); } for(i=1;i<=3;i++) { if(i==3) goto last; printf("%d",i); } end: ; } a . 123123 b . 1212 c . Error d . Garbage values Q. 2 . Which member of a union is in use at any time can be known explicitly using a . Enum b . Bit fields c . Static members d . Can’t be determined Q. 3 . The Turbo C implementation of C language supports a . High level file I/O b . System level file I/O c . Both a and b d . Executable files only Q. 4 . The commonly used functions for writing to a text stream are a . putc() b . fputc() c . fputs() d . All of the above Q. 5 . A bit field can be of a . int b . float c . double d . All of these Q. 6 . An assembler which runs on a computer for which it produces object codes is called as a . one pass assembler b . two pass assembler c . self assembler d . none of these Q. 7 . Find the output void main() { char a=’H’; switch(a) { case ‘H’:printf("%c",’H’); case ‘E’:printf("%c",’E’); case ‘L’:printf("%c",’L’); case ‘L’:printf("%c",’L’); case ‘O’: printf("%c",’O’); } } a . HELLO b . HEL c . Error d . HELO Q. 8 . Width of a data bus of the microprocessor is known as a . Byte Regs b . Word Regs c . WordLength d . None Q. 9 . Find the output void main() { char *p= (char*) 0x21; printf ("%d %p", p, p); } a . 21 0021 b . 21 21 c . 33 0021 d . None of these Q. 10 . In a hard disk a track is a collection of a . sectors b . clusters c . cylinders d . none of these Q. 11 . Find the output. void main() { int a=5; a=find(a+=find(a++)); printf("%d", a); } int find(int a) { return ++a; } a . 12 b . 13 c . 15 d . None of these Q. 12 . Find the correct output void main() { printf("%d","lakshya"[1]); } a . l b . a c . 97 d . None of these Q. 13 . Find the output. union res { int a:16; char b:10; } void main() { union res s; s.b=’B’; s.a=10; printf("%c %d", s.b, s.a) ; } a . 2048 10 b . B 2144 c . B 10 d . None of these Q. 14 . Find out the output. void main() { char *s="Rani"; printf("%s\r%s",s,s); } a . Rani b . RaniRani c . Rani\0 d . Ranii Q. 15 . Find the output void main() { int i; static int j=0; for(i=1;i<5;i++) num="345," sum="0;" m="num%10;" num="num/10;" sum="sum*10+m;" a="*a+*b;*b=" a="*a-*b;" x="10,y=" x=" %d" y =" %d\n" x="10" y="20" x="20" y="10" x="garbage" y="garbage" a="sizeof(int)/sizeof(float))" a="=" i="10;" p="&i;" q="p;" a="2,b=" c="a">b?printf("2>=4"):puts("2<4");>=4
b . 2<4 x="16384,y=" i="3,j=" k="lakshya(++i)*++i;" p="a;" i="0;i<=" j="2;printf(" c="a;" i="1;i<5;i++)" s="{80," a="3,b=" a="b);" x="10;" y="3.14;" x="20;" a="4,b=" f="0.9;" d="0.9f;" f="=" i="1,j=" k="3;" i="=" j="=" k="=" p="array[0];" i="0;i<5;i++)" i="4;i">0;)
printf("%d",a[i--]);
}
a . 05432
b . 54321
c . 5432
d . 4321
Q. 26 . Which of the following is/are true for nested if
I. It can only test for equality.
II. Conditions may be repeated for number of times.
III. It can evaluate relational or logical expressions.
IV. Character constants are automatically converted to integers.
a . All of the above
b . I & II
c . I, II & III
d . II, III & IV
Q. 27 . Most of the errors blamed on a computer are actually due to
a . programming errors
b . hardware damage
c . data entry errors
d . physical conditions
Q. 28 . Find the correct output
struct abc
{
int x;
char c;
union xyz
{
int a;
char b;
float c;
}p;
}q;
void main()
{
printf("%d",sizeof(q));
}
a . 2
b . 4
c . 7
d . None of these
Q. 29 . Find the output
void main()
{
int *q,**p,x=4;
q=&x;
p=&q;
(**p)++;
++*p;
printf("%d",**p);
}
a . 5
b . 6
c . Garbage output
d . Error, non portable pointer conversion
Q. 30 . Which storage class can precede any data type in the parameter list?
a . Auto
b . Static
c . Register
d . Extern

Related Links :


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!