Skip to main content

C Programming Test Upwork Answers 2019

1. Identify the incorrect statement.
Answers:
  1. Records can be defined in C by using structures
  2. Structure members can be of the same/different data types
  3. Memory is reserved when a structure label is defined
  4. A pointer to a structure can be used to pass a structure to a function
  5. Arrays of structures can be defined and initialized
2. What will be printed on the standard output as a result of the following code snippet?
void func()
{
static int i = 1;
int j = 1;
i++;
j++;
printf(“%d %d “,i,j);
}
void main()
{
func();
func();
func();
}
Answers:
  1. 2 2 2 2 2 2
  2. 2 2 3 2 4 2
  3. 2 2 2 3 2 4
  4. 2 2 3 3 4 4
  5. None of these
3. Given the following array:
int a[8] = {1,2,3,4,5,6,7,0}; 
what would be the output of 
printf(“%d”,a[4]); ?
Answers:
  1. 3
  2. 4
  3. 5
  4. 6
  5. 7
4. Which function will convert a string into an integer?
Answers:
  1. int()
  2. number()
  3. atoi()
  4. val()
  5. tonum()
5. Which standard function is used to clear memory allocated by the malloc() function?
Answers:
  1. free
  2. calloc
  3. delete
  4. elease
  5. destroy
6. From which of the following loop or conditional constructs, is “break” used for an early exit?
Answers:
  1. switch
  2. fo
  3. while
  4. do-while
  5. All of the above
7. What would be printed on the standard output as a result of the following code snippet?
char i = ‘A’; 
char *j; 
j = & i; 
*j = *j + 32; 
printf(“%c”,i);
Answers:
  1. An error will occur
  2. a
  3. A
  4. c
8. What does the argv[0] represent?
Answers:
  1. The first command line parameter has been passed to the program
  2. The program name
  3. The number of command line arguments
  4. None of the above
9. What would be printed on the standard output as a result of the following code snippet?
#define func(t, a, b) { t temp; temp=a; a=b; b=temp; }
main()
{
int a=3, b=4;
float c=4.5, d = 5.99;
func(int, a, b);
func(float, c, d);
printf(“%d %d “, a, b);
printf(“%.2f %.2fn”, c, d); 
}
Answers:
  1. Results in Compilation Error
  2. 3 4 5.99 4.50
  3. 3 4 4.50 5.99
  4. 4 3 5.99 4.50
  5. None of the above
10. What is the function to concatenate two strings?
Answers:
  1. strcmp()
  2. strcpy()
  3. strcat()
  4. strlen()
  5. catstr()
11. Given the following array:
char books[][40]={ 
“The Little World of Don Camillo”, 
“To Kill a Mockingbird”, 
“My Family and Other Animals”, 
“Birds, Beasts and Relatives” 
}; 
what would be the output of printf(“%c”,books[2][5]);?
Answers:
  1. m
  2. M
  3. F
  4. i
  5. L
12. Which of the following is not a valid mode for opening a file?
Answers:
  1. r
  2. w
  3. a
  4. +
  5. i
13. Given the following array declaration:
int a[2][3][4] 
what would be the number of elements in array a?
Answers:
  1. 24
  2. 22
  3. 20
  4. 12
  5. 36
14. Which function will convert a string into a double precision quantity?
Answers:
  1. atoi()
  2. atof()
  3. atol()
  4. atan()
  5. acos()
15. What will be the output of following code?
int main()
{
int i;
i = 0;
for (i = 1; i <2; i++)
{
i++;
printf( “%d”, i );
continue;
printf( “%d”, i );
}
return 0;
}
Answers:
  1. 22
  2. 2,2
  3. 2
  4. none of the above
16. What would be printed on the standard output as a result of the following code snippet?
main()
{
int u = 1, v = 3;
printf(“%d %d”,u,v);
funct1(&u,&v);
printf(“%d %dn”,u,v);
}
void funct1(int *pu, int *pv)
{
*pu=0;
*pv=0;
return;
}
Answers:
  1. 1 31 3
  2. 1 3 1 1
  3. 1 30 0
  4. 1 1 1 1
  5. 3 1 3 1
17. What will be printed on the standard output as a result of the following code snippet?
void main()
{
int num1 = 30, num2 = 4;
float result;
result = (float)(num1/num2);
printf(“%.2f”, result);
return 0;
}
Answers:
  1. 7
  2. 7.00
  3. 7.000000
  4. 7.5
  5. 7.50
18. Study the following code:
int n = 2;
int a[n];
What is the error in the above code?
Answers:
  1. There is no error
  2. The minimum limit of an array is 5
  3. The second statement should be placed before the first
  4. A constant value has to be given in place of a variable for array declaration
19. Which of the following is not a file related function?
Answers:
  1. fgetc()
  2. puts()
  3. fputc()
  4. fscanf()
  5. fprintf()
