URDINESH: Objective C
Showing posts with label Objective C. Show all posts
Showing posts with label Objective C. Show all posts

Thursday, May 8, 2014

Objective C Debugging Questions and Answers Part 2

1)      Find  the output for the following program
#include<stdio.h>
main()
{
                  int y[4]=={6,7,8,9};
                  int *ptr=y+2;
                  printf(“%d\n”,ptr[1]);
}
(a) 6                 (b)7                  (c)8                  (d)9
            ANS :(d)9

2)      char txt[20]=”Helloworld!\0”.=;
How many bytes are allocated by the definition above?
 (a)11bytes      (b)12bytes       (c)13bytes       (d)20bytes
ANS :(d)20bytes

3)      What would be the output of the given program?
#include<stdio.h>
main()
{
            int x,y=10;
            x=y*NULL;
            printf(“%d”,x);
}
(a)Error            (b)0      (c)10    (d)Garbagevalue
ANS :(b)0

4)      Find the output for the given program.
#include<stdio.h>
main()
{
            int a=36,b=9;
            printf(“%d”,a>>a/b-2);
}
(a)9                  (b)7                  (c)5                  (d)None of these
ANS :(a)9

5)      What would be the output for the given program?
#include<stdio.h>
main()
{
            char far *s1,*s2;
            printf(“%d%d”,sizeof(s1),sizeof(s2));
}
(a)2,2               (b)4,4               (c)4,2               (d)Garbagevalue
ANS :(c)4,2

6)      Check out the answer for the given program.
#include<stdio.h>
main()
{
            extern int i;
            i=20;
            printf(“%d”,i);
}
(a)20    (b)Compile Error         (c)0      (d)Linker Error
ANS :(d)Linker Error

7)      What would be the output of the following program?
#include<stdio.h>
main()
{
            int i=-3,j=2,k=0,m;
            m=++i||++j&&k;
            printf(“\n%d%d%d%d”,i,j,k,m);
}
(a)-3,2,0,1        (b)-2,3,1,0       (c)-2,2,0,1                    (d)-4,3,1,1
ANS :(c)-2,2,0,1

8)      Find the output for the given program.
#include<stdio.h>
main()
{
            int a=10;
            printf(“%d”,printf(“%d”,a));
}
(a)Error            (b)10    (c)1010            (d)102
ANS :(d)102

9)      Find the output for the given program.
#include<stdio.h>
main()
{
            Printf(“%f”,log(36.0));
}
 (a)36.0            (b)Compile Error         (c)0.000                       (d)Linking Error
ANS :(c)0.000

10)  Find the answer for the following program.
#include<iostream.h>
void main()
{
            char p[]=”\n”;
            p[1]=’c’;
            cout.<<p,65;
            getch();
}                     
 (a)A                (b)C                 (c)65                (d)Error
ANS :(b)C

11)  Find out the output for the given program.
#include<stdio.h>
void main()
{
            int a=10,b=20;
            char x=1,y=0;
            if(a,b,x,y)
            {
                        printf(“EXAM”);
            }
}
(a)XAM          (b)EXAM        (c)Compile Error         (d)None of these
ANS :(c)Compile Error

12)  What would be the output for the following program?
#include<stdio.h>
char *myfun(char *ptr)
{
            ptr+=3;
            return(ptr);
}
int main()
{
            char *x,*y;
            y=”HELLO”;
            y=myfun(x);
            printf(“y=%s\n”,y);
            return 0;
}
(a)Y=HELLO             (b)Compile Error         (c)Linking Error          (d)No output
ANS :(b)Compile Error

13)  Find the output for the following program.
#include<iostream.h>
main()
{
            register i=5;
            char j[]=”hello”;
            cout<<j<<i;
}
 (a)hello5                     (b)Error           (c)Runtime Error                     (d)hello
ANS :(a)hello5

14)  Find the output of the following  program.
#include<stdio.h>
main()
{
            int arr[]={12,13,14,15,16};
            printf(“%d%d%d”,sizeof(arr),sizeof(*arr),sizeof(arr[0]));
}          
(a)4,1002,12                (b)10,1002,2    (c)10,2,2          (d)Error
ANS:(c)10,2,2

15)  What would be the output for the following program?
#inlcude<stdio.h>
void main()
{
int const *p=5;
printf(“%d”,++(*p));
}
(a)5                  (b)6                  (c)3275                        (d)Compiler Error
ANS :(d)Compile Error

16)  What would be the output for the following program?
#include<iostream.h>
int main()
{
            int i=3,j=5;
            cout<<(i+j)++;
            return 0;
}
(a)8                  (b)9      (c)Compile Error         (d)No output
ANS :(c)Compile Error

