NITT-EEE ASSOCIATION-CAMPUS PLACEMENT PROGRAMME-SOFTWARE QUESTIONS
EEE ASSOCIATION-CAMPUS PLACEMENT PROGRAMME
C - DIAGNOSTIC TEST
Instructions: Assume compilation under DOS(Turbo C).
Assume all required header files are included.
Write the output for all the questions. In case there is error, point it out.
1. main()
{
char line1[80],line2[80];
scanf("%s", line1);
scanf("%[^\n]", line2);
printf("%s \n %s", line1, line2);
}
INPUT: Good evening.
2. main()
{
clrscr();
int a;
scanf("%d", &a);
printf("%d", a);
}
INPUT: 5
3. main()
{
int a = 1;
~a;
printf("%d", a);
}
4. main()
{
int a = 5;
printf("%d", sizeof(a++));
printf("%d", a);
}
5. main()
{
int *p,x;
*p = 2;
x = 1 /*p;
printf("%d", x);
}
6. main()
{
int i = -32768;
printf("%d", -i);
}
7. main()
{
struct s {
char *s;
} a = { "Rithcie"}, *p = &a;
printf("%s", *p.s);
}
8. main()
{
struct s {
char *z;
int i;
struct s *p }
a[] = { { "BAD", 1, a+1},
{ "SAD", 2, a+2},
{ "MAD", 3, a+3} } , *p = a;
printf("\n %s", a[ (++p)->i ].z);
printf("\n %s", a[ --(p->p->i).z);
printf("\n %s", (*(++p)->p).z);
}
9. main()
{
int x = 55;
int *p = &x;
char *c = p;
c++;
printf("%d", *c);
}
10. main()
{
float far *s1, *s2;
printf("%d %d", sizeof(S1),sizeof(s2));
}
11. main()
{
int i;
scanf("%d", &i);
switch(i)
{
case 3: printf("Three");
break;
case 3.14: printf("pi");
break;
}
}
INPUT : 3
12. main()
{
int *c;
c = check(10,50);
printf("\n c = %u", c);
}
check(int i, int j)
{
int *p, *q;
p = &i;
q = &j;
if(i >= 45)
return(p);
else
return(q);
}
13. #define mul(a,b) a*b
main()
{
printf("%d", mul(3+2,4+5));
}
14. int i = 0;
main()
{
printf("%d \n", i);
i++;
ini();
printf("%d \n", i);
ini();
}
ini()
{
i = 100;
printf("%d \n", i);
i++;
}
15. main()
{
static int s[4][] = { 1,2,3,4,5,6,7,8};
printf("%d \n", *(*(s+2)+1);
}
16. State any two differences between malloc() and calloc().
17. main()
{
static int a[] = { 0,1,2,3,4 };
static int *p[] = { a,a+1,a+2,a+3,a+4};
int **ptr = p;
ptr++;
printf("%d %d %d \n", ptr-p, *ptr-a, **ptr);
*ptr++;
printf("%d %d %d \n", ptr-p, *ptr-a, **ptr);
*++ptr;
printf("%d %d %d \n", ptr-p, *ptr-a, **ptr);
++*ptr;
printf("%d %d %d \n", ptr-p, *ptr-a, **ptr);
}
18. main()
{
int a[s] = { 0,1,2,3,4};
printf("%u \n", a+1);
}
a's address is 7046.
19. main()
{
int i;
int a[s];
for ( i=0; i<5; i++ )
scanf("%d \n", &a[i]);
if( a[4] = 4 )
printf("Right");
else
printf("Wrong"); }
INPUT : 0,1,2,3,5
20. #define CONDITION ( i==1 )
main()
{
int i = 5;
while CONDITION
printf("True");
if ( i != 1)
printf("False");
}
21. main()
{
int x = 3, y = 4, z = 4;
printf(" ans = %d", z >= y && y <= x ? 1 : 0);
}
22. main()
{
int a = 10;
if (a&8==8)
printf("ON");
else
printf("OFF");
}
23. main()
{
int a[] = { 1,3,6,7,0};
int *b;
b = &a[2];
printf("%d", b[-1]);
}
24. main()
{
printf("main);
main();
}
In the above code, how many times main will be printed?
25. main()
{
int i1 = 1, i2 = 2;
PRINT(1);
PRINT(2);
}
To get the output as
i1 = 1
i2 = 2
what should be the macro "PRINT" ?
26. main()
{
printf("\101");
}
27. What is wrong with the call
fopen ("c:\eee\marks.txt", "r");
28. main()
{
int a,b;
a = (10,15);
b = 10,15;
printf("%d %d", a,b);
}
29. main()
{
int x = 5;
printf("%d %d %d", x, x<<2, x>>2);
}
30. main()
{
int i = 1, j = -1, k = 0;
k = ++j && ++i;
printf("%d %d %d", i,j,k);
}
31. main()
{
int a = 5, b = 10;
if ( a>0,b>0 )
printf("Go to heaven");
else
printf("Go to hell");
}
32. main()
{
char a[5] = { 'a','b','c' };
char b[] = { 'a','b','c' };
char c[] = { "abc" };
printf("%d %d %d", strlen(a), strlen(b), strlen(c));
printf("%s %s %s", a,b,c);
}
Decipher the following declarations:
33. int *(*pap)[ ];
34. int *x[ ]( );
35. int (* fpf ( ) ) ( );
36. Define pure virtual functions.
37. What is the use of the copy constructor.
38. int a = 10;
void main( )
{
int a = 15;
cout<=65 && a<=96)
main()
{
char a=’N’;
if COND
printf(“UPPERCASE”);
else
printf(“lowercase”);
}
Is it a good style of programming? If not give a better idea.
5. #define AREA (r) (3.14*r*r)
main()
{
float a,r=1;
a=AREA(r);
printf(“area of circle=%f”,a);
}
6. #define PCAT
main()
{
#ifdef PCAT
printf(“Get up early!”);
#undef PCAT
printf(“\nAttend CPC regularly!”);
#endif
#ifndef PCAT
printf(“\nSmile always!”);
#endif
}
7. Instead of using the macro #define PI 3.14159
can we use a variable float PI=3.14159 ?
If yes, then what is the purpose of macro?
If no, justify ur answer.
8. #include “cpc.h”
#include
What is the difference between the above two?
9. What are the uses of #pragma directive?
10. A macro should always be written in a single line. Is this true?
If not how will u write a macro having multiple lines?
11. main()
{
int i1=2,i2=1;
print(1);
print(2);
}
Define the macro print(x) so that the o/p is
i1=2
i2=1
12. main()
{
int a=2;
#if(a==2)
printf(“The size of int is 2”);
#else
printf(“%d is the size of int”,2);
#endif
}
13. i) Can we use #undef to undefine library functions?
ii) # undef getchar – will this work?
14. Define a macro SWAP(t,x,y) that will interchange 2 arguments x,y of
type t. what is the limitation of ur program?
15. #include
#define conv(a) printf("%c",a+97);
main()
{
char str[]="REC\12NIT\6";
int i=-1;
while(str[++i]!='\0')
{
i=i-1;
switch(str[++i])
{
case 'R':
printf(" ");
conv(0)
i=3;
continue;
case 'N':
conv(str[i]-'A')
i=6;
continue;
case 6:
conv(str[i])
i=0;
continue;
case 'E':
printf("u");
i=2;
continue;
case 10:
conv(str[i]+1)
i=4;
continue;
case 'I':
conv(i*i-1)
printf("\r");
i=8;
continue;
}
}
conv(-26);
}
c++:
1. #define MYFILE “conio.h”
#define MYFILE
main()
{
window(1,1,11,11);
cprintf(“Do not bunk classes!”);
}
2. main()
{
clrscr();
printf(“how is this paper?”);
}
#include “conio.h”
3. #define EEE #include
EEE
main()
{
printf(“Cigarette smoking is injurious to health!”);
}
4. What are the operators that cannot be overloaded?
5. Difference between malloc & new?
6. What are static & dynamic polymorphism?
True or False:
7. It is possible to create ur own manipulator?
8. A destructor can return a value.
9. Multiple & Multilevel inheritance are one and the same.
10.Size of an object is equal to the sum of size of data members & member functions within the class.
********************************************************************************
software test-3
loop, decision, case control
NAME :
ROLL NO. :
1. main()
{
int a=1;
switch(a)
{
case 2:
printf(“believe in the best”);
case 1:
printf(“better than the best“);
case default:
printf(“yeh dil mange more“);
}
}
2. main()
{
unsigned char a;
for(a=1;a<=255;a++)
printf(“%d”,a);
}
3. main()
{
int i; char c; float f;
scanf(“%d %c %f”,&i,&c,&f);
printf(“%d %c %f”,i,c,f);
}
i/p: 3.14 a 3
4. Rewrite the following expression so that ‘30’
is used only once:
a<50?b=30:c=30;
5. main()
{
float f=0.7,g=0.9;
if(g&&f==0.7)
printf(“real taste of life“);
else
printf(“the coolest ones “);
}
6. main()
{
float f=0.7,g=0.9;
if(g&&f=0.9)
printf(“let's make things better “);
else
printf(“connecting people “);
}
7. main()
{
int a=-1,b=1;
if(++a,b++)
printf(“%d”,a);
else
printf(“%d”,b);
}
8. main()
{
int i=1,j=1;
for(;j;printf(“%d %d\n”,i,j))
j=i++<=3;
}
9. main()
{
while(printf(“\0”))
printf(“Infinite”);
}
10. #include
main()
{
char str[]="aeiou";
int i=0;
for(putchar('c');putchar(str[i++]);putchar('\n'),putchar(‘b'))
putchar('t');
}
11.main()
{
int a,b;
for(a=-2,b=-2;++b,a++;)
printf("\na=%d b=%d",a,b);
}
12.main()
{
int a;
char b;
printf(" %d",scanf("%c%d",&b,&a));
printf(“\r%c\/%d”,b,a);
}
I/P : 84 3
what is the output of this program ?
13.using conditional operator, write single statement to find the
biggest of 3 nos, a, b & c.
14. main()
{
goto default:
switch(‘1’)
{
case 1:
printf(“born tough“);
default:
printf(“made for each other “);
}
}
15. #include
main()
{
char ch=’A’;
while(ch<=’F’)
{
switch(ch)
case ‘A’:case ‘B’:case ‘D’:ch++;continue;
case ‘E’:case ‘F’: ch++;
}
putchar(ch);
}
}
16. main()
{
int i=3;
while(i--)
{
int i=100;
i--;
printf(“%d..”,i);
}
}
17. main()
{
int n=3;
fun(n);
}
int fun( int n)
{
static int i=0;
for(;i<=n;)
{
i++;
fun(n-i);
}
printf(" well done");
}
How many times “well done” will b printed?
********************************************************************************
Software test – 4
Functions and Bitwise operators
NAME:
ROLL NO:
1.#include
main()
{
unsigned int a=40,b;
for(b=0;a!=0;a&=(a-1),b++);
printf("\n%d",b);
}
o/p ?
what is the significance of this program ?
2. #include
main()
{
unsigned int a,b,c,d,e,f;
a=b=c=d=e=f=64;
a<<=2,b>>=2;
a^=b^=a^=b;
d|=2,e&=2;
f=~0xff,c=!a;
printf("%d %d %d %d %d %x",a,b,c,d,e,f);
}
what is the o/p of this program ?
In this program one bitwise operator is different
from the other which is that and why?
3. #include
main()
{
int a=5,b=15;
arg2(a);
arg1(a,b);
}
arg2(int d,int e)
{
printf("\nthe values passed to arg2 are %dand%d",d,e);
}
arg1(c)
int c;
{
printf("\nthe value passed to arg1 is %d",c);
}
5 4.#include
main()
{
unsigned int a,b;
printf("Enter a number :");
scanf("%d",&a);
b=~3;
a&=b;
printf("%d",a);
}
i/p 47
What is the o/p of this program ?
Trace the o/p of this program for some other i/p
Do you observe any relation between i/p and o/p
5. #include
int fun3()
{
printf(" do this ");
return 3;
}
int fun2()
{
printf(" you ");
return 2-1;
}
int fun1()
{
printf(" can ");
return 1;
}
main()
{
int i;
i=fun3()+fun1()*fun2();
printf("%d me",i);
}
What is the output of this program ?
6.what are actual arguments and formal arguments ?
7.#include
sumandavg(int a[])
{
int i,sum,avg;
for(sum=0;i<5;i++)
sum+=a[i];
avg=sum/5;
return(sum,avg);
}
main()
{
int a[]={5,10,15,20,25},sum,avg;
avg=sumandavg(a);
printf("sum= %d,avg= %d",sum,avg);
}
What is the o/p of the program ?
8.#include
main()
{
unsigned int a,b;
printf("enter a number");
scanf("%d",&a);
printf("\n%x",a);
for(;a>0;a>>=1)
b=(b<<1)|(a&1);
printf("\n%x",b);
}
i/p 15 o/p ?
What is the purpose of this program ?
If the o/p of this program is same as the input what
does it mean ?
9#include
int fun(int a,int b)
{
if(0==b)
return a;
if(b>a)
fun(b,a);
else
fun(b,a%b);
}
main()
{
printf("%d",fun(3,8));
}
o/p ?
What does the function fun() do?
10.Mr X wants to print the message "God could not be everywhere therefore he made mothers" But he don't
want to use even a single semicolon.Can you help him ?
11.Suggest three ideas to swap two integers without
using a temp variable.
12.#include
int f(int n)
{
static int a;
if(n)
a=n%10+f(n/10);
return a;
}
main()
{
printf("%d",f(12345);
}
o/p ?
what is the limitation of this program?
13.Compare the execution times of loops and recursion
for performing a same task. Give reason for your answer.
14.#include
main()
{
static int i=1;
printf("\nSoftware is like sex. It is better when it is
free \n -linus torvalds”);
for(;i<5;i++)
main();
}
The intention of this program is to print the message five times.Will this code give the desired output? If not make
minimal changes in the code to achieve the desired output.
15.#include
main()
{
int i=-5,j=5,k=0,m,l;
m=++j&&++i||++k;
printf("i=%d j=%d k=%d m=%d",i,j,k,m);
l=k=i=j;
k=j+=i-=k;
l+=j*k;
printf("\ni=%d j=%d k=%d l=%d",i,j,k,l);
}
o/p ?
16.Write a function leftrotate(x,n) that returns the value
of an unsigned integer x rotated to left by n bit positions.
Assume that n is a non negative integer less than 16.
17.what is pass by value and pass by reference.which
one is used for passing arrays to a function.How can we
pass an array to the function using the other concept?
18.write a program to print the Fibonacci series up to
n terms.the series must start from 0.Get n from
the user
19.In order to utilize the memory efficiently, The Apti,
Tech and C marks of a student in cpc exams are stored
in a single unsigned integer(16 bit) whose format is
raaaaatttttccccc. r-result{1 for pass 0 for fail};
aaaaa-apti marks;ttttt-tech marks; ccccc-c marks.Write
a function which accepts the encoded marks
(i.e an unsigned int).Decode the marks and calculate
the results.Return the marks along with the result.
Minimum pass mark in each subject is 15.
Max marks =25
20.Write C code to compare 2 integers (tell if they are
equal or not)without using ‘==’, ‘! =’ operators.
21.#include
int FiveTimes(int a)
{
int t;
t = a<<2 + a;
return t;
}
main()
{
int a = 1, b = 2,c = 3;
printf("\n%d",FiveTimes(a));
printf(" %d",FiveTimes(b));
printf(" %d",FiveTimes(c));
}
o/p ?
22.#include
main()
{
int k = 5;
if (++k < 5 && k++/5 || ++k <= 8);
printf("%d\n", k);
}
o/p ?
23.
#include
main()
{
int a=5,b=2,c=0x8000;
float d,e,f;
d=a/b;
e=(float)c;
f=(float)a/b;
printf("\n%f %f %f",d,e,f);
}
o/p ?
24.#include
int cast(float a)
{
return a+=0.5;
}
float circum(float r)
{
return(2*3.14*r);
}
main()
{
int c;
float r=2.0;
printf("\n%d ",cast(circum(r)),(int)circum(r));
}
o/p?
25.say true or false
i)Left shifting an integer by 1 is equivalent to
multiplying it by 2.
ii)Two return statements will never occur in a
function successively.
iii)We cann't use bitwise operators on floating
point numbers.
iv)The bitwise operator '^' can be used to
toggle a bit.
v)The output of (a&b) will always be less than
or equal to the minimum of (a,b).
vi)a<<-2 is equivalent to a>>2.
f
}
********************************************************************************
SOFTWARE TEST-5
(arrays,strings,datatypes) 1) int main()
{
char a[10]="serenity";
char b[]="serenity";
char *c="serenity";
printf("%d %d %d",sizeof(a),sizeof(b),sizeof(c));
return 0;
}
2) int main()
{
char a[2][10][10]={"serenity"};
char b[][10][15]={"serenity"};
char *c[2][10]={"serenity"};
printf("%d %d %d",sizeof(a),sizeof(b),sizeof(c));
return 0;
}
3) int main()
{
char food[]={"yummy"};
char *ptr;
ptr=food+strlen(food);
while(--ptr>=food)
puts(ptr);
return 0;
}
4) char input[]="SSGOOEDM1\1\11X\1OELRN\1\1G";
int main()
{
int i,c;
printf("%s %c",input,9);
for(i=2;(c=input[i])!='\0';i++)
{
switch(c)
{
case 'a':putchar('i');
continue;
case '1':break;
case 1: while((c=input[++i])!='\1'&&c!='\0');
case 9: putchar('V');
case 'E':
case 'L':continue;
default: putchar(c);
continue;
}
putchar(' ');
}
putchar('\n');
return 0;
}
5) int main()
{
char a[2][35][50];
int b[5][55][30];
float *c[45][40];
printf("%d %d %d",sizeof(a[2][33]),sizeof(b[3]),sizeof(c[35]));
return 0;
}
6) int arraysize(char[]);
int main()
{
char a[]={1,2,3,4,5};
printf("%d",arraysize(a));
return 0;
}
int arraysize(char a[])
{
return(sizeof(a));
}
7) #define scanf "%%%s is a string\n"
int main()
{
printf("%%s is a string\n","bye");
printf(scanf,"bye");
printf(scanf,scanf,"bye");
return 0;
}
8)Use of ellipsis(…)?
9) int main()
{
int x,y,z;
printf("%d\n",printf("enter an integer\n"));
printf("%d %d",x,scanf("%d %d %d",x,y,z));
}
10) int main()
{
int k;
char a[]="india",*india="flourishes";
k=strcmp(a,"india flourishes");
strcat((*a+32),india);
return 0;
}
In the above pgm,what will be the value of k and a?
11) int main()
{
char a[]="india";
char b[]={'a','u','s','t','r','a','l','i','a'};
printf("%d %d %d %d",sizeof(a),sizeof(b),strlen(a),strlen(b));
return 0;
}
12)int main()
{
int i;
char a[10]={65,66,67,68,69};
for(i=0;i<4;i++)
a[i]=i+'a';
printf("%s %d",a,strlen(a));
return 0;
}
13)Vivek wants to reset the fifth bit of any integer given to him.
But, unfortunately he doesn’t know the architecture of his machine and he
even doesn’t know the operator sizeof().So,he decided to write a
machine compatible code.What might he have done?
14) Interpret the equivalent strings for the following:
(a)”\10123\xggx” -
(b)”\10223\xfffgx” -
(c)”\10323\xfggx” -
15)Write the prototype of the following library functions:
(a)strcat() -
(b)strcmp() -
©strcpy() -
16) int main()
{
char a[]="\10123\xggx";
char b[]="\10123\r\xffgx";
char c[]="\10123\xffggx";
printf("%s %s %s",a,b,c);
return 0;
}
17) int main()
{
if((-1L>1UL)&&(-1L<1U))
printf("india will win vb series");
else
printf("australia will win vb series");
return 0;
}
18)In the below pgm,are both the values changed?
int i;
char c;
i=c;
c=i;
19) int main()
{
int j=0;
for(j=0;j<5;j++)
{
int k;
for(k=j;k>0;k--)
{
static int i;
printf("%d",i++);
}
}
return 0;
}
20)Is it a good programming practice to declare many register variables?Why?
21)Where can one use register variables?What will happen to ur register variables when u run short of registers?
22)int main()
{
unsigned int x=-1;
for(;x>=-10;x++) printf(“something is better than nothing.”);
return 0;
}
23)What are the default initialisers for the following?
a)register
b)static
c)external
d)automatic
24)What is the scope and the retention property of the following in a multifile program?
a)external
b)static
c)automatic
d)static external
25) int main()
{
int i;
{
printf("%d\n",++i);
}
i++;
printf("%d\n",i);
int j=3;
{
static int i;
i+=2;
printf("%d %d\n",i,sizeof(j++));
}
j++;
printf("%d %d\n",++i,j);
}
*******************************************************************************
(c test 6: structures and unions : Not available)
EEE ASSOCIATION
CAMPUS PLACEMENT PROGRAMME
(C test 7: pointers and files)
1) #include
#include
int main()
{
char *s;
char *fun(void);
s=fun();
printf("%s",s);
return 0;
}
char *fun(void)
{
char a[20];
strcpy(a,"hello");
return a;
}
2) #include
int main()
{
float *p=1000,*q=2000;
printf("%d",p-q);
return 0;
}
3) #include
int main()
{
FILE *fp;
fp=fopen("test.c","r");
return 0;
}
What does fp points to ?
4) FILE *fp;
fp=fopen("cpc.txt","a+");
In the above code cpc.txt is opened for __________
5) #include
int main()
{
char *s[]={"you","must","practice","well"};
char **ptr[]={s+3,s+2,s+1,s};
char ***p=ptr;
printf("\n%s",**++p);
printf("\n%s",*--*++p+1);
printf("\n%s",*p[-2]+3);
printf("\n%s",p[-1][-1]+1);
return 0;
}
6) #include
int main()
{
int y=0;
const int x=get();
int *const ptr=&y;
*ptr=1;
printf("%d %d",x,y);
return 0;
}
get(){return 0;}
7) #include
int main()
{
char ch;
int i;
scanf("%d",&i);
scanf("%c",&ch);
printf("%c %d",ch,i);
return 0;
}
What is the bug in this code and how will you eliminate it ?
8) Declare
a)a pointer to an integer constant.
b)a constant pointer to an integer.
what is the difference between the above two ?
9) /* myprog.c */
#include
int main(int argc,char *argv[])
{
int i;
i=argv[1]+argv[2]+argv[3];
printf("%d",i);
return 0;
}
What will be the output of this program if it is executed in the command prompt as follows
myprog 1 2 3
10) #include
int main()
{
int *iptr,i=2;
iptr=&i;
++*iptr;
(*iptr)++;
*iptr++;
printf("%d %p",i,iptr);
return 0;
}
assume &i=0xabcd
11) #include
int main()
{
int a[]={1,2,3,4,5,6,7,8,9,10};
void fun(int a[]);
fun(a);
return 0;
}
void fun(int a[5])
{
int i;
for(i=0;i<10;i++)
printf("%d ",a[i]);
printf("\n%d",sizeof(a));
}
12) What is the error in the following program ?
#include
int main()
{
unsigned char ch;
FILE *fp;
fp=fopen("input","r");
while((ch=getc(fp))!=EOF)
printf("%c",ch);
fclose(fp);
return 0;
}
13) #include
int main()
{
int a[]={0x4142,0x0044,0x4441,0x0044};
char *b;
b=(char *)a;
printf(b);
return 0;
}
Assume the machine has little endian architecture and give the output
14) #include
int main()
{
FILE *fp;
char str[80];
fp=fopen("trial","r");
while(!feof(fp))
{
fgets(str,80,fp);
puts(str);
}
return 0;
}
The contents of "trial.c"
Hai
Bye
15) /* hai.c */
#include
int main(int c,char *v[])
{
printf("%c",++**++v);
return 0;
}
Command line execution :
hai one two three
16) #include
int main()
{
char a[10]="NIT";
char b[10]="TRICHY",*ptra,*ptrb;
while(*ptra++=*ptrb++);
printf(a);
printf(b);
return 0;
}
17) #include
#include
int main()
{
char c[]="Three"
int *p=(int *)c,i=0;
for(;(char *)p<&c[strlen(c)];p++)
printf("%c",*p);
printf("%c",*--p);
return 0;
}
18) #include
int main()
{
int *ptr1;
char *ptr2[5],float(*ptr3)[10];
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
return 0;
}
19) #include
int main()
{
char *arr[5];
int i=0;
for(;i<5;i++)
scanf("%s",arr[i]);
for(i=0;i<5;i++)
printf("\n%s",arr[i]);
return 0;
}
Is there any error in the above code if yes what is it ?
20) int i,j=25;
int *pi,*pj=&j;
*pj=j+5;
i=*pj+5;
pi=pj;
*pi=i+j;
Assume &i=0x0f9c,&j=0xof9e and answer the following
a)*pj+2
b)what value is represented by pi ?
c)*(pi+2)
d)pi+2-pj
21) Write a[2][4][5] using pointer notation.
22) int *p;
*p=0;
combine these two statements into a single statement
23)What are the sizes of near,far & huge pointers ?
24) /* myprog.c */
#include
int main(int argc,char *argv[],char *env[])
{
int i;
for(i=1;i
int main(int c,char *v[])
{
printf("%c",++**++v);
return 0;
}
hai one two three
26) int (*a)[20];
int *b[5];
Allocate memory to a and b such that both of them can be used as a 2 dimensional array of dimension 5*20
What are the operations that can be performed on a pointer ?
27) #include
int main()
{
int a=10,*j;
void *k;
j=k=(int *)&a;
j++;
k++;
printf("\n%u % u",j,k);
return 0;
}
assume &a=0x14ad
28) #include
int main()
{
int a[10];
char *ptr=(char *)a;
printf("%d",(char*)&a[10]-ptr);
return 0;
}
29) /* myprog.c */
#include
int main(int argc,char *argv[])
{
printf("%c",*++argv[1]);
return 0;
}
myprog 23 01 83
30) Differentiate between Null pointer,NULL macro,ASCII NUL character and null string
31) Decipher the following
a)struct s(*(*(*x)[])()[];
b)int(*fp())()[];
c)int *p(char(*s)[]);
d)char(*(*x[3])())[5];
32) What is the prototype of the following functions ?
a)fseek
b)free
33) How will you access argc and argv from a function without passing them to the function as arguments ?
34) #include
int main()
{
FILE *fp=fopen("test.c","r");
printf("%d %d %d %d",fileno(stdout),fileno(stdin),fileno(stderr),fileno(fp));
fclose(fp);
return 0;
}
Hint: fileno returns filehandle(int)
35) char *p="char*p=%c%s%c;int main(){printf(p,34,p,34);return 0;}";
int main()
{
printf(p,34,p,34);
}
Hint: ASCII value of " is 34
********************************************************************************