20. What is the output of the following program ?
main()
{
int u = 1, v = 3;
printf(“%d %d”,u,v);
funct1(&u,&v);
printf(” %d %dn”,u,v);
}
void funct1(int *pu, int *pv)
{
*pu=0;
*pv=0;
return;
}
Answers:
  1. 1 3 1 3
  2. 1 3 1 1
  3. 1 3 0 0
  4. 1 1 1 1
  5. 3 1 3 1
21. What would be printed on the standard output as a result of the following code snippet?
#include<stdio.h>
main()
{
unsigned char a=255;
a = a+1;
printf(“%d”,a);
return 0;
}
Answers:
  1. Undefined value
  2. 256
  3. 1
  4. -1
22. What is wrong with the following statement?
int func();
Answers:
  1. The function definition {…} is missing
  2. While calling a function, the type int is not needed
  3. No parameter has been passed
  4. The semicolon should not be there
  5. There is nothing wrong with the statement
23. Suppose there is a file a.dat which has to be opened in the read mode using the FILE pointer ptr1, what will be the correct syntax?
Answers:
  1. ptr1 = open(“a.dat”);
  2. ptr1 = fileopen(“a.dat”);
  3. ptr1 = fopen(“a.dat”,”r”);
  4. ptr1 = open(“a.dat”,”r”);
  5. ptr1 = fileopen(“a.dat”,”r”);
24. What would be printed on the standard output as a result of the following code snippet?
main()
{
char *pmessage = “asdfgh”;
*pmessage++;
printf(“%s”, pmessage);
return 0;
}
Answers:
  1. Will result in Compilation Error
  2. Undefined string
  3. sdfgh
  4. asdfgh
25. Study the following code where num is an integer array and n is the length of the array:
for(i=0;i<n-1;i++) 

for(j=i+1;j<n;j++) 

if(num[i] > num[j]) 

var=num[i]; 
num[i]=num[j]; 
num[j]=var; 



What does the above code do?
Answers:
  1. It prints the elements of the array in the ascending orde
  2. It calculates the sum of the elements of the array
  3. It sorts the array in the ascending orde
  4. It sorts the array in the descending orde
  5. It calculates the average of the elements of the array
26. Read the following two declaration statements.
1. #include <stdio.h>
2. #include “stdio.h”
Which of the following statements pertaining to the above two statements are correct?
Answers:
  1. For statement 1, the header file will be searched first in the local directory and then in the standard system directories such as “/usr/include”
  2. For statement 1, the header file will be searched in the standard system directories such as “/usr/include”
  3. For statement 2, the header file will be searched first in the local directory and then in the standard system directories such as “/usr/include”
  4. For statement 2, the header file will be searched in the standard system directories such as “/usr/include”
  5. None of the above
27. Is the following statement correct? If not, why not? If yes, what is the size of the array?
int array[][3] = { {1,2}, {2,3}, {3,4,2} };
Answers:
  1. Yes, the size is three columns by two rows
  2. Yes, the size is two columns by two rows
  3. No, the first dimension is omitted
  4. No, one of the three initializer sets contains too many numbers
  5. Yes, the size is three columns by three rows
28. What would be printed on the standard output as a result of the following code snippet?
#define max(a, b) ((a) > (b)?(a):(b))
main()
{
int a=4;
float b=4.5;
printf(“%.2fn”,max(a, b)); 
}
Answers:
  1. Results in Compilation Error
  2. Undefined value
  3. 4.50
  4. 4.0
  5. None of the above
29. What will be the output of the following program?
#include <assert.h>
main()
{
int n = 5;
assert(n > 3); //statement 1
n = n+2;
assert(n > 7);//statement 2
return 0;
}
Answers:
  1. Assertion ‘n > 3’ failed; Program aborts at statement 1
  2. Assertion ‘n > 7’ failed; Program aborts at statement 2
  3. Program returns 0 with the value of n as 7
  4. Compilation Error
30. What would be printed on the standard output as a result of the following code snippet?
main()
{
enum {red, green, blue = 6, white};
printf(“%d %d %d %d”, red, green, blue, white);
return 0;
}
Answers:
  1. 0 1 6 2
  2. 0 1 6 7
  3. Will result in Compilation Error
  4. None of the above
31. Which file header is to be included for file handling in a C program?
Answers:
  1. string.h
  2. file.h
  3. stdio.h
  4. stdlib.h
  5. ctype.h
32. What will be printed on the standard output as a result of the following code snippet?
void main()
{
char arr[] = {‘R’,’A’,’M’};
printf(“%d”,strlen(arr));
}
Answers:
  1. 1
  2. 3
  3. 4
  4. Cannot be determined
33. Which function will you use to write a formatted output to the file?
Answers:
  1. fputc()
  2. fputs()
  3. fprintf()
  4. fseek()
  5. ftell()
