oDesk Programming With C Test Answers 2015

oDesk Programming With C Test Answers will be more helpful to get more high quality and expensive job on oDesk.


Q1.  Which of the following is suitable data type for the variable a in the statement given below?
(datatype) a = 23.45;
a) float
b) double
c) long double
d) long float
Q2.  What will be the out put of the following program
void func()
{
static int i=1;
int j=1;
i++;
j++;
printf(“%d%d”, i,j);
}
void main()
{
func();
func();
func();
}
a) 222222
b) 232323
c) 234234
d) 223242
e) none of the above
Q3.  Break is used in early exit
a) switch
b) for
c) while
d) do while
e) all
Q4.  What will be the out put of the C program
char *str[]={“MANOJ”, “KUMAR”, “CHOUDHRY”};
printf(“\n string 1=%s”, str[0]);
printf(“\n string 2=%s”, str[1]);
printf(“\n string 3=%s”, str[3]);
a) MANOJ KUMAR CHOUDHRY
b) MAN
c) KUM
d) DHRY
e) none of the above
Exact Answer: 
 string 1=MANOJ
 string 2=KUMAR
 string 3=(null)
Q5.  Preprocessor directive #undef can be used only on a macro that has been #define earlier
a) True
b) False
Q6.  Which can be causes loss of the data
a) int i;
char c;
i=c;
c=i;
b) int i;
char c;
c=i;
i=c;
c) int i;
float f;
i=f;
f=i;
d) all codes are right
Q7.  Which of the following function is used to find the first occurrence of a given string in another string?
a) strchr()
b) strrchr()
c) strstr()
d) strnset()
Q8.  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
Q9.  Which memory function is used to free the memory, when the memory is allocated by malloc()
a) calloc()
b) remove()
c) delete()
d) del()
Exact Answer: free()
Q10.  What will be the out put
void main()
{
char arr1[]=”REGALIMT”;
char *arr2;
arr2=arr1;
printf(“%d”,sizeof(arr1));
printf(“%d”,sizeof(arr2));
}
a) 1,1
b) 9,8
c) 8,8
d) 8,9
Q11. Which is/are not relational operator
a) ==
b) !=
c) <>
d) >=
e) <=
Q12. Which memory allocation system allocating the memory and initialize the element to 0 ?
a) calloc();
b) malloc();
c) gets();
d) getch();
e) scanf();
Q13. Which is/are not storage Type?
a) auto
b) global
c) static
d) resister
e) extern
Q14. Which is not a file related function ?
a) fgetc()
b) puts()
c) fputs()
d) malloc()
Q15. isalpha(), islower() a part of ?
a) stdio.h
b) dos.h
c) string.h
d) ctype.h
f) none of the above
Q16.  Bitwise can be used to generate a random number?
a) Yes
b) No
Q17.  A function cannot be defined inside another function?
a) True
b) False
Q18. What will be the output
main()
{
char *massg=”asdfgh”;
*massg++;
printf(“%s”, massg);
return(0);
}
a) asdfgh
b) sdfgh
c) dfgh
d) asdfg
e) none of the above.
Q19.  The expression of the right hand side of || operators doesn’t get evaluated if the left hand side determines the outcome.
a) True
b) False
Q20. Is there any difference between the two statements?
char *ch = “IndiaBIX”;
char ch[] = “IndiaBIX”;
a) Yes
b) No
Q21. Which memory function is used to free the memory, when the memory is allocated by malloc()?
a) calloc()
b) remove()
c) delete()
d) del()
e) free()
Q22. There exists a way to prevent the same file from getting #included twice in the same program?
a) True
b) False
Q23.  What will be the output of the program?
#include
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
Q24. Which of the following code(s) generate compile error?
a) int n=5, x; x=n++;
b) int n=5; x; x=++n++
c) int n=5; x; x=(n+1)++
d) int n=5, x=6; x=(n+x)++
e) non of the above
Q25. What will be the output of the program ?
#include
int main()
{
char *p;
p=”%d\n”;
p++;
p++;
printf(p-2, 23);
return 0;
}
a) 21
b) 23
c) Error
d) No output
Q26. What will be the output of the program?
#include
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
d) Garbage value
Q27.  By default a real number is treated as a?
a) float
b) double
c) long double
d) far double
Q28. What will be the out put?
#include “stdio.h”
main()
{
int n=5;
assert(n>3);
n=n+2;
assert(n>7)
return (0);
}
a) Error in line assert(n>3)
b) error in line n=n+2
c) error in line n>7
d) error in line return(0)
Q29.  Which header file should be included to use functions like malloc() and calloc()?
a) memory.h
b) stdlib.h
c) string.h
d) dos.h
Q30.  A header file contains macros, structure declaration and function prototypes..
a) True
b) False
Q31. What will be the output of the program?
#include
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
b) The letter is A Now the letter is a
c) Error
d) None of above
Q32. What will be the output of the program ?
#include
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
b) 102 Java
c) 103 PHP
d) 104 DotNet
Q33. In order to read symmetrical record which function should used ?
a) fscanf()
b) fread()
c) fgets()
d) fgetc()
e) fseek()
Q34. What does argc[0] represents
a) The first command line argument to be passed
b)The no. of argument

Q35. What does argv[0] represents
a) The first command line argument to be passed
b)The no. of argument
c) The name of the program

Q36. What does
#include<stdio.h>
#include “stdio.h” represents                   (Multiple choice question)
a) Statement 1 indicates that functions will be searched first in local directories and then in standard \usr\stdrd\
b)Statement 1 indicates that functions will be searched first in local directories and then in standard \usr\stdrd\
c)Statement 1 indicates that functions will be searched first in standard directories
d)Statement 2 indicates that functions will be searched first in standard directories

Q37.What is true in these statements
a) Automatic arrays can’t be initailized
b) int arr[100][100] indicates an array that can contain 10000 elements

Q38. Static variables are stored in 
a) Heap storage
b)Stack
c)binary pointer
d) None of the above
Q39. Which header file must be included for allowing file handling operations
a) file.h
b) stdio.h
c) scanf.h

Q40. Which file opening mode is not included in C
a) a+
b) r
c)w
d) i+
e) w+

Q.41 How many elements does int arr[2][3][4] include
a)36
b) 24
c) 16
d) 48

Q.42. If int is of 16 bits and long is of 32 bits then which of the following will be right
a) -1L> 1UL
b) -1L< 1UL
c) 1L< 1UL
d) 1L> 1UL                       (Multiple choice question)

Q43. What is meant by int *(*p[5])() 
a) array of pointer to a function whose return type is int
b)pointer to a pointer of array integer
c) Pointer to an array of inter pointer

Q44. Function used for opening a file using file pointer ptr in read mode
a) *ptr= fopen(“a.dat”,r);
a) *ptr= fileOpen(“a.dat”,r);
a) *ptr= fileRead(“dat”,r);

Q45. Which of the following file functions helps to position file pointer w.r.t. current file position
a)fseek
b)ftell
c) rewind
d)fgetpos

Q46. Which of the following function is used to open a file in read+append mode
a) r+
b) w+
c) a+
d) r+w
e) r+a

Q47. Which function is used to convert a string value to an interger
a) val()
b) intval()
c) stringval()

Q. 48 What does meant by int(*p) 10 
a) array of integer pointers
 Note: (   int *p[10] means that p is an array of 10 integer pointers .
int *ptr[10];
This is an array of 10 int* pointers, not as you would assume, a pointer to an array of 10 ints
int (*ptr)[10];
This is a pointer to an array of 10 int
It is I believe the same as int *ptr; in that both can point to an array, but the given form can ONLY point to an array of 10 ints)

Q. 50 Learn the Right way of declaring a structure
a)struct student{
char name[50];int roll;
};
Also check whether a union can be used within the structure declaration
struct student{
char name[50];int roll;
Union amp1{
// entries
}
};

Q51. Tell the precedence of operators in c, in which order these will be executed
1) /
2) *
3) %
a) All will have same precedence
b) 1 and 2 have same precedence, 3 will be executed later
c) execution order : 1,2,3
d) execution order : 3,2,1

Q. 52 What will be the output of the following code:
signed char i=1;
for(; i<=255;i++)
printf(“%d”,i);

Q. 53.  What will be the output of the following code:
int a[5]={1,4,5,6,9};
  printf(“%d\t”, *a);
  printf(“%d”, ++a);
  return 0;

Q. 54.  What will be the output of the following code:
enum{red,green,blue=0,white};
 printf(“%d%d%d%d”,red,green,blue,white);
 return 0;

Q. 55.  What will be the output of the following code:
char *str1=”hello world”;
strcat(str1,’!’);
printf(“%s”,str1);

Q. 56.  What will be the output of the following code:
unsigned char a=255;
a=a+1;
printf(“%d”,a);
return 0;

Q. 57.  What will be the output of the following code:
int num[3][4]={{3,6,9,12},{15,25,30,35},{66,77,88,99}};
printf(“%d”,*(*num+1));
return 0;

Q. 58.  What will be the output of the following code:
char *s=”hello world”;
char s1[20],s2[20];
int len=sscanf(s,”%s”,s1);
printf(“%s:%d”,s1,len);

Q. 59.  What will be the output of the following code:
#include <stdio.h>
#include <string.h>
#define max(a,b) ((a)>(b)?(a):(b))
main()
{
int a=4;
float b=4.5;
printf(“%.2f\n”,max(a,b));
}

Q. 60.  What will be the output of the following code:
 char i=’A';
char *j;
j=&i;
*j=*j+32;
printf(“%c”,i);

Q. 61 What will be the output of the following code:
int arr[][2]={1,2,3,4,5,6};
printf(“%d”,arr[2][1]);

Q. 62 What will be the output of the following code:
 int num[3][4]={{3,6,9,12},{15,25,30,35},{66,77,88,99}};
printf(“%d”,*(*(num+1)+1)+1);



You can find out more test answers  
oDesk Programming With C Test Answers.