Introduction To Programming Using C
Introduction To Programming Using C
003-007101 1 P.T.O.
(4) Which of the following is the valid variable in a C program ?
(1) main (2) sort (3) signed (4) unsigned
(a) (2) only (b) (1) and (2) only
(c) (2) (3) and (4) only (d) None of the above
(5) What will be output of the following program ?
void main()
{
int i = 1, j = 2, k = 3 ;
if (--i && ++j)
k = i +++ j--;
printf(“%d %d %d\n”, i, j, k) ;
}
(a) 0 2 3 (b) 0 3 3 (c) 1 2 3 (d) None of these
(6) What will be output of the following program ?
void main()
{
int i = 1, j = 2, k = 3 ;
for (; i < = 5 ; i++)
for (j = 1 ; j < = 7 ; j++)
k=i+j;
printf(“%d %d %d\n”, i, j, k) ;
}
(a) 5 7 14 (b) 6 8 14 (c) 5 7 12 (d) 6 8 12
(7) What will be output of the following program ?
void main ()
{
int i, j ;
for (i = 1 ; i < = 5 ; i++)
for (j = 1 ; j < = 5 ; j++)
if (i = j)
break ;
else
continue ;
printf(“%d %d \n”, i, j) ;
}
(a) 6 6
(b) 1 1
(c) Program cannot be compiled
(d) Program goes infinite without printing anything
003-007101 2
(8) What will be output of the following program ?
void main()
{
int a[5] = {10, 20, 30, 40, 50};
int *p1, *p2;
p1 = a;
p2 = &a[4];
printf(“%d \n”, p1 – p2);
}
(a) – 40 (b) cannot be determined
(c) –4 (d) 4
(9) What will be output of the following program ?
void main ()
{
int i = 5, j ;
j = ++i+i+++++i+++i;
printf(“%d %d\n”, i, j) ;
}
(a) 9 29 (b) 9 32 (c) 8 28 (d) compile time error
(10) Only operator that is different from other operators in terms of number of
operands on which it is operated is
(a) % (b) >> (c) ?: (d) ||
(11) What will be output of the following program ?
void main ()
{
int a = 5 ;
float c = 10.50;
printf(“%d\n”, (int) c % a) ;
}
(a) 2 (b) 0 (c) 0.50 (d) compile time error
003-007101 3 P.T.O.
(12) What will be output of the following program ?
void main ()
{
int a = 5, b = 10;
int fun (int);
a = fun (b)
printf(“%d %d\n”, a, b);
}
int fun (int b)
{
int c;
c = --b;
return (c);
}
(a) 9 10 (b) 99 (c) 10 9 (d) 10 10
(13) What will be output of the following program ?
void main ()
{
char str[20] = “MCA-SEM-I”;
void prn (char *);
prn (str)
}
void prn (char s[])
{
if(*s)
prn(s+1);
printf(“%c”, *s);
return;
}
(a) MCA-SEM-I
(b) I-MES-ACM
(c) Program goes infinite execution
(d) Compile time error
003-007101 4
(14) What will be output of the following program ?
void main()
{
int a[10];
void disp (int []);
printf(“%d\n” sizeof(a));
}
void disp (int a[])
{
printf(“%d”, sizeof(a));
return;
}
(a) 10 10 (b) 20 20 (c) 2 10 (d) 2 20
(15) What will be output of the following program ?
union U
{
char c;
int i;
} u1;
void main()
{
u1.i = 321;
printf(“%c\n” u1.c);
}
(a) 321
(b) Garbage value
(c) A
(d) Equivalent character with ASCII value 321
003-007101 5 P.T.O.
2. Answer any five of the following questions : 15
(1) Write a program in C that will receive an integer number from keyboard and
determine whether the given number is odd or even without using modulus
operator.
(2) When will you use simple if statement and when will you use ternary operator ?
Give a suitable example in which ternary operator is better than simple if
statement.
(3) What is back slash character constant ? What is the usefulness of it ? Explain
three such constants with example.
(4) Explain the ways of initialization of two dimensional integer array with size
3 × 4.
(5) Switch statement can take only which type of expression ? Write the syntax and
draw a flow chart of switch statement.
(6) Write a program in C to print following triangle for given N number of lines.
A B
A B C
A B C D
A B C D E
(2) Write a program to find out GCF (Greatest Common Factor) using recursive
function.
(3) What is the difference between pre test and post test loops ? Give list of each
loop available in C and explain post test loop construct with syntax, flowchart
and example.
(4) What is pointer ? Explain array of pointer and pointer to an array with suitable
example.
003-007101 6
4. Attempt any two of the following questions : 15
(1) What is storage class ? List and explain each of them with scope and life time.
(2) Write a C program that will receive N names of students. Arrange them in
alphabetical order and display the result.
(3) Write the C code to create structure RESULT with student roll number and total
marks of MCA SEM I as only two its members. Write declaration statement to
create an array of 10 elements for this structure. Write a function that will
receive this array as argument and return the roll number of the student who
obtained maximum marks from all 10 students.
(b) Write a program in C to copy one file to another in reverse order. File name
should be given as command line arguments.
______________
003-007101 7 P.T.O.
003-007101 8