1. What would be the output of the following program, if the array begins at address 1200?
main()
{
int arr[ ]={2,3,4,1,6};
printf(“%d %d”, arr, sizeof(arr));
}
2. What would be the output of the following program, if the array begins at address 65486?
main()
{
int arr[ ]={12, 14, 15, 23, 45};
printf(“%u %u”, arr, &arr);
}
3. What would be the output of the following program, if the array begins at address 65486?
main()
{
int arr[ ]={12, 14, 15, 23, 45};
printf(“%u %u”, arr+1, &arr+1);
}
4. Would the following program compile successfully?
main()
{
char a[ ]= “ sunstroke”;
char *p=”coldwave”;
a= “coldwave”;
p=”sunstroke”;
printf(“\n %s %s”, a, p);
}
5. A pointer to a block of memory is effectively same as an array. <True/False>
6. What would be the output of the following program, if the array begins at 65472?
main()
{
int a[3][4] = {
1, 2, 3, 4,
4, 3, 2, 1,
7, 8, 9, 0
};
printf(“\n %u %u”, a+1, &a+1);
}
7. What does the following declaration mean:
int (*ptr)[10];
8.What would be the output of the following program?
main( )
{
printf(5+”Fascimile”);
}
- Error
- Facsimile
- mile
- None of the above
9.What would be the output of the following program?
main( )
{
char str1[ ] = “Hello”;
char str2[ ] = “Hello”;
if(str1 = = str2)
printf (“\n Equal”);
else
printf (“\nUnequal”);
}
A. Equal
B. Unequal
C. Error
D. None of the above
10.What would be the output of the following program?
main()
{
printf (“%c”,”abcdefgh”[4]);
}
- error
- d
- e
- abcdefgh
11.What would be the output of the following program?
main()
{
char str[7] = “Strings”;
printf(“%s”, str);
}
- Error
- Strings
- Cannot predict
- None of the above
12.What would be the output of the following program?
main()
{
char ch=’A’;
printf(“%d %d”, sizeof(ch), sizeof(‘A’));
}
A. 1 1
B. 1 2
C. 2 2
D. 2 1
13.What would be the output of the following program?
main()
{
printf(“\n %d %d %d”, sizeof(‘3’), sizeof(“3”), sizeof(3));
}
A. 1 1 1
B. 2 2 2
C. 1 2 2
D. 1 1 1
14.In the following code which function would get called, the user-defined strcpy() or the one ibn the standard library?
main()
{
char str1[]=”keep India beautiful…..emigrate!”;
char str2[40];
strcpy (str2, str1);
printf(“ \n %s”, str2);
}
strcpy( char *t, char *s)
{
while(*s)
{
*t=*s;
t++;
s++;
}
*t = ‘\0’;
}
15.What is the similarity between a structure, union and enumeration?
16.Point out the error, if any, in the following code.
Void modify( struct emp*);
Struct emp
{
char name[20];
int age;
}
main()
{
struct emp e= { “Sanjai”, 35};
modify (&e);
printf (“\n %s %d”, e.name, e.age);
}
void modify( struct emp *p)
{
strupr (p->name);
p->age = p->age + 2;
}
17.Point out the error, if any, in the following code.
main()
{
struct emp
{
char n[20];
int age;
}
struct emp e1 = {Dravid”,23};
struct emp e2 = e1;
if(e1 == e2)
printf(“ The structures are equal”);
}
- What is main returning in the following program.
Struct transaction
{
int sno;
char desc[30];
char dc;
float amount;
}
main()
{
struct transaction t;
scanf(“ %d %s %c %f”, &t.sno, t.desc, &t.dc, &t.amount);
printf(“ %d %s %c %f”, t.sno, t.desc, t.dc, t.amount);
}
18. What error would the following function give on compilation?
f (int a int b)
{
int a;
a= f(10,3.14);
printf(“%d”,a);
}
f(int aa,int bb)
{
return((float)aa+bb);
}
19. Point out the error in the following code.
main()
{
int a=10;
void f();
a=f();
printf(“\n%d”,a);
}
void f()
{
printf(“\nhi”);
}
20. point out the error , if any in the following function
main()
{
int b;
b=f(20);
printf(“%d”,b);
}
int f (int a)
{
a > 20 ? return(10) : return(20);
}
21.A Function cannot be defined inside another function<True/False>
22.Will the following function work? <Yes / No>
f1 ( int a, int b)
{
return(f2(20));
}
f2(int a )
{
return (a*a);
}
23. What are the following two notations of defining functions commonly known as:
int f( int a, float b)
{
/*some code */
}
int f(a,b)
int a: float b;
{
/*some code*/
}
24. In a function two return statements should never occur successively.
< True /False>
25. In C all functions except main() can be called recursively .
<True/False>
26. How many times the following program would print “jamboree’?
main( )
{
printf(“\n jamboree”);
main( );
}
A. Infinite number of times.
B. 32767 times
C. 65535 times
D. Till the stack doesn’t overflow
27.Would the following program always output the size of the structure as 7 bytes?
struct ex
{
char ch;
int i;
long int a;
}
28. Is the following program correct ?<Yes/No>
main()
{
char *str1 = “United”;
char *str2 = “ front”;
char *str3;
str3 = strcat (str1,str2);
printf(\n %s”,str3);
}
29.What is the difference in the following declarations?
char *p = “Samuel”;
char a[ ] = “Samuel”
30.Point out the errors, if any ,in the following program segments:
main()
{
int size;
scanf(“%d”,&size);
int arr[size];
for( i=1;i<=size;i++)
{
scanf(“%d”,arr[i]);
printf(“%d”,arr[i]);
}
}
31.What is the output
struct a{
int a=10;
char *name=”student1”;
};
void main()
{
printf(“%1d”%s”,s1.a,s1.name);
}
a)10 student1
b)1 student1
c)error
d)10student1
32.What is the output?
struct student{
int rollno;
char department;
};
void main()
{
struct student s1,s2;
scanf(“%d%c”,&s1.rollno,&s1.department);
s1=s2;
scanf(“%d%c”,&s2.rollno,&s2.department);
printf(“\n%d%c”,s1.rollno,s1.department);
printf(“\n%d%c”,s1.rollno,s1.department);
}
input
10 c
12 b
a.) 10 c
12 b
b) 10 c
10 c
c) 12 b
12 c
d) error.
33. What is the output
struct stud{
int age;
char name[10]
}s1,s2;
void main()
{
s1.age=10;
strcpy(s1.name,”sona1”);
strcpy(s2.name,”sona2”);
s2.age=10;
if(s1==s2)
printf(“s1 and s2 are equall”);
else
printf(“s1 and s2 are not equall”);
}
a)s1 and s2 are equall.
b)s1 and s2 are not equall.
c)error
d)none of this.
34. struct employee
{
char* name;
struct student
{
int rollno;
};
};
void main()
{
struct employee e1;
e1.name=”emp1”;
printf(“%s”,el.name”);
}
a)e1.n=”emp1” not allowed.
b)emp1
c)error
d)non of this.
35.What is the output?
union employee
{
char name[10];
int rollno;
}e;
void main()
{
union employee e1={“sona1”};
printf(“%d”,e1.rolllno);
gecth();
}
a)0
b)100
c)error
d)s
36.What is the output?
union employee
{
char name[10];
int rollno;
unsigned int a :4;
}e;
void main()
{
union employee e1={“sona1”};
printf(“%d”,e1.rolllno);
gecth();
}
a)0
b)100
c)error
d)s
37. What is the output?
struct employee
{
char name[10];
int rollno;
unsigned a:4;
}e;
void main()
{
struct employee e1;
scanf(“%d”,&e1.a);
printf(“%d”,e1.a);
gecth();
}
a)0
b)100
c)error
d)s
38. What is the output?
struct employee
{
unsigned a:4;
int a;
unsigned a:4;
}e;
void main()
{
struct employee e1;
printf(“%d”,sizeof (e1));
gecth();
}
a)6 byte
b)2 byte
c)4 byte
d)error
No comments:
Post a Comment