Starting from:
$30

$24

C/C++ Exercise Solution

Introduction:







Why C language is named "C"? Briefly describe its hisotry and the development of this language. Generally discuss the relation between C and any other languages(e.g. Java, C#, etc). (200 words at most)



Data type







What is primitive data type in C?



Discuss the value range of char , short , int , long , long long ,






unsigned int (Try in different operating system, different compilers). Please write the code and corresponding output to discuss your result and try to explain why.




Which types of data can be used as keyword in switch/case block. Please show codes and try to discuss the reason?
Read the following codes:






C

#include <stdio.h



2

typedef struct student
{
char name[10];
long student_id;
char sex;



double score[4]; 9 } STU;



10

int main ()



{
STU a[5];



printf("%d\n", sizeof(a));



}



Calculate the size of a and compare your result with the output. Disscuss what your result and the reason.







Operators







Choose at least 5 operators and write codes to compare their priorities, binding, and order of operations.
What is the difference between ++i and i++ ? (Hints: also try to discuss from the perspective of compilation process.)



Try to implement swap without using temporary variables. (Function prototype: void swap(int* a, int



*b), hints: using bit operators)




Array and Pointer







What is the difference between char* a and char a[] . Then, try to explore the difference between array and pointer by writing codes to prove the differences.



Investigate what operations can be used on pointer. Write some codes to show how to implement these operations.






Others:







1.
How many main
functions exists and simply discuss their difference. Also consider whether


void main ()
is legal or not? Why?
2.
Try to write a simple program to test the endian of your system.(Big endian or little endian)
3.
Try to compare sizeof and strlen , explain your result.



Try to implement common string functions: strcmp, strcat, strtok



Compare the differences of these input/output functions: scanf/printf, putchar/getchar, puts/gets, fputs/fgets
Do you know goto ? How it is used in programs and discuss how to properly use goto .(Please search this keyword with Linux kernel and find out more stories about this keyword.)



Compare the differences of malloc & free with new & delete .

More products