17)  What function will read  a specified number of elements from a file?
(a)fileread ()                (b)getline()                  (c)fread()                     (d)getread()
ANS :(c)fread()

18)  Find the output of the following  program.
#include<stdio.h>
main()
{
            char str[]=”S/065AB”;
            printf(“\n%d”,sizeof(str));
}
(a)7                  (b)6                  (c)5                  (d)Error
ANS :(c)5

19)  What would be the output for the given program?
#include <fstream.h>
void main () 
{
               ifstream f1;
         ofstream f2;
         f1.open("scores.96");
         f2.open("final.96");
               int s1, s2, s3;
         float w1, w2, w3;
               f1 >> s1 >> w1;
               f1 >> s2 >> w2;
               f1 >> s3 >> w3;
               f2 << (s1*w1+s2*w2+s3*w3);
       }
(a)    Abnormal Termination  (b)Floating point error (c)Both 'a' and 'c' (d)None
     ANS :(c)Both ‘a’ and ‘c’

20)  What is the output of the following program?
#include<stdio.h>
main()
{
            int a=10;
            printf(“%d&i”a,10);
}
(a)Error                        (b)10                (c)1010                        (d)None of these
ANS :(d)None of these

21)  What would be the output of the following program?
#include<stdio.h>
main()
{
            int x[4]={1,2,3};
            printf(“%d%d%D”,x[3],x[2],x[1]);
}
(a)03%D          (b)000              (c)032              (d)321
ANS :(a)03%D

22)  Find the output for the given program.
#include<stdio.h>
main()
{
            printf(3+”goodbye”);
}
(a)goodbye      (b)dbye            (c)odbye          (d)3goodbye
ANS :(b)dbye

23)  What would be the output of the given program?
#include<stdio.h>
main()
{
            int i,j
            for(i=0;i<=10;i++)
            {
                        j+=5;
                        assert(i<5);
            }
}
(a)Linking Error          (b)Compiler Error        (c)No output   (d)Runtime Error
ANS :(a)Linking Error

24)  Find the output for the given program.
#include <iostream.h>
typedef int Bool;
const Bool TRUE = 1;
const Bool FALSE = 0;
void main() 
{
                int zero = 0;
  int two = 2;
  int three = 3;
  cout << (FALSE && (1/zero == 5)) << endl;
  cout << ((1/zero == 5) && FALSE) << endl;
  cout << ((1/zero == 5) && (two == three)) << endl;
}
 
(a)TRUE     (b)FALSE   (c)Divide Error   (d)none
ANS :(c)Divide Error

25)  What would be the output for the given program?
#include<stdio.h>
#include<conio.h>
main()
            {
                        clrscr();
                        printf(“%d\n”,clrscr());
}
(a)Error            (b)100  (c)Compiler Error        (d)Infinite Loop
ANS :(b)100

26)  Check out the answer for the given program.
#include<stdio.h>
main()
{
            int counter=40;
            for(;counter;)
            counter--;
            printf(“%d\n”,counter);          
}
(a)40                (b)-40              (c)0                  (d)Error
ANS :(c)0

27)  What would be the output of the following program?
#include<stdio.h>
main()
{
            main();
}
(a)Compile Error     (b)Empty Screen       (c)Runtime Error       (d)Garbagevalue
ANS :(c)Runtime Error

28)  Find the output for the given program.
#include<stdio.h>
void main()
{
            int i=5;
            printf(“%d”,i+++++i);
}
(a)5+5              (b)5+++++5                (c)No output               (d)Error
ANS :(c)No output

29)  Find the output for the given program.
#include<stdio.h>
main()
{
            printf(“%d”,out);
}
int out=100;
 (a)out              (b)100              (c)Compile Error                     (d)None of these
ANS :(c)Compile Error

30)  Find the answer for the following program.
#include<stdio.h>
 main()
{
                        long int a=scanf(“%ld%ld”,&a,&a);
                        printf(“%ld”,a);
}
(a)Error            (b)Garbagevalue          (c)0                  (d)2

ANS :(d)2





                 *******Thank you for reading and All the best**************

Your comments will help me a lot...please give your comments which will encourage me to post more.....

Objective C Debugging Questions and Answers part 1

1)      Point out the error, if any, in the following program.
#include<stdio.h>
main()
{
                  int i=1,j=2;
                  switch(i)
                  {
                              case 1:
                                          printf(“Good”);
                                          break;
                              case j:
                                          printf(“Bad”);
                                          break;
                  }
}
(a) Error     (b)Good          (c)Bad             (d)GoodBad
ANS :(a)Error

2)      Find the output for the given program.
#include<stdio.h>
main()
{
            int i=4z=12;
            if(i=5&&z>5)
            printf(“\nLet us C”);
            else
            printf(“\nwish C was free”);
}
(a)Let us C      (b)wish C was free      (c)Error            (d)No output
ANS :(a)Let us C

3)      What would be the output of the given program?
#include<stdio.h>
main()
{
            int big,a,b,c;
            a=2,b=3,c=4;
            big=(a>b?(a>c?3:4):(b<c?6:8));
            printf(“%d”,big);
}
(a)Error            (b)3      (c)6      (d)8
ANS :(d)8

4)      Find the output for the given program.
#include<stdio.h>
main()
{
            extern int i;
            i=20;
            printf(“%d”,i);
}
(a)20    (b)Compile Error         (c)0      (d)Linker Error
ANS :(d)Linker Error

5)      What would be the output for the given program?
#include<stdio.h>
main()
{
            int a=10,*j;
            void *k;
j=k=&a;
j++;
k++;
printf(“\n%u%u”,j,k);
}
(a)10,11           (b)0      (c)Linker Error            (d)Compiler Error
ANS :(d)Compiler Error

6)      Check out the answer for the given program.
#include<iostream.h>
main()
{
            int x=77;
            float y=5.1252;
            char z=’A’;
            char city[15];
            cout<<”x=”<<(char)x<<endl;
            cout<<”y=”<<(int)y<<endl;
            cout<<”z=”<<(int)z;
}
(a)65,5,M        (b)M,5,65        (c)Compiler Error        (d)Linker Error
ANS :(b)M,5,65

7)      What would be the output of the following program?
#include<stdio.h>
#define PRODUCT(X) (X*X)
void main()
{
            int i=3,j,k;
            j=PRODUCT(i++);
            k=PRODUCT(++i);
            printf(“\n%d%d”,j,k);
}
(a)3,4               (b)9,9               (c)49,5             (d)9,49
ANS :(d)9,49

8)      Find the output for the given program.
#include<stdio.h>
main()
{
            int i=10;
            i=!i>14;
            printf(“i=%d”,i);
}
(a)i=13             (b)i=10            (c)i=0               (d)No output
ANS :(c)i=0

9)      Find the output for the given program.
#include<stdio.h>
main()
{
            int k=35,*z,*y;
            z=&k;
            y=z;
            *z++=*y++;
            k++;
            printf(“k=%d z=%d y=%d”,k,z,y);
}
If suppose address of k is 1000. what is the value of k,z,y?
(a)k=36 z=-10 y=-10                           (b)k=1010 z=1012 y=35                    
(c)k=1012 z=1010 y=1008                 (d)None
ANS :(a)k=36 z=-10 y=-10

10)  Find the answer for the following program.
#include<iostream.h>
void main()
{
            char c;
            cout<<”Enter text(press F6 to end)”;
            while(cin.get())
            {
                        if(c==’s’)
                        cin.putback(‘s’);
                        cout.put(c);
                        }
                        return 0;
}
If input is “cplusplus”
(a)cpluss          (b)Error           (c)No output               (d)cplusspluss
ANS :(d)cplusspluss

11)  Find out the output for the given program.
#include<stdio.h>
main()
{
            int a=2,*f1,*f2;
            f1=f2=&a;
            *f2+=*f2+=a+=2.5;
            printf(“\n%d%d%d”,a,*f1,*f2);
}
(a)2.5,2.5,2.5   (b)16.5,16.5,16.5         (c)15.5,15.5,15.5         (d)16,16,16
ANS :(d)16,16,16

12)  What would be the output for the following program?
#include<stdio.h>
main()
{
            int i=300;
            char *ptr=&i;
            *++ptr=2;
            printf(“%d”,i);
}
(a)302              (b)119              (c)556              (d)298
ANS :(c)556

13)  Find the output for the following program.
#include<iostream.h>
main()
{
            char text[20];
            int len;
            cout<<”Enter text:”;
            cin.getline(text,20);
            len=cin.getcount();
            cout<<len;
}
If text is virtual, what is ouput of len?
(a)6                  (b)7                  (c)8                  (d)Error
ANS :(c)8

14)  Find the output of the following  program.
#include<stdio.h>
main()
{
            enum colors{BLACK,BLUE,GREEN};
            printf(“%d..%d..%d”,BLACK,BLUE,GREEN);
}
(a)0..1..2          (b)2..5..6          (c)Undeclared variables          (d)None
ANS:(a)0..1..2

15)  What would be the output for the following program?
#inlcude<stdio.h>
main()
{
            int i;
            printf(“%d”,scanf(“%d”,&i));//value 10 is given as input
}
(a)1                  (b)10                (c)Linker Error                        (d)Compiler Error
ANS :(a)1


16)  What would be the output for the following program?
#include<iostream.h>
main()
{
            unsigned int=65536;
            cout<<”x=”<<x;
}
(a)0                  (b)Garbagevalue          (c)Error            (d)65536
ANS :(a)0

17)  What is the output for the given program?
#include<stdio.h>
main()
{
            int i=10;
            i=i>14;
            printf(“\n%d”,i);
}
(a)1                  (b)10                (c)0                  (d)14
ANS :(c)0

18)  Find the output of the following  program.
#include<stdio.h>
main()
{
            char not;
            not=!2;
            printf(“%d”,not);
}
(a)1                  (b)0                  (c)Error                        (d)No output
ANS :(b)0

19)  What would be the output for the given program?
#include<iostream.h>
void main()
{
            int a=2,*pa,*ra;
            pa=&a;
            ra=a;
            cout<<”a=”<<a<<”*pa=”<<*pa<<”ra=”<<ra;
}
(a)Compiler Error        (b)Linker Error            (c)No output       (d)None of this
ANS :(a)Compiler Error

20)  What is the output of the following program?
#include<stdio.h>
main()
{
            int i;
            i=1;
            i=i+2 * i++;
            printf(“%d”,i);
}
(a)5                  (b)2                  (c)4                  (d)3
ANS :(c)4

21)  What would be the output of the following program?
#include<stdio.h>
main(0
{
            char *str1=”abcd”;
            char *str2=”abcd”;
            printf(“%d%d%d”,sizeof(str1),sizeof(str2),sizeof(“abcd”));
}
(a)144              (b)244              (c)255              (d)155
ANS :(c)255

22)  Find the output for the given program.
#include<stdio.h>
main()
{
            int c=--2;
            printf(“c=%d”,c);
}
(a)c==-2          (b)c=2             (c)Error            (d)Garbage value
ANS :(c)Error

23)  What would be the output of the given program?
#include<stdio.h>
main()
{
            int i,j
            for(i=0;i<=10;i++)
            {
                        j+=5;
                        assert(i<5);
            }
}
(a)Linking Error          (b)Compiler Error        (c)No output   (d)Runtime Error
ANS :(a)Linking Error

24)  Find the output for the given program.
#include<stdio.h>
main()
{
            char *p=”hai friends”,*p1;
            p1=p;
            while(*p!=’/0’)++*p++;
            printf(“%s%s”,p,p1);
}
(a)Error            (b)ibj!gsjfoet               (c)No output   (d)None of these
ANS :(c)No output

25)  What would be the output for the given program?
#include<stdio.h>
#include<conio.h>
main()
            {
                        clrscr();
                        printf(“%d\n”,clrscr());
}
(a)Error            (b)100  (c)Compiler Error        (d)Infinite Loop
ANS :(b)100

26)  Check out the answer for the given program.
#include<stdio.h>
main()
{
            printf(“\nab”);
            printf(“\bsi”);
            printf(“\nrna”);
           
}
(a)hai               (b)absina          (c)ab sina         (d)sp abha
ANS :(a)hai

27)  What would be the output of the following program?
#include<stdio.h>
void main()
{
            while(1)
            {
                        if(printf(“%d”,printf(“%d”)))
                        break;
                        else
                        continue;
}
(a)0                  (b)2                  (c)1      (d)Garbagevalue
ANS :(d)Garbagevalue

28)  Find the output for the given program.
#include<stdio.h>
void main()
{
            void *v;
            int integer=2;
            int *i=&integer;
            v=i;
            printf(“%d”,(int*)*v);
}
(a)2                  (b)0                  (c)Compiler Error                    (d)Linker Error
ANS :(c)Compiler Error

29)  Find the output for the given program.
#include<stdio.h>
main()
{
            int i=257;
            int *iPtr=&i;
            printf(“%d%d”,*((char*)iPtr),*((char*)iPtr+1));       
}
 (a)10,11          (b)257,257       (c)257,752                   (d)1,1
ANS :(d)1,1

30)  Find the answer for the following program.
#include<stdio.h>
 main()
{
                        int y[4]={6,7,8,9};
                        int *ptr=y+2;
                        printf(“%d\n”,ptr[1]);
}
(a)6      (b)7      (c)8                  (d)9

ANS :(d)9





                 *******Thank you for reading and All the best**************

Your comments will help me a lot...please give your comments which will encourage me to post more.....

Followers