C Programming
Test your C skill in programming language for campus placements by free online preparation and practice paper tests
Questions
Which of the following is not an identifier?
- Area_of_circle
- Pi-value
- 4th semester
- Count2
If i, j and k are integer variables with values 8, 15 and 4 respectively, the arithmetic expression 2 * ((i % 5) * (4 + (j - 3) / (k + 2))) results
- 26
- 36
- 34
- 32
Unsigned integer quantities are
- greater than ordinary integer quantities
- greater than ordinary integer quantities and can be negative
- lesser than ordinary integer quantities and cannot be negative
- greater than ordinary integer quantity and cannot be negative
The use of the function floor (d) returns the
- value round down to the next integer value
- absolute value of d
- value round up to the next integer
- none of these
What is the correct precedence of the following operators?
!=, &&, *, >=
- &&, *, >=, !=
- *, >=, !=, &&
- *, !=, &&, >=
- >=, !=, &&, *
In the under given expression
flag = (i < 10) ? 0 : 100
if the value of 'i' is 12, then the result is
- 0
- 10
- 100
- 12
Suppose a, b and c are integer variables assigned values 8, 3 and -5 respectively. In this case, the respective values of arithmetic expressions (ac)%b and a(c%b) are
- -1 & 16
- 1 & 16
- 1 & -16
- -1 & -16
If a C program contains the following declarations
long ix;
double dx;
the data type of the expression ((int)dx) + ix is
- double precision
- double
- long integer
- integer
Is it possible to write the following expression?
for(expression 1a, expression 1b; expression 2; expression 3)
{
statement;
}
- Yes
- No
If the declaration is float x = 123.456, then the statement printf(“%7f %7.1f “,x,x) will print
- 123.456000 & 123.5
- 123.456 & 123.4
- 123.4560000 & 123.5
- 123.456000 & 123.0
For the statement 'scanf(“%3d %3d %3d”,&a,&b,&c)'; if the input value is 1234 5678 9, then the assignments will be
- a=123 b=456 c=789
- a=123 b=567 c=9
- a=123 b=4 c=567
- a=123 b=678 c=9
Break statement is used to terminate _____ loop(s).
- for
- while
- do-while
- all of the above
The syntax of the switch statement is
switch (expression) statement
is true when the expression results in
- integer
- char
- float
- either int or char
The function definition of the statement “A function called process accepts an integer and two floating point numbers and returns a double precision quantity”, is
- float process( int i, float a, float b)
- double process(int i, double a, double b);
- double process (int i, float a, float b);
- long process(int i, float a, float b);
Which of the following is a wrong declaration of array?
- int digits[5]={1,2,3,4,5};
- float num[10];
- char color[3]={R,G,B};
- static float x[3]={2.5, 6.2, 7.8};
The strcmp function is used to __________.
- compare three strings
- compare two strings
- copy strings
- compare and then copy strings
The array declaration - float num[3][4][5] - will have ____ elements.
- 12
- 17
- 35
- 60
The declaration
char flag[]=”TRUE” will result in
- flag is a one dimensional, 4 element, character array;
- flag is a one dimensional, 5 element, character array;
- flag is a one dimensional character array containing TRUE or FALSE
- the declaration is wrong
Consider the following program segment:
main()
{
int a=2;
printf (“a= %d”,a);
modify(a);
printf (“a= %d”,a);
}
modify(a)
{
a*=3;
printf (“a= %d”,a);
return;
}
The answer printed after executing this program will be
- a=2 a=2 a=2
- a=2 a=6 a=2
- a=2 a=6 a=6
- none of these
The statement to declare a two dimensional floating point array of 15 rows and 30 columns using pointer, is
- float *(15)[30];
- float [15][30];
- float *(x)[30];
- float *x[30];
The declaration int *px means that
- p is a pointer to integer x
- both p and x are pointers to integer quantity
- px is an array of integer pointer
- px is a pointer to an integer quantity
The output of the following program is
main()
{
int a, b, c;
int num[3][4]= {1,2,3,4,5,6,7,8,9,10,11,12};
for(a=0;a<3;++a)
{
c=999;
for(b=0;b <4;++b)
if (z[a][b]<c)
c=z[a][b];
printf(“ %d”,c);
}
}
- 1 5 9
- 4 8 12
- 1 4 7 10
- 1 3 6 9 12
C pre-processor is a collection of special statements, called directives, which are executed _________.
- as and when required
- at the end of the compilation process
- at the beginning of the compilation process
- while running the program
A C program contains following declaration:
char text[80];
The for statement that permit a 60 character message and store it in array text is ________
text[i]=getchar();
- for(i=0;i<80;++i)
- for(i=0;i<=60;i++)
- for(i=1;i<60;i++)
- for(i=0;i<60;++i)