ODesk C programming test answers :
1. | A header file contains macros, structure declaration and function prototypes. |
|
2. | There exists a way to prevent the same file from getting #included twice in the same program. |
|
3. | Preprocessor directive #undef can be used only on a macro that has been #define earlier |
|
4. | Which of the following is suitable data type for the variable a in the statement given below? (datatype) a = 23.45; |
|
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;
}
|
|
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;
}
|
|
7. | Is there any difference between the two statements? char *ch = "IndiaBIX"; char ch[] = "IndiaBIX"; |
|
8. | Which header file should be included to use functions like malloc() and calloc()? |
|
9. | By default a real number is treated as a |
|
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;
}
|
|
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;
}
|
|
12. | Bitwise can be used to generate a random number. |
|
13. | Which of the following function is used to find the first occurrence of a given string in another string? |
|
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. |
|
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--);
}
|
|
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;
}
|
|
17. | The expression of the right hand side of || operators doesn't get evaluated if the left hand side determines the outcome. |
|
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;
}
|
|
19. | A function cannot be defined inside another function |
|
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
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("%c", *++argv[1]);
return 0;
}
|
|
Tell us your feedback in comments
0 commentaires:
Enregistrer un commentaire