Académique Documents
Professionnel Documents
Culture Documents
#include <stdio.h>
void main()
{
int y,z;
int x=y=z=10;
int f=x;
float ans=0.0;
f=x*y;
ans=x/3.0 + y/3;
printf("%d,%.2f",f,ans);
}
/* What will be the output of this program ?
a) It will print 1000,6.66;
b) It will give a type mismatch error;
c) It will generate a compile-time error;
d) None of the above;
*/
2)#include <stdio.h>
void main(void);
double dbl=20.4530,d=4.5710,dblvar3;
void main()
{
double dbfn(void);
dblvar3=dbfn();
printf("%.2f\t%.2f\t%.2f\n",dbl,d,dblvar3);
}
double dbfn(void)
{
double d,dblvar3;
dbl=d=dblvar3=4.5;
return(dbl+d+dblvar3);
}
/* The output of the above program will be
a) 4.50 4.57 29.52;
b) 4.50 4.57 13.50;
c) 4.57 4.57 29.52;
d) 4.57 4.50 13.50; */
3)#include <stdio.h>
int SumElement(int *,int);
void main(void)
{
int x[10];
int i=10;
for(;i;)
{
i--;
*(x+i)=i;
}
printf("%d",SumElement(x,10));
}
int SumElement(int array[],int size)
{
int i=0;
float sum=0;
for(;i<size;i++)
sum+=array[i];
return sum;
}
/* What will be the output of this program ?
a) It will print 45;
b) It will produce a type mismatch error as SumElement's return
statement returns a float;
c) It will produce a compilation error in statement for(;,i,;);
d) Both (b) and (c); */
4)#include <stdio.h>
void main(void)
{
int oldvar=25, newvar=-25;
int swap(int,int);
swap(oldvar,newvar);
printf("Numbers are %d \t %d",newvar,oldvar);
}
int swap(int oldval,int newval)
{
int tempval= oldval;
oldval = newval;
newval = tempval;
}
/* The output of this program will be
a) Numbers are 25 -25
b) Numbers are 25 25
c) Numbers are -25 25
d) Numbers are -25 -25 */
5)#include <stdio.h>
void main(void);
int newval(int);
void main(void)
{
int ia[]={12,24,45,0};
int i,sum=0;
for(i=0;ia[i];i++)
{
sum+=newval(ia[i]);
}
printf("Sum = %d",sum);
}
int newval(int x)
{
static int div = 1;
return (x/div++);
}
/* The output of this program will be
a) Sum = 61;
b) Sum = 39;
c) Runtime error
d) Compilation error */
6) #include <stdio.h>
void main(void);
void main(void)
{
int var1=5,var2=5,var3=6,minmax;
minmax = (var1 > var2) ? (var1 > var3) ? var1:var3:(var2 > var3) ? var2:
var3;
printf("%d\n",minmax);
}
/* This program will
a) Produce a runtime error
b) Produce a compilation error
c) Print 5
d) Print 6 */
7)#include <stdio.h>
void main(void);
void main(void)
{
void pa(int *a,int n);
int arr[5]={5,4,3,2,1};
pa(arr,5);
}
void pa(int *a,int n)
{
int i;
for(i=0;i<n;i++)
printf("%d\n",*(a++)+i);
}
/* Which of the following is correct ?
a) The Program prints the alternate elements of array.
b) It will not compile as 'array' cannot be incremented.
c) It will print 6,5,4,3,2 on individual lines.
d) It will print 5 five times 6 */
13. ONe questions on CO, which is slight a lenghty one and I couldnt'
recollect the same.
14. Given Three trees and ONe sequence of alphabets, we are suppose
to find which operation was performed on the tress to get
that result. ie. either preorder, postorder or inorder.
Ans: To that question, all preorder
15. When the fn. is called where the return add. is stored?
ans. stack
16. What is the nece. for compiler to support recursion?
ans/ stack