Computer Science and Information Technology - Programming in C
Exam Duration: 45 Mins Total Questions : 30
Correct way of declaring main() when it receives command line arguments.
- (a)
main()
{
int argc;
char*arg[], char*argv[]
} - (b)
main (argc,argv)
int argc;
char*argv[]; - (c)
main(int argc,char argv[])
- (d)
None of the above
Consider for loop in a C program. If the condition is missing
- (a)
it is assumed to be present and taken to be true
- (b)
it results in a syntax error
- (c)
it is asumed to be present and taken to be false
- (d)
execution will be terminated abruptly
Which of the following is incorrect about the function
(i)The use of a function avoids the need for redundant programming of the same instruction
(ii)The use of function enables a programmer to build a customized library of frequently used routine or of routines containing system depended feauture
(iii)Some function accept information but do not return anything whereas other functions return multiple values as different times
- (a)
None
- (b)
(i),(ii) and (iii)
- (c)
(i)and(ii)
- (d)
(ii) and (iii)
Pointers are of
- (a)
integer datatype
- (b)
character datatype
- (c)
unsign integer datatype
- (d)
None of the above
The operator > and < are meaningful when used with pointers ,if
- (a)
the pointers point to data of similar type
- (b)
the pointers point to the structure of similar data type
- (c)
the pointer points to element of the same array
- (d)
None of the above
As soon as a pointer variable is freed,its value
- (a)
is set to null
- (b)
because unpredictable
- (c)
is set to 1
- (d)
remains the same
If an array is used as function argument the array is passed
- (a)
by value
- (b)
by reference
- (c)
call by value
- (d)
None of these
Consider the following type definition typedef char:
X[0];
X mu Array[5];
what will size of (my Array) be?
- (a)
15 byte
- (b)
10 byte
- (c)
50 byte
- (d)
30 byte
putcbar(*(wer[1]+1));
- (a)
prints a
- (b)
prints a
- (c)
prints I
- (d)
prints b
Consider the following declaration:
typedef struct
{
char name[20];
char mid_name[5];
char sur_name[20];
}
Name;
Name class[20];
Which of the follwoing statements is correct about class?
- (a)
Claas in a new type
- (b)
Class in an array of 20 character only
- (c)
Class in an array name.mid_name and sur_name
- (d)
None of the above
Struct adder
{
Char city [10]
Char street[20]
int pincode;
};
struct
{
char name [20];
int sex;
struct adder locate;
} criminal *kd=& criminal
Pincode can be accesse by
- (a)
criminal.locate.pincode
- (b)
criminal.pincode
- (c)
\(kd\rightarrow \) locate.pincode
- (d)
\(kd.locate\rightarrow \) pincode
What will be the output of the following program?
#include<stdio.h>
int main();
{
char*S1;
char for *S2;
char hug *S3;
printf("%d%d\n",sizeof(S2),sizeof(S2),sizeof(S3));
return 0;
}
- (a)
442 in Tc/C++ compiler
- (b)
Error in code
- (c)
Error in Vc++ or gcc compiler
- (d)
Both (a) and (c)
How many times the following C program would point jamboree?
main()
{
ptintf("\n Jambooree");
main();
}
- (a)
Infinite number of times
- (b)
32767 times
- (c)
65535 times
- (d)
Till the stack doesn't overflow
The fields in a structure of C program are by default
- (a)
private
- (b)
public
- (c)
protected
- (d)
None of these
Pick the operators that associate from the right.
- (a)
?:
- (b)
+=
- (c)
=
- (d)
(a),(b) and (c)
The process of transforming one bit pattern into another by bitwise operation is called
- (a)
masking
- (b)
prunning
- (c)
binding
- (d)
chopping
Consider the following statements:
put char (get char ());
put char (get char ());
If
a
b
The input the output will be
- (a)
ab
- (b)
an error message
- (c)
This cannot be the input
- (d)
None of the above
The following program
main()
int i=1234;
printf("%d%2d%4d",i,i,i);
}
prints
- (a)
1234 1234 234
- (b)
1 2 1234
- (c)
12 12 12
- (d)
1234
The following program
main()
{
int a=4,b=2;
printf("%u",main);
}
result in
- (a)
printing of a garbage number
- (b)
an execution error
- (c)
sentinel
- (d)
None of the above
printf ("xy","ab","mn") it will print
- (a)
xy
- (b)
xy ab mn
- (c)
a garbage value
- (d)
None of theseThe
Constructor should be defined in section of a class
- (a)
public
- (b)
private
- (c)
protected
- (d)
any where in the class
The scope of nameless objects
- (a)
have local scope
- (b)
have global scope
- (c)
Only to the statement in which it is created
- (d)
Both (a) and (b)
Consider the program below:
#include<stdio.h>
int fun(int n,int *f_p)
{
int t,f;
if(n<=1)
{
*f_p=1;
}
t=fun(n_1,f_p);
f=t+*f_p;
*f_p=t;
return f;
}
int main()
{
int x=15;
printf("%d\n",fun(5,&x));
return 0;
}
The value peinted is
- (a)
6
- (b)
8
- (c)
14
- (d)
15
#include
void pri((int,int);
void printit(float,int);
int main()
{
float a=3.14;
int i=99;
pri(i,a);
printit(a,i);
return 0;
}
void pri(int i,int a)
{
printf("i=%d a=%f\n',i,a);
printf("a=%f i=%d\n",a,i);
}
void printit(float a,int i)
{
printf("a=%fi=%d\n",a.i);
printf("i=%d a=%f\n",i,a)
}
The above program prints
- (a)
i=99 a=3.00000 a=3.000000 i=99 a=3.1400000 i=99 i=99 a=3.140000 - (b)
i=99 a=0.00000 a=0.000000 i=1234503 a=3.1400000 i=99 i=99 a=3.140000 - (c)
i=99 a=3.140000 a=0 a=0 a=3.14 i=99 i=99 a=3.14 - (d)
None of the above
#include<stdio.h>
#define ISUPPER(x)(x>=65&&x<=90)
#define(ISLOWER(x)(x>=97&&x<=122]
#define ISALPHA(x) (ISUPPER(x) II (ISLOWER(x))
int main()
{
char ch='+';
if(ISALPHA(ch))
printf("ch contains an alphabet\n");
else
printf("ch doesn't contain an alphabet\n");
return 0;
}
Which is true for the above program?
- (a)
ch contains an alphabet
- (b)
ch doesn't an alphabet
- (c)
Error
- (d)
No output
main()
{
struct node
{
int a;
int b;
int c;
};
struc nodeS={3,2,4};
struct node*ptr=&S;
printf("%d",*(int*)(pt+2));
}
The output for the program is
- (a)
3
- (b)
5
- (c)
4
- (d)
Unexpected result
main()
{
int i=10;
i=!i>12;
pritf("i=%d",i);
}
Output of the program is
- (a)
1
- (b)
0
- (c)
10
- (d)
12
main()
{
Char a[]="visual c++";
Char*b="visual c++";
printf("%d%d",size of (a),size of (b));
}
What is the output of the above program?
- (a)
11 2
- (b)
2 11
- (c)
2 2
- (d)
11 11
# define PRINT(int) printf("int=%d\n",int);
main()
{
int x=1,y=1,z=1;
x+=y+=z;
}
The above code segment will print
- (a)
0
- (b)
1
- (c)
2
- (d)
3
#include <stdio.h>
int i=0;
main()
{
auto i=1;
print f("%d",i);
{
int i=2;
printf(%d",i);
{
i+=1;
printf("%d",i);
}
printf("%d",i);
}
printf("%d",i);
}
Here 3rd printf will print
- (a)
1
- (b)
2
- (c)
3
- (d)
4