Académique Documents
Professionnel Documents
Culture Documents
else printf("not equal"); } What will be output if you compile and execute the
above code? (a)equal (b)not equal (c)Run time error (d)Compiler error (2) #define
num int long void main() { num a=0;
printf("%d,%d,%d",a++,sizeof a++,sizeof(a++));
} What will be output if you compile and execute the above code? (a)3 2 4 (b)0 0 4
(c)0 4 4 (d)Compiler error (3)
#define short int long void main() {
printf("%d",sizeof(short));
} What will be output if you compile and execute the above code? (a)2 (b)4 (c)8
(d)Compiler error (4) #define float char void main() { float f=255;
printf("%d",sizeof(f++));
} What will be output if you compile and execute the above code? (a)1 (b)2 (c)8
(d)Compiler error (5) void main() { char f=255.0;
printf("%d",sizeof(f++));
} What will be output if you compile and execute the above code? (a)1 (b)8 (c)10
(d)Compiler error (6) void main() { f++; char f=255;
printf("%d",sizeof(f));
} What will be output if you compile and execute the above code? (a)1 (b)2 (c)4
(d)Compiler error (7) #define value 10\2 void main() {
printf("%d",value);
} What will be output if you compile and execute the above code? (a)5
(b)20 (c)102 (d)Compiler error (8) #define xxx 11\ 3 void main() {
printf("%ld",xxx);
} What will be output if you compile and execute the above code? (a)11 (b)3 (c)113
(d)Compiler error (9) #define option1 a++; printf("%d",a); #define option2
print("%d",a); void main() { int a=10;
}
What will be output if you compile and execute the above code? (a)10 (b)11 (c)12
(d)Compiler error (10) //test.c void main() {
printf("%s",__FILE__);
} What will be output if you compile and execute the above code? (a)null (b)test.c
(c)url of current working directory (d)Compiler error (11) #include"stdio.h" void
main() {
}
What will be output if you compile and execute the above code? (a)defined (b)not
defined (c)Run time error (d)Compiler error (12) #include"stdio.h" void main()
{ const int a=1;
} What will be output if you compile and execute the above code? (a)2 (b)3 (c)4
(d)Compiler error (13) #define conio.h #include "stdio.h" #define max 0\5 void
main()
{
} What will be output if you compile and execute the above code? (a)Output will be
date of compilation (b)Output will be time of compilation (c)Output will be both
time of compilation and date of compilation (d)Compiler error (14) #define max 5
#define a max*max #define value a\a void main() { const int aa=5;
printf("%d",value+aa);
} What will be output if you compile and execute the above code? (a)5
(b)6 (c)10 (d)Compiler error (15) #define function(a,b) a##b void main() {
printf("%d",function(5,2));
} What will be output if you compile and execute the above code? (a)10 (b)2 (c)52
(d)Compiler error (16) #define find(a,b,c) #a#b#c void main() { int a=10; int b=20;
int c=30;
printf("%s",find(a,b,c)+1);
} What will be output if you compile and execute the above code? (a)102030 (b)02030
(c)bc (d)Compiler error (17) #define swap(x,y) x^=y^=x^=y void main() { int
a=10,b=20; swap(a,b);
} What will be output if you compile and execute the above code? (a)10 20 (b)20 10
(c)0 10 (d)Compiler error (18) #define int long #define cal(x,y,z) x*y*z void
main() { int a=2; int b=cal(a++,a++,a++);
printf("%d,%d" ,a,b);
} What will be output if you compile and execute the above code? (a)5,0
(b)5,125 (c)5,60 (d)Compiler error (19) #define final(a,b,c) ++a+ ++b+ ++c void
main() {
printf("%d" ,final(1,2,3));
} What will be output if you compile and execute the above code? (a)6 (b)9 (c)10
(d)Compiler error (20) void one(); void two(); #pragma startup one 2 #pragma
startup two 1 void main() { printf("main ");
(d)
What will be output if you compile and execute the above code? (a)3 (b)4 (c)103
(d)Compiler error
(2) void display(); void calculate(); #pragma startup calculate #pragma exit
display void main() { printf("\ncquestionbank"); } void calculate()
{ printf("\njava-questionsbank"); } void display() { printf("\njavadoubt"); }
What will be output if you compile and execute the above code? (a)cquetionbank
Java-questionsbank javadoubt (b)java-questionban Cquetionbank javadoubt (c)
cquetionbank (d)Compiler error (3)
#define int double #define const struct #define char sizeof const student{ int s;
}; void main() { const student s; printf("%d" ,char(s)); } What will be output if
you compile and execute the above code? (a)1 (b)8 (c)Run time error (d)Compiler
error
(5)
(6)
#define find(a,b) a##b void main() { int a=10; int b=20; int ab=15;
printf("%d",find(a,b)-ab); } What will be output if you compile and execute the
above code? (a)0 (b)5 (c)1005 (d)Compiler error
(7) #define max 0\5 void main() { #if max printf("cquestionbnk"); #elif max+1
printf("java-questionsbank"); #else printf("blogspot.com"); #endif
} What will be output if you compile and execute the above code? (a)cquestionbank
(b)java-questionsbank (c)blogspot.com (d)Compiler error (8) #define option1 a++;\
printf("%d",a); #define option2 printf("%d",a); void main() { int a=10; if(a++)
{option1} else option2
} What will be output if you compile and execute the above code? (a)10 (b)11 (c)12
(d)Compiler error
Answer of preprocessor questions: 1. (c) 2. (b) 3. (a) 4. (b) 5. (a) 6. (a) 7. (a)
8. (c) What will be output of following program ?void main() { int a=320; char
*ptr; ptr=(char *)&a; clrscr(); printf("%d ",*ptr); getch(); } Output:64
Explanation: As we know int is two byte data byte while char is one byte data byte.
Char pointer can keep the address one byte at time. Binary value of 320 is 00000001
01000000 In 16 bit Memory representation of int a=320 is:
So ptr is pointing only first 8 bit which color is green and Decimal value is 64.
Memory representation of data type in detail. (q) What will be output of following
program? #include"stdio.h" #include"conio.h" void main() { void (*p)(); int (*q)();
int (*r)(); p=clrscr;
q=getch; r=puts; (*p)(); (*r)("cquestionblogspot.com"); (*q)(); } Output:
cquestionblogspot.com Explanation: p is pointer to function whose parameter is void
and return type is also void. R and q is pointer to function whose parameter is
void and return type is int . so then can hold the address of such function. How
can we read complex pointer in easy way click here. (q) What will be output of
following program? void main() { int i=3; int *j; int **k; j=&i; k=&j; printf( %u
%u %d } Answer: Output: 8085 6024 3 Explanation: Memory representation :
,k,*k,**k);
Ans. (b) 58. What is FAT?. a) b) c) d) File Allocation Table File Access Table FDD
Allocation Table None of the above
(1)List the five c compiler? Ans: Name Work on O.S Name of microprocessor
1. Turbo c M.S DOS 8086 2. Ansic c LINUX/UNIX 80386 3. Borland c WINDOW 80386 4.
Microsoft c M.S DOS 8086 5. Visual c++ WINDOW 80386 Note:- 8086 is 16 bit
microprocessor while 80386 is 32 bit microprocessor. (2) Describe turbo c compiler?
Ans: Turbo c compiler is one of the most popular c compiler.It is based on DOS
operat ing system.It uses 8086 microprocessor which is 16 bit microprocessor. It
has 20 address buses and 16 data bus. It s word length is two byte. (3) What is
hexadecimal number system ? Ans: In hexadecimal number system we use 16 differen
digit so it s base is 16 TABLE Hexadecimal digit decimal equivalent binary
equivalent 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 7 7 0111
8 8 1000 9 9 1001 A 10 1010 B 11 1011 C 12 1100 D 13 1101 E 14 1110 F 15 1111 To
convert the binary number into hexadecimal number: Make the group of four binary
digit from right to left put the equivalent hexade cimal digit using TABLE. e.g
binary number =11000111110101 group of four digit from right 11 0001 1111 0101 to
make group of four digit of left most digit 11,add two zero to the leftt side i.e
0011 now put the eqivalent hexadecimal digit form table 0011 0001 1111 0101 3 1 F 5
So,equivalent hexadecimal number will be 31F5 (4) What will address range which can
repersent in 20 bit ? Ans: in binary in hexadecimal Minimum possible number 0000
0000 0000 0000 0000 0000 Maximum possible number 1111 1111 1111 1111 1111 FFFF In c
any hexadecimal number statr with 0x 0r 0X So,address range will be 0x0000 to
0xFFFF It is 1MB memory range. Note. 2^10 = 1KB 2^20 = 1MB 2^30 = 1GB
Where 10,20,30 are number of bit. (5)What is difference betweent TSR and TSO
program? Ans :TSO means terminate but stay outside.It is those program, which
release the main memory after the executon of the program.e.g Vcd cutter, turbo c
compiler. TSR means terminate but stay residence .It is those program, which after
the exe cution of the program does not release the RAM (main memory).e.g antivirus.
(1) Why there are so many c compilers? Ans: (3)How many keywords are in c? Ans: 43
(6)What is difference between .com program and .exe program? Ans: Both .com and
.exe program are executable program but .com program execute faste r than .exe
program.All driver are .com program. (2) How many type of error in c. Ans: 183
Memory orgnization To be a good programmer is very necessay to understand the
memory structure. (1) What is memory cell? Ans:
Entire RAM has divided in number of equal part, which is known as memory cell.Ca
pcity of each cell is to store one-byte data. i.e char a resevre one memory cell
while float a reseve four memory cell. Each memory cell has unique addresss.Address
are always in whole number an incre sing order. (6) What is residence memory? Ans:
RAM has divided into two parts: (1) Extended memory (useless) (2) Residence
memory : When any program is excuted it is stored in the residence memory .For
turbo c, i t has 1MB residence memory i.e when we open turbo c it store 1MB in the
RAM. (3) What is physical address ? Ans: 20 bit address of the memory cell is known
as physical address or real address.I n 20 bit we can repersent address from
0x00000 to 0xFFFFF.
1. Stack area:All automatic variables are created into stack area.Default storage
class of any local variable is auto.This variable may be int, char, float, array,
pointer, s truct, union etc.It also return fuction argument and return address.It
follow LI FO datastructure. It has two part one for initialize variable another for
non-in itialize variable.All initialize variable are more nearer than unintialize
varia ble and vice versa. 2. Data area : All static and extern variable are created
in the data area. 3. Heap area: Malloc and calloc always allocate memory in the
heap area.It is used for dynamic memory allocation.It s size depends upon free
space in the memory. 4. Code area: Fuction pointer can only access code area.Size
of this area is always fixed and it is read only area.
(10) What will output: void main() { int a=5,b=6,c=7; printf( %d,%d,%d );
} Ans: Output: 7 6 5 Explanation: Default sotrage class int a=5 is auto.Since it
automatic variable it will create in the stack area. It will store in the stack as
Stack always follows LIFO datastructure. In the printf statement name of variable
is not written explicitly.So default ou tput will content of Stack which will be in
the LIFO order i.e 7 6 5. (9) what will be output: void main() { int a=5 ,b,c=7;
printf( %d %d %d ); } Ans: Output: 7 5 garbage value Explanation: Automatic
variable a and c has initialized while b has not initilize.Initialize variable are
more nearer than non initialize variable .They will be stored in th e stack.So due
to LIFO first output will be 7 then 6 (since a is more nearer tha n b with respect
to c) then any garbage value will be output which is persent in the stack. (7) How
many number system in c. Ans: There are three type of number system in c: 1.
Decimal number e.g 25 2. Octal number e.g 025 3. Hexadecimal number e.g 0x25 (8)
010110 is which type of number in c? Ans: Octal integer constant (Since it starts
with zero) Note. C has not binary integer constant. (1) Without using any semicolon
(;) in program write a c programm which output i s: HELLO WORLD ? Ans: void main()
{ if(printf("HELLO WORLD")) { } } (1)What will be output ? void main() { char a[5];
a[0]='q'; a[1]='u'; a[2]='e'; clrscr(); printf("%s",a); getch();
} Output: garbage Explanation: %s is used for string but a is not a string it is
only array of cha racter since its last character is not null character. If you
will write a[3]= \0 ; then output will be que. (2) Write a scanf statement which
can store one line of string which includes wh ite space. Ans: void main() { char
a[30]; clrscr(); scanf("%[^\n]",a); printf("%s",a); getch(); } (3) Write a c
program in which a scanf function can store a paragraph at time ? Ans: void main()
{ char a[30]; clrscr(); scanf("%[^\t]",a); printf("%s",a); getch(); } Note:
Paragraph will end when you will press tab key. (4)In the following program void
main() { char a[30]; } How much aryy a is reserving memory space ? Ans: It is not
reserving any memory space because array a has only declared it has no t
initialized .Any not initialized variable doesn t reserve any memory space.
what will be output of the following program? void main(){ float a=0.7; if(a<0.7)
{ printf("C"); } else{ printf("C++"); } }
For solution and detail explanation click here (2) what will be output of the
following program? void main() { int i=5,j; j=++i+++i+++i; printf("%d %d",i,j); }
For solution and detail explanation click here (3) what will be output of the
following program? void main() { int i=1; i=2+2*i++; printf("%d",i); } For solution
and detail explanation click here (4) what will be output of the following program?
void main() { int a=2,b=7,c=10; c=a==b; printf("%d",c); }
For solution and detail explanation click here (5) what will be output of the
following program? void main() { int x; x=10,20,30; printf("%d",x); } For solution
and detail explanation click here (6) what will be output of the following program?
void main() { int a=0,b=10; if(a=0) { printf("true"); } else { printf("false"); } }
For solution and detail explanation click here (7) what will be output of the
following program? void main() {
int a; a=015 + 0x71 +5; printf("%d",a); } For solution and detail explanation click
here (8) what will be output of the following program? void main() { printf("%d %d
%d",sizeof(3.14),sizeof(3.14f),sizeof(3.14L)); } For solution and detail
explanation click here (9) what will be output of the following program? void
main() { int x=100,y=20,z=5; printf("%d %d %d"); } For solution and detail
explanation click here (10) what will be output of the following program? void
main(){ int a=2; a=a++ + ~++a; printf("%d",a); } For solution and detail
explanation click here
(11) what will be output of the following program? void main() { int a; a=sizeof(!
5.6); printf( %d ,a); } For solution and detail explanation click here (12) what
will be output of the following program? void main() { float a; (int)a= 45; printf(
%d ,a); } For solution and detail explanation click here (13) what will be output
of the following program? void main() { int i=5; int a=++i + ++i + ++i;
printf( %d ,a); } (1)What will be output void main() { clrscr();
printf("%d",sizeof(3.8)); getch();
} output: 8 Explanation: 3.8f is float constant, 3.8 is double constant and 3.8L is
long dou ble constant .Here are finding size of double constantan which is 8. For
more detail click here (2) What will be output ? void main() { char *str1="powla";
char *str2="er"; clrscr(); printf("%s\b\b%s",str1,str2); getch(); } output: power
Explanation: \b escape sequence back the cursor one position left .We are using two
/b so after writing str1 cursor is at the position of l of powal .So when it write
er it will override the la so output will be power. (3)What will be output ? void
main() { int a=270; char *p; p=(char *)&a; clrscr(); printf("%d",*p); getch(); }
output: 16 (4)What is missing statement of in the following program ? void main() {
int sort(int,int); int I; i=sort(5,6); } int sort(int a,int b) { int c; c=a; a=b;
b=c; return a; } Ans: Function sort returning a value but we are not using return
value so there is weastge of two byte memory. So missing statement is ,there should
statement w hich uses the return value. (5)Write following in term of if and else :
void main() { int a=1,b=2,c=3; clrscr(); if(a==5&&b==6&&c==7) printf("india"); else
printf("pak"); getch(); } Ans: void main()
{ int a=1,b=2,c=3; clrscr(); if(a==1) { if(b==2) { if(c==3) { printf("india"); }
else { printf("pak"); }} else { printf("pak"); } } else { printf("pak"); } getch();
} (6)Give the memory representation of struct xxx { char a; int b; char c; }; Ans:
Memory representation :
More detail click here (7) Write the following program in term of switch and case ?
void main() { int a=3; if(x>2) { printf( INDIA IS BEST ); } else{ printf( PAK IS
BEST ); } } Ans: if condition always return two value. 1 if condition is true. 0 if
condition is false. So program is void main() { int x=3; switch(x>2) { case
0:printf("India is best");
break; case 1:printf("Pak is best"); } getch(); } (8) What will be output ? void
main() { int far *a=(int far*)0x50000011; int far *b=(int far*)0x50010001; int huge
*c=(int huge*)0x50000011; int huge *d=(int huge*)0x50010001; clrscr(); if(a==b)
printf("I know C"); else printf("I don't know C"); if(c==d) printf("\nI know C");
else printf("\nI don't know C"); getch(); } Output: I don t know C I known C
Explanation: far pointer always compare its whole far address.Since both or not
equal so first output is :I don t know C Huge pointer always compare its physical
address both c and d are representing s ame physical address so a and b are equal.
More detail click here (9) What will be output ? #define power(a) #a void main()
{ clrscr(); printf("%d",*power(432)); getch(); } Output : 52 Explanation: # is
string zinging operator. It make the string constant of any data. So 432 is
converted into 432 by macro power .Now * 432 means first char which is 4.Since we
ar e using %d so it will print ASCII value of char 4 i.e 52 More detail click here
(10) What will be output ? void main() { int arr[]={1,2,3,4,5,6}; void xxx(int[5]);
xxx(arr); getch(); } void xxx(int ch[5]) { clrscr(); printf("%d",-1[ch]); }
Output : -2
Explanation: We are passing the array by xxx function. 1[ch] means *(ch+1) which is
ch[1] =2. (11) What is difference between a,b,c and in following declaration ?
#define xxx char * typedef char * yyy; void main() { yyy a,b; xxx c,d; } Ans: Both
and b are char * type but c is char * type while d is char type. (12) Write a c
program to find the HCF of any two number ? Ans: void main() { int a,b,c; scanf( %d
%d%d ,a,b,c); clrscr(); while((c=a%b)!=0) { a=b; b=c; } printf("%d",b); getch(); }
(13) What will be output ? void main() { int a=5; { a++; } clrscr();
printf("%d",a); getch(); } Ans :6 (14) What will be output ? void main() { int a=5;
{ int a=7; a++; printf( %d ,a); } clrscr(); printf("%d",a); getch(); } Output: 8 5
Explanation: Scope of the auto variable is within {} if it is declared in {}.Als o
local variable has more priority than global variable. How to calculate RoM and RaM
sizes reading from map file... RO stands for Read Only. It is the const variable
that does not change througho ut the program.
RW stands for Read/Write. It is the variable contains initial value, but it may
change when the program runs. ZI stands for Zero Initialize data. It is the
variable (i.e. buffer) that uses to hold data when the program runs. RAM usage is
the combination of RW and ZI. ROM usage is the conbination of Code, RO, and RW. RW
is part of the ROM usage b ecause it needs to hold initial data. That's this
reason, we can save RAM usage by changing RW into RO data, if we can identify it
does not change throughout t he program.