Monday, July 27, 2009

some of Subex c questions

1. #include
void main()
{
int arr[]={0,1,2,3,4,5};
int i;
int *p=arr;
*p+2=10;
for(i=0;i<6;i++)
printf(“%d\n”,arr[i]);
}



2. enum marks
{
che, phy=53, math;
};
struct s
{
char name[15];
enum marks m;
}k;
void main()
{
strcpy(k.name,”Tom”);
k.m=phy;
printf(“name:%s\n”,k.name);
printf(“Physics marks:%d\n”,k.m);
k.m=che;
printf(“chemistry marks:%d\n”,k.m);
}


3. What is the o/p of the following statement?
cout<<(100==100);


4. void main()
{
extern int i;
i=20;
printf(“%d”,i);
}


5. void main()
{
int i=5;
int arr[]={-1,2,3,4,5};
for(;i==0;i++)
printf(“%d\n”,arr[i]);
}


6. void main()
{
int i=5,k;
k=++i==6;
printf(“%d\n”,k);
}

7. void main()
{
int size=10;
int arr[size];
printf(“%d”,sizeof(arr));
}



8. #include
#define first 5
#define second 7
#define last first+second
void main()
{
int i;
i=last*last;
printf("%d",i);
}

9. #include
struct s
{
int i;
struct s p;
}k;
void main()
{
k.i=10;
printf("%d",k.i);
}


10. void main()
{
char ch;
scanf(“%c”,&ch);
printf(“%c\n”,ch);
scanf(“%c”,&ch);
printf(“%c\n”,ch);
}

If ‘a’ is given as i/p o/p will be
a
a

If 4 ‘a’s are to be printed,(i/p,o/p,i/p,o/p) the fflush() function should be used.

11. void main()
{
char s1[]=”hi”;
char s2[]=”hi”;
if(s1==s2)
printf(“same”);
else
printf(“Different”);
}

No comments: