Skip to main content

Upwork/oDesk C Programming Test Answers 2016

C Programming Question Answers for Upwork Test

1. Identify the incorrect statement.
 Answers: • Memory is reserved when a structure label is defined

 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: • 2 2 3 2 4 2

 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: • 5

 4. Which function will convert a string into an integer?
 Answers: • atoi()

 5. Which standard function is used to clear memory allocated by the malloc() function?
 Answers: • free

 6. From which of the following loop or conditional constructs, is "break" used for an early exit?
 Answers: • 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: • a

 8. What does the argv[0] represent?
 Answers: • The program name

 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 %.2f\n", c, d); 
 }
 Answers: • 4 3 5.99 4.50

 10. What is the function to concatenate two strings?
 Answers: • strcat()


 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: • m

 12. Which of the following is not a valid mode for opening a file?
 Answers: • i

 13. Given the following array declaration:

 int a[2][3][4] 
 what would be the number of elements in array a?
 Answers: • 24

 14. Which function will convert a string into a double precision quantity?
 Answers: • atof()

 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: • 2

 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 %d\n",u,v);

 }


 void funct1(int *pu, int *pv)

 {

 *pu=0;

 *pv=0;

 return;

 }
 Answers: • 1 30 0

 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: • 7.00

 18. Study the following code:


 int n = 2;

 int a[n];


 What is the error in the above code?
 Answers: • 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: • puts()

 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 %d\n",u,v);

 }


 void funct1(int *pu, int *pv)

 {

 *pu=0;

 *pv=0;
 return;

 }
 Answers: • 1 3 0 0

 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: • Undefined value

 22. What is wrong with the following statement?

 int func();
 Answers: • 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: • ptr1 = fopen("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: • sdfgh


 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: • It sorts the array in the ascending orde

 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: • 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"

 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: • 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("%.2f\n",max(a, b)); 
 }
 Answers: • 4.50

 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: • Assertion 'n > 7' failed; Program aborts at statement 2

 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: • 0 1 6 7

 31. Which file header is to be included for file handling in a C program?
 Answers: • stdio.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: • Cannot be determined

 33. Which function will you use to write a formatted output to the file?
 Answers: • fprintf()

 34. Which function returns the current pointer position within a file?
 Answers: • ftell()

 35. Which of the following is not a string function?
 Answers: • 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: • 23

 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("%d\n",a);

 return 0;

 }
 Answers: • 40

 38. Which of the following is a function for formatting data in memory?
 Answers: • sprintf()

 39. Which function allocates memory and initializes elements to 0?
 Answers: • calloc()

 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: • 5 31 8

 41. Given the operators:


 1) *

 2) /

 3) %


 What would be the order of precedence?
 Answers: • All have the same precedence

 42. Which of the following sets of conversion statements may result in the loss of data?
 Answers: • int i; float f; i=f; f=i;

 43. Which of the following standard functions is used to close a file?
 Answers: • fclose()

Comments

Popular posts from this blog

Upwork Knowledge of Microsoft Office Skills Test Answer

In Microsoft Word 2010, "Keep lines together" paragraph formatting:
Answers: • does not work for paragraphs within a table if "Allow row to break across pages" is also selected.

You want to add an image as the first character in your paragraph. Which type of text wrapping treats your graphic as if it were a character?
Answers: • In Line with Text

In the given screenshot, the contents of the 'Name of User' column have been oriented at an angle. How is this done?
Answers: • By using the 'Orientation' button in the alignment group of the 'Home' tab.

In the given screenshot, the letter X is pointing to an area between the first Row header, and the first Column header. What will happen when this particular area is selected?
Answers: • It will select the whole sheet, having the same effect as that of Ctrl+A.

Which of the following types of worksheets will not load in Microsoft Excel Services?
Answers: • Worksheets with ActiveX controls

Why would you use con…

पिता के घर पे बेटे का कानूनी हक नही

Top SEO Companies in India by TOPSEO's Ranking

I am providing you the list of top 10 SEO Companies/Firms/Agencies in India by TOPSEO's  (January 2016)

1. SEO.IN 
Year Founded: 2002
Website: http://www.seo.in/



2. SEOValley Solutions Private Limited
Year Founded: 2000
Website: http://www.seovalley.com/



3. PageTraffic
Year Founded: 2002
Website: http://www.pagetraffic.com/



4. SeoTonic Web Solutions Private Ltd.
Year Founded: 2006
Website: http://www.seotonic.com/


5. Outsource SEO
Year Founded: 2004
Website: http://www.outsourceseo.com/


6. Ranking By SEO
Year Founded: 2008
Website: http://www.rankingbyseo.com/


7. Techmagnate
Year Founded: 2006
Website: http://www.techmagnate.com/


8. SEO Discovery
Year Founded: 2006
Website: http://www.seodiscovery.com/


9. Greenlemon
Year Founded: 1999
Website: http://greenlemon.in/


10. SEOXperts India
Year Founded: 2008
Website: http://www.seoxpertsindia.com/