34. Which function returns the current pointer position within a file?
Answers:
  1. ftell()
  2. fseek()
  3. fgetc()
  4. fread()
  5. fscanf()
35. Which of the following is not a string function?
Answers:
  1. strlen()
  2. strcmp()
  3. strcpy()
  4. strrev()
  5. strcomp()
36. Which of the following declarations of structures is/are valid?
1) 
struct node {
int count;
char *word;
struct node next;
}Node;
2)
struct node {
int count;
char *word;
struct node *next;
}Node;
3)
struct node {
int count;
char *word;
union u1 {
int n1;
float f1;
}U;
}Node;
Answers:
  1. 123
  2. 12
  3. 23
  4. 2
  5. None of the above
37. What would be printed on the standard output as a result of the following code snippet?
main()
{
int arr[10];
int a = sizeof(arr);
printf(“%dn”,a);
return 0;
}
Answers:
  1. Compilation Error
  2. 10
  3. 4
  4. 40
38. Which of the following is a function for formatting data in memory?
Answers:
  1. sprintf()
  2. printf()
  3. scanf()
  4. free()
  5. atol()
39. Which function allocates memory and initializes elements to 0?
Answers:
  1. assign()
  2. calloc()
  3. malloc()
  4. swab()
  5. allocate()
40. What will be printed on the standard output as a result of the following code snippet?
void main()
{
int i,j,k;
i=4;
j=30;
k=0;
k=j++/i++;
++k;
printf(“%d %d %d”,i,j,k);
}
Answers:
  1. 5 31 8
  2. 5 31 7
  3. 5 31 6
  4. 4 30 7
41. Given the operators:
1) *
2) /
3) %
What would be the order of precedence?
Answers:
  1. 1,2,3
  2. 1,3,2
  3. 3,2,1
  4. All have the same precedence
  5. 1 and 2 have the same precedence, 3 is of lower precedence
42. Which of the following sets of conversion statements may result in the loss of data?
Answers:
  1. int i; char c; i=c; c=i;
  2. int i; char c; c=i; i=c;
  3. int i; float f; i=f; f=i;
  4. None of the above
43. Which of the following standard functions is used to close a file?
Answers:
  1. fileclose()
  2. closefile()
  3. fclose()
  4. Any of the above

Comments

Popular posts from this blog

English Spelling Test (U.S. Version) Upwork Answers Test 2019

1 . Complete the following sentence by choosing the correct spelling of the missing word. Their relationship was plagued by _______ problems. Perpetual   —- it means: continuing for ever in the same way, often repeated Perpechual Purpetual Perptual 2.  Complete the following sentence by choosing the correct spelling of the missing word. The crowd _________ me on my acceptance into Mensa Congradulated Congrachulated Congratulated  —- it mean: to praise someone Congratilated English Spelling Test (U.S. Version) Answer;Upwork English test answer; Upwork English test answer 2017; lastest Upwork English test answer; upwork test answer;  3. Choose the correct spelling of the word from the options below. Goverment Governmant Government  — the group of people who officially control a country Govermant 4. Choose the correct spelling of the word from the options below. Temperamental ...

Office Skills Test Upwork Test Answers 2019

Question:* Your computer is not printing and a technician is not available, so you perform the following activities to investigate the problem. In which order should you take these up? 1 See if the printer cartridge is finished 2 See if the printer is switched on 3 Try to print a test page using the printer self-test 4 Try to print a test page from Windows 5 See if the printer is properly attached to the computer Answer: • 2,3,1,5,4 Question:* What is 'flexi-time'? Answer: • The flexible use of personal office hours, such as working an hour earlier one day, in order to leave an hour earlier another day. Question:* Which of the following are proven methods of improving your office skills? Answer: • All of the above Question:* When replying to an e-mail, who do you place in the cc: line and who in the bcc: line? Answer: • A person you wish to openly inform goes in the cc: line, and the person you wish to read the e-mail without the knowledge of the rec...

Python Test Answers Upwork 2019

1. Which of the following will disable output buffering in Python? Answers: a. Using the -u command line switch a. class Unbuffered: def __init__(self, stream): self.stream = stream def write(self, data): self.stream.write(data) self.stream.flush() def __getattr__(self, attr): return getattr(self.stream, attr) import sys sys.stdout=Unbuffered(sys.stdout)  a. Setting the PYTHONUNBUFFERED environment variable a. sys.stdout = os.fdopen(sys.stdout.fileno(), ‘w’, 0) 2. Which of the following members of the object class compare two parameters? Answers: a. object.__eq__(self, other)  a. object.__ne__(self, other)  a. object.__compare__(self, other) a. object.__equals__(self, other) a. object.__co__(self, other) a. None of these 3. Object is the base class of new-style datatypes. Which of the following functions is not a member of the object class? Answers: a. object.__eq__(self, other) a. object.__ne__(self, other) a. object.__nz__(self)  a. object.__repr__(self) a. None ...