UPDATED:

How To Make A Simple Calculator By C Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... This blog is under construction!!!!
Namecheap.com

Programming problem practice


programming problems.Here we set two types of Question pattern for you.
1. General Question(GNQ)
2. Objective Question(OBQ).

if you want to submit answers,submit it in comment.
Submission rules:
  • For General Question (GNQ):
  • 1.Write the program in pasteUbuntu content area.
  • 2.Give poster name(your name) and Syntax type.
  • 3.Click paste and comment here with your name,problem Genre,number and the link.
  • Example:
    Your Name, GNQ/4. http://paste.ubuntu.com/16718350
  • For Objective Question (OBQ):
  • 1.Comment here with your name, problem Genre and answer 
  • Example:
    Your Name, OBQ. 1.a/2.b/3.a/4.d....
  • if you need answer leave a comment below.

  • Exercise:
  • General Question(GNQ):
Questions will post soon.....




  • Objective Questions(OBQ):

  • 1.Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
    A.rem = 3.14 % 2.1;
    B.rem = modf(3.14, 2.1);
    C.rem = fmod(3.14, 2.1);
    D.Remainder cannot be obtain in floating point division.  

    2. 
    What are the types of linkages?
    A.Internal and ExternalB.External, Internal and None
    C.External and NoneD.Internal

    3. 
    Which of the following special symbol allowed in a variable name?
    A.* (asterisk)B.| (pipeline)
    C.- (hyphen)D._ (underscore)
    4. 
    Is there any difference between following declarations?
    1 :extern int fun();
    2 :int fun();
    A.Both are identical
    B.No difference, except extern int fun(); is probably in another file
    C.int fun(); is overrided with extern int fun();
    D.None of these
    5. 
    How would you round off a value from 1.66 to 2.0?
    A.ceil(1.66)B.floor(1.66)
    C.roundup(1.66)D.roundto(1.66)
    6. 
    By default a real number is treated as a
    A.floatB.double
    C.long doubleD.far double
    7. 
    Which of the following is not user defined data type?
    1 :
    struct book
    {
        char name[10];
        float price;
        int pages;
    };
    2 :
    long int l = 2.35;
    3 :
    enum day {Sun, Mon, Tue, Wed};
    A.1B.2
    C.3D.Both 1 and 2
    8. 
    Is the following statement a declaration or definition?
    extern int i;
    A.DeclarationB.Definition
    C.FunctionD.Error
    9. 
    Identify which of the following are declarations
    1 :extern int x;
    2 :float square ( float x ) { ... }
    3 :double pow(double, double);
    A.1B.2
    C.1 and 3D.3
    10. 
    In the following program where is the variable a getting defined and where it is getting declared?
    #include<stdio.h>
    int main()
    {
        extern int a;
        printf("%d\n", a);
        return 0;
    }
    int a=20;
    
    A.extern int a is declaration, int a = 20 is the definition
    B.int a = 20 is declaration, extern int a is the definition
    C.int a = 20 is definition, a is not defined
    D.a is declared, a is not defined
    11. 
    When we mention the prototype of a function?
    A.DefiningB.Declaring
    C.PrototypingD.Calling
    12. 
    What is the output of the program given below ?
    #include<stdio.h>
    int main()
    {
        enum status { pass, fail, atkt};
        enum status stud1, stud2, stud3;
        stud1 = pass;
        stud2 = atkt;
        stud3 = fail;
        printf("%d, %d, %d\n", stud1, stud2, stud3);
        return 0;
    }
    
    A.0, 1, 2B.1, 2, 3
    C.0, 2, 1D.1, 3, 2
    13. 
    What will be the output of the program in 16 bit platform (Turbo C under DOS)?
    #include<stdio.h>
    int main()
    {
        extern int i;
        i = 20;
        printf("%d\n", sizeof(i));
        return 0;
    }
    
    A.2
    B.4
    C.vary from compiler
    D.Linker Error : Undefined symbol 'i'
    14. 
    What is the output of the program?
    #include<stdio.h>
    int main()
    {
        extern int a;
        printf("%d\n", a);
        return 0;
    }
    int a=20;
    
    A.20B.0
    C.Garbage ValueD.Error
    15. 
    What is the output of the program in Turbo C (in DOS 16-bit OS)?
    #include<stdio.h>
    int main()
    {
        char *s1;
        char far *s2;
        char huge *s3;
        printf("%d, %d, %d\n", sizeof(s1), sizeof(s2), sizeof(s3));
        return 0;
    }
    
    A.2, 4, 6B.4, 4, 2
    C.2, 4, 4D.2, 2, 2
    16. 
    What is the output of the program
    #include<stdio.h>
    int main()
    {
        struct emp
        {
            char name[20];
            int age;
            float sal;
        };
        struct emp e = {"Tiger"};
        printf("%d, %f\n", e.age, e.sal);
        return 0;
    }
    
    A.0, 0.000000B.Garbage values
    C.ErrorD.None of above
    17. 
    What will be the output of the program?
    #include<stdio.h>
    int X=40;
    int main()
    {
        int X=20;
        printf("%d\n", X);
        return 0;
    }
    
    A.20B.40
    C.ErrorD.No Output
    18. 
    What is the output of the program
    #include<stdio.h>
    int main()
    {
        int x = 10, y = 20, z = 5, i;
        i = x < y < z;
        printf("%d\n", i);
        return 0;
    }
    
    A.0B.1
    C.ErrorD.None of these
    19. 
    What is the output of the program
    #include<stdio.h>
    int main()
    {
        extern int fun(float);
        int a;
        a = fun(3.14);
        printf("%d\n", a);
        return 0;
    }
    int fun(int aa)
    {
        return (int)++aa;
    }
    
    A.3B.3.14
    C.D.4
    E.Compile Error
    20. 
    What is the output of the program?
    #include<stdio.h>
    int main()
    {
        union a
        {
            int i;
            char ch[2];
        };
        union a u;
        u.ch[0] = 3;
        u.ch[1] = 2;
        printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i);
        return 0;
    }
    
    A.3, 2, 515B.515, 2, 3
    C.3, 2, 5D.None of these
    21. 
    In the following program how long will the for loop get executed?
    #include<stdio.h>
    int main()
    {
        int i=5;
        for(;scanf("%s", &i); printf("%d\n", i));
        return 0;
    }
    
    A.The for loop would not get executed at all
    B.The for loop would get executed only once
    C.The for loop would get executed 5 times
    D.The for loop would get executed infinite times
    22. 
    What will be the output of the program?
    #include<stdio.h>
    int main()
    {
        int X=40;
        {
            int X=20;
            printf("%d ", X);
        }
        printf("%d\n", X);
        return 0;
    }
    
    A.40 40B.20 40
    C.20D.Error
    23. 
    Point out the error in the following program (if it is compiled with Turbo C compiler).
    #include<stdio.h>
    int main()
    {
        display();
        return 0;
    }
    void display()
    {
        printf("IndiaBIX.com");
    }
    
    A.No error
    B.display() doesn't get invoked
    C.display() is called before it is defined
    D.None of these
    24. 
    Point out the error in the following program.
    #include<stdio.h>
    int main()
    {
        void v = 0;
    
        printf("%d", v);
    
        return 0;
    }
    
    A.Error: Declaration syntax error 'v' (or) Size of v is unknown or zero.
    B.Program terminates abnormally.
    C.No error.
    D.None of these.

    25. 
    Point out the error in the following program.
    #include<stdio.h>
    struct emp
    {
        char name[20];
        int age;
    };
    int main()
    {
        emp int xx;
        int a;
        printf("%d\n", &a);
        return 0;
    }
    
    A.Error: in printfB.Error: in emp int xx;
    C.No error.D.None of these.
    26. 
    Which of the following is correct about err used in the declaration given below?
     typedef enum error { warning, test, exception } err;
    A.It is a typedef for enum error.
    B.It is a variable of type enum error.
    C.The statement is erroneous.
    D.It is a structure.
    27. 
    Point out the error in the following program.
    #include<stdio.h>
    int main()
    {
        int (*p)() = fun;
        (*p)();
        return 0;
    }
    int fun()
    {
        printf("IndiaBix.com\n");
        return 0;
    }
    
    A.Error: in int(*p)() = fun;
    B.Error: fun() prototype not defined
    C.No error
    D.None of these
    28. 
    Which of the declaration is correct?
    A.int length;B.char int;
    C.int long;D.float double;
    29. 
    Which of the following operations are INCORRECT?
    A.
    int i = 35; i = i%5;
    B.
    short int j = 255; j = j;
    C.
    long int k = 365L; k = k;
    D.
    float a = 3.14; a = a%3;
    30. 
    Which of the following correctly represents a long double constant?
    A.6.68B.6.68L
    C.6.68fD.6.68LF
    31. 
    Which of the structure is incorrcet?
    1 :
    struct aa
    {
        int a;
        float b;
    };
    2 :
    struct aa
    {
        int a;
        float b;
        struct aa var;
    };
    3 :
    struct aa
    {
        int a;
        float b;
        struct aa *var;
    };
    A.1B.2
    C.3D.1, 2, 3
    32. 
    Which of the structure is correct?
    1 :
    struct book
    {
        char name[10];
        float price;
        int pages;
    };
    2 :
    struct aa
    {
        char name[10];
        float price;
        int pages;
    }
    3 :
    struct aa
    {
        char name[10];
        float price;
        int pages;
    }
    A.1B.2
    C.3D.All of above

    33. 
    1 :typedef long a;
    extern int a c;
    2 :typedef long a;
    extern a int c;
    3 :typedef long a;
    extern a c;
    A.1 correctB.2 correct
    C.3 correctD.1, 2, 3 are correct
    34. 
    long double can be used if range of a double is not enough to accommodate a real number.
    A.TrueB.False
    35. 
    float is 4 bytes wide, whereas a double is 8 bytes wide.
    A.TrueB.False
    36. 
    If the definition of the external variable occurs in the source file before its use in a particular function, then there is no need for an extern declaration in the function.
    A.TrueB.False

    37. 
    Size of short integer and long integer can be verified using the sizeof()operator.
    A.TrueB.False
    38. 
    Range of double is -1.7e-38 to 1.7e+38 (in 16 bit platform - Turbo C under DOS)
    A.TrueB.False
    39. 
    Size of short integer and long integer would vary from one platform to another.
    A.TrueB.False
    40. 
    Range of float id -2.25e+308 to 2.25e+308
    A.TrueB.False
    41. 
    Is there any difference in the following declarations?
    int myfun(int arr[]);
    int myfun(arr[20]);
    A.YesB.No
    42. 
    Suppose a program is divided into three files f1, f2 and f3, and a variable is defined in the file f1 but used in files f2 and f3. In such a case would we need the externdeclaration for the variables in the files f2 and f3?
    A.YesB.No
    43. 
    Global variable are available to all functions. Does there exist a mechanism by way of which it available to some and not to others.
    A.YesB.No
    44. 
    Is it true that a global variable may have several declarations, but only one definition?
    A.YesB.No
    45. 
    Is it true that a function may have several declarations, but only one definition?
    A.YesB.No
    46. 
    What will be the output of the program?
    #include<stdio.h>
    int main()
    {
        float a=0.7;
        if(a < 0.7)
            printf("C\n");
        else
            printf("C++\n");
        return 0;
    }
    
    A.CB.C++
    C.Compiler errorD.Non of above
    47. 
    How many times "IndiaBIX" is get printed?
    #include<stdio.h>
    int main()
    {
        int x;
        for(x=-1; x<=10; x++)
        {
            if(x < 5)
                continue;
            else
                break;
            printf("IndiaBIX");
        }
        return 0;
    }
    
    A.Infinite timesB.11 times
    C.0 timesD.10 times
    48. 
    How many times the while loop will get executed if a short int is 2 byte wide?
    #include<stdio.h>
    int main()
    {
        int j=1;
        while(j <= 255)
        {
            printf("%c %d\n", j, j);
            j++;
        }
        return 0;
    }
    
    A.Infinite timesB.255 times
    C.256 timesD.254 times
    49. 
    What will be the output of the program?
    #include<stdio.h>
    int main()
    {
        int i=0;
        for(; i<=5; i++);
            printf("%d", i);
        return 0;
    }
    
    A.0, 1, 2, 3, 4, 5B.5
    C.1, 2, 3, 4D.6
    50. 
    What will be the output of the program?
    #include<stdio.h>
    int main()
    {
        int a = 500, b = 100, c;
        if(!a >= 400)
            b = 300;
        c = 200;
        printf("b = %d c = %d\n", b, c);
        return 0;
    }
    
    A.b = 300 c = 200B.b = 100 c = garbage
    C.b = 300 c = garbageD.b = 100 c = 200
    51. 
    What will be the output of the program?
    #include<stdio.h>
    int main()
    {
        int x=1, y=1;
        for(; y; printf("%d %d\n", x, y))
        {
            y = x++ <= 5;
        }
        printf("\n");
        return 0;
    }
    
    A.2 1
    3 1
    4 1
    5 1
    6 1
    7 0
    B.2 1
    3 1
    4 1
    5 1
    6 1
    C.2 1
    3 1
    4 1
    5 1
    D.2 2
    3 3
    4 4
    5 5

    52. 
    What will be the output of the program?
    #include<stdio.h>
    int main()
    {
        int i=3;
        switch(i)
        {
            case 1:
                printf("Hello\n");
            case 2:
                printf("Hi\n");
            case 3:
                continue;
            default:
                printf("Bye\n");
        }
        return 0;
    }
    
    A.Error: Misplaced continueB.Bye
    C.No outputD.Hello Hi
    53. 
    Point out the error, if any in the program.
    #include<stdio.h>
    int main()
    {
        int i = 1;
        switch(i)
        {
            printf("This is c program.");
            case 1:
                printf("Case1");
                break;
            case 2:
                printf("Case2");
                break;
        }
    return 0;
    }
    
    A.Error: No default specified
    B.Error: Invalid printf statement after switch statement
    C.No Error and prints "Case1"
    D.None of above
    54. 
    What will be the output of the program ?
    #include<stdio.h>
    
    int main()
    {
        int a[5] = {5, 1, 15, 20, 25};
        int i, j, m;
        i = ++a[1];
        j = a[1]++;
        m = a[i++];
        printf("%d, %d, %d", i, j, m);
        return 0;
    }
    
    A.2, 1, 15B.1, 2, 5
    C.3, 2, 15D.2, 3, 20
    55. 
    What will be the output of the program ?
    #include<stdio.h>
    
    int main()
    {
        static int a[2][2] = {1, 2, 3, 4};
        int i, j;
        static int *p[] = {(int*)a, (int*)a+1, (int*)a+2};
        for(i=0; i<2; i++)
        {
            for(j=0; j<2; j++)
            {
                printf("%d, %d, %d, %d\n", *(*(p+i)+j), *(*(j+p)+i), 
                                        *(*(i+p)+j), *(*(p+j)+i));
            }
        }
        return 0;
    }
    
    A.1, 1, 1, 1
    2, 3, 2, 3
    3, 2, 3, 2
    4, 4, 4, 4
    B.1, 2, 1, 2
    2, 3, 2, 3
    3, 4, 3, 4
    4, 2, 4, 2
    C.1, 1, 1, 1
    2, 2, 2, 2
    2, 2, 2, 2
    3, 3, 3, 3
    D.1, 2, 3, 4
    2, 3, 4, 1
    3, 4, 1, 2
    4, 1, 2, 3
    56. 
    Which of the following is correct way to define the function fun() in the below program?
    #include<stdio.h>
    
    int main()
    {
        int a[3][4];
        fun(a);
        return 0;
    }
    
    A.
    void fun(int p[][4])
    {
    }
    
    B.
    void fun(int *p[4])
    {
    }
    
    C.
    void fun(int *p[][4])
    {
    }
    
    D.
    void fun(int *p[3][4])
    {
    }

    57. 
    What will be the output of the program ?
    #include<stdio.h>
    
    int main()
    {
        enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
        printf("%d, %d, %d, %d, %d, %d\n", MON, TUE, WED, THU, FRI, SAT);
        return 0;
    }
    
    A.-1, 0, 1, 2, 3, 4B.-1, 2, 6, 3, 4, 5
    C.-1, 0, 6, 2, 3, 4D.-1, 0, 6, 7, 8, 9
    58. 
    Point out the error in the program?
    #include<stdio.h>
    
    int main()
    {
        struct a
        {
            float category:5;
            char scheme:4;
        };
        printf("size=%d", sizeof(struct a));
        return 0;
    }
    
    A.Error: invalid structure member in printf
    B.Error in this float category:5; statement
    C.No error
    D.None of above
    59. 
    Which of the following is the correct order if calling functions in the below code?
    a = f1(23, 14) * f2(12/4) + f3();
    A.f1, f2, f3
    B.f3, f2, f1
    C.Order may vary from compiler to compiler
    D.None of above

    60. 
    What will be the output of the program ?
    #include<stdio.h>
    
    int main()
    {
        printf(5+"Good Morning\n");
        return 0;
    }
    
    A.Good MorningB.Good
    C.MD.Morning

    61. 
    What will be the output of the program ?
    #include<stdio.h>
    #include<string.h>
    
    int main()
    {
        char sentence[80];
        int i;
        printf("Enter a line of text\n");
        gets(sentence);
        for(i=strlen(sentence)-1; i >=0; i--)
            putchar(sentence[i]);
        return 0;
    }
    
    A.The sentence will get printed in same order as it entered
    B.The sentence will get printed in reverse order
    C.Half of the sentence will get printed
    D.None of above

    62. 
    The keyword used to transfer control from a function back to the calling function is
    A.switchB.goto
    C.go backD.return
    63. 
    What is the notation for following functions?
    1.  int f(int a, float b)
        {
            /* Some code */
        }
    
    2.  int f(a, b)
        int a; float b;
        {
            /* Some code */
        }
    
    A.1. KR Notation
    2. ANSI Notation
    B.1. Pre ANSI C Notation
    2. KR Notation
    C.1. ANSI Notation
    2. KR Notation
    D.1. ANSI Notation
    2. Pre ANSI Notation

    64. 
    What will be the output of the program?
    #include<stdio.h>
    void fun(int*, int*);
    int main()
    {
        int i=5, j=2;
        fun(&i, &j);
        printf("%d, %d", i, j);
        return 0;
    }
    void fun(int *i, int *j)
    {
        *i = *i**i;
        *j = *j**j;
    }
    
    A.5, 2B.10, 4
    C.2, 5D.25, 4

    65. 
    What will be the output of the program?
    #include<stdio.h>
    int reverse(int);
    
    int main()
    {
        int no=5;
        reverse(no);
        return 0;
    }
    int reverse(int no)
    {
        if(no == 0)
            return 0;
        else
            printf("%d,", no);
        reverse (no--);
    }
    
    A.Print 5, 4, 3, 2, 1B.Print 1, 2, 3, 4, 5
    C.Print 5, 4, 3, 2, 1, 0D.Infinite loop




No comments:

Post a Comment

Namecheap.com

Popular Posts