Odesk C programming


ODesk C programming test answers :


1.A header file contains macros, structure declaration and function prototypes.
A.
True(answer)
B.
False



2.There exists a way to prevent the same file from getting #included twice in the same program.
A.
True(answer)
B.
False



3.Preprocessor directive #undef can be used only on a macro that has been #define earlier
A.
True(answer)
B.
False



4.Which of the following is suitable data type for the variable a in the statement given below?
(datatype) a = 23.45;
A.
float(answer)
B.
double
C.
long double
D.
long float



5.What will be the output of the program ? 
#include<stdio.h>

    struct course
    {
        int courseno;
        char coursename[25];
    };
int main()
{
    struct course c[] = { {102, "Java"}, 
                          {103, "PHP"}, 
                          {104, "DotNet"}     };

    printf("%d", c[1].courseno);
    printf("%s\n", (*(c+2)).coursename);
    return 0;
}
A.
103 Dotnet(answer)
B.
102 Java
C.
103 PHP
D.
104 DotNet



6.What will be the output of the program? 
#include<stdio.h>
int main()
{
    char ch;
    ch = 'A';
    printf("The letter is");
    printf("%c", ch >= 'A' && ch <= 'Z' ? ch + 'a' - 'A':ch);
    printf("Now the letter is");
    printf("%c\n", ch >= 'A' && ch <= 'Z' ? ch : ch + 'a' - 'A');
    return 0;
}
A.
The letter is a
Now the letter is A(answer)
B.
The letter is A
Now the letter is a
C.
Error
D.
None of above


7.Is there any difference between the two statements?
char *ch = "IndiaBIX";
char ch[] = "IndiaBIX";
A.
Yes(answer)
B.
No


8.Which header file should be included to use functions like malloc() and calloc()?
A.
memory.h
B.
stdlib.h(answer)
C.
string.h
D.
dos.h


9.By default a real number is treated as a
A.
float
B.
double(answer)
C.
long double
D.
far double


10.What will be the output of the program ? 
#include<stdio.h>

int main()
{
    static char mess[6][30] = {"Don't walk in front of me...", 
                               "I may not follow;", 
                               "Don't walk behind me...", 
                               "Just walk beside me...", 
                               "And be my friend." };

    printf("%c, %c\n", *(mess[2]+9), *(*(mess+2)+9));
    return 0;
}
A.
t, t
B.
k, k(answer)
C.
n, k
D.
m, f


11.What will be the output of the program? 
#include<stdio.h>

int main()
{
    const int x=5;
    const int *ptrx;
    ptrx = &x;
    *ptrx = 10;
    printf("%d\n", x);
    return 0;
}
A.
5
B.
10
C.
Error(answer)
D.
Garbage value


12.Bitwise can be used to generate a random number.
A.
Yes
B.
No


13.Which of the following function is used to find the first occurrence of a given string in another string?
A.
strchr()
B.
strrchr()(answer)
C.
strstr()(answer)
D.
strnset()


14.If scanf() is used to store a value in a char variable then along with the value a carriage return(\r) also gets stored it.
A.
True
B.
False(answer)


15.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, 1
B.
Print 1, 2, 3, 4, 5
C.
Print 5, 4, 3, 2, 1, 0
D.
Infinite loop(answer)


16.What will be the output of the program? 
#include<stdio.h>

int main()
{
    int i=1;
    if(!i)
        printf("IndiaBIX,");
    else
    {
        i=0;
        printf("C-Program");
        main();
    }
    return 0;
}
A.
prints "IndiaBIX, C-Program" infinitely
B.
prints "C-Program" infinetly(answer)
C.
prints "C-Program, IndiaBIX" infinitely
D.
Error: main() should not inside elsestatement


17.The expression of the right hand side of || operators doesn't get evaluated if the left hand side determines the outcome.
A.
True(answer)
B.
False


18.What will be the output of the program ? 
#include<stdio.h>

int main()
{
    char *p;
    p="%d\n";
    p++;
    p++;
    printf(p-2, 23);
    return 0;
}
A.
21
B.
23(answer)
C.
Error
D.
No output


19.A function cannot be defined inside another function
A.
True(answer)
B.
False



20.What will be the output of the program (myprog.c) given below if it is executed from the command line?
cmd> myprog friday tuesday sunday 

/* myprog.c */
#include<stdio.h>

int main(int argc, char *argv[])
{
    printf("%c", *++argv[1]);
    return 0;
}
A.
r(answer)
B.
f
C.
m
D.
y


Tell us your feedback in comments

0 commentaires:

Enregistrer un commentaire