Skip to content

Latest commit

 

History

History

exercises

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

C exercises

Print "Hello World!".

Print the C version you are using.

Print the following characters in a reverse way.
Test Characters: X, M, L
Expected Output:

The reverse of XML is LMX

Enter the height and width values of a rectangle and compute perimeter and area.
Test Characters: 7, 5
Expected Output:

The perimeter is 24 inches
The area is 35 square inches

Enter the radius of a circle and compute perimeter and area.
Test Characters: 6
Expected Output:

The perimeter is 37.699112 inches
The area is 113.097336 square inches

Display the following variables: a + c, x + c, dx + x, ((int) dx) + ax, a + x, s + b, ax + b, s + c, ax + c, ax + ux
Variable declaration :

int a = 125, b = 12345;
long ax = 1234567890;
short s = 4043;
float x = 2.13459;
double dx = 1.1415927;
char c = 'W';
unsigned long ux = 2541567890;

Convert specified days into years, weeks and days.
Note: Ignore leap year.
Test Data:

1329

Expected Output:

Years: 3
Weeks: 33
Days: 3

Calculate the distance between two points.
Test Data:

Input x1: 25
Input y1: 15
Input x2: 35
Input y2: 10

Expected Output:

Distance between the said points: 11.1803

Read 5 numbers and sum of all odd values between them.
Test Data:

Input the first number: 11
Input the second number: 17
Input the third number: 13
Input the fourth number: 12
Input the fifth number: 5

Expected Output:

Sum of all odd values: 46

Prints all even numbers between 1 and 50 (inclusive).
Expected Output:

Even numbers between 1 to 50 (inclusive): 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50

Find and print the square of each one of the even values from 1 to a specified value.
Expected Output:

List of square of each one of the even values from 1 to a 4:
2^2 = 4
4^2 = 16

Read a password until it is correct. For wrong password print "Incorrect password!" and for correct password print "Correct password!" and quit the program. The correct password is 1234.
Expected Output:

Input the password: 1234
Correct password

Calculate the value of S where S = 1 + 1/2 + 1/3 + … + 1/50.
Expected Output:

Value of S: 4.50

Read an array of length 5 and print the position and value of the array elements of value less than 10.
Expected Output:

Input the 5 members of the array:
15
25
4
35
40
A[2] = 4

Swaps two numbers without using third variable.
Expected Output:

Input value for x & y: 5 7
Before swapping the value of x & y: 5 7
After swapping the value of x & y: 7 5

Shift given data by two bits to the left.
Expected Output:

Input value: 2
The left shifted data is 8

Reverse and print a given number.
Expected Output:

Input a number: 234
The reverse of the said number is 432

Create enumerated data type for 7 days and display their values in integer constants.
Expected Output:

Sun = 0
Mon = 1
Tue = 2
Wed = 3
Thu = 4
Fri = 5
Sat = 6

Accepts a real number x and prints out the corresponding value of sin(1/x) using 4-decimal places.
Expected Output:

Input value of x: .6235
Value of sin(1/x) is 0.9995

Generates 50 random numbers between -0.5 and 0.5, writes them in a file rand.dat and print the contents of the file. The first line of ran.dat contains the number of data and the next 50 lines contains the 50 random numbers.
Expected Output:

50
-0.4215
0.2620
...
0.1750
0.3565

Print the alphabet set in decimal and character form.
Expected Output:

[65-A] [66-B] [67-C] [68-D] [69-E] [70-F] [71-G] [72-H] [73-I] [74-J] [75-K] [76-L] [77-M] [78-N] [79-O] [80-P] [81-Q] [82-R] [83-S] [84-T] [85-U] [86-V] [87-W] [88-X] [89-Y] [90-Z] [97-a] [98-b] [99-c] [100-d] [101-e] [102-f] [103-g] [104-h] [105-i] [106-j] [107-k] [108-l] [109-m] [110-n] [111-o] [112-p] [113-q] [114-r] [115-s] [116-t] [117-u] [118-v] [119-w] [120-x] [121-y] [122-z]

Reverse a given string and count the number of characters.
Expected Output:

Input a string: w3resource
Reversed string: ecruoser3w
Number of characters is 10

Write a function to remove any negative sign in front of a number.
Expected Output:

Input a value (negative): -253
Absolute value is 253

Demonstrates the difference between predecrementing and postdecrementing using the decrement operator --.

Produce the following table of values using looping.
Sample Output:

x       x+2     x+4     x+6
--------------------------------
1       3       5       7
4       6       8       10
7       9       11      13
10      12      14      16
13      15      17      19

Reads the side (side sizes between 1 and 10) of a square and prints a hollow square using hash (#) character.
Sample Output:

Input the size of the square: 10
##########
#        #
#        #
#        #
#        #
#        #
#        #
#        #
#        #
##########

Display the sizes and ranges for each of C's data types.
Sample Output:

Size of C data types:

Type               Bytes
-------------------------
char                 1
int8_t               1
unsigned char        1
uint8_t              1
short                2
int16_t              2
uint16t              2
int                  4
unsigned             4
long                 8
unsigned long        8
int32_t              4
uint32_t             4
long long            8
int64_t              8
unsigned long long   8
uint64_t             8
float                4
double               8
long double          16
_Bool                1

Find the angle between (12:00 to 11:59) the hour hand and the minute hand of a clock.
The hour hand and the minute hand is always among 0 degree and 180 degree. For example, when it's 12 o'clock, the angle of the two hands is 0 while 3:00 is 90 degree and 6:00 is 180 degree.
Sample Output:

Input hour(h) and minute(m) (separated by a space):
The angle is -246 degrees at 00:41.

Invoke the command processor to execute a command.

Convert an input to an unsigned long integer.

Convert a string to a long integer.

Convert a string to a double.

Generate a random number.

Sort the elements of an array.

Show the basic declaration of pointer.

Demonstrate the use of &(address of) and *(value at address) operator.

Multiply two numbers using pointers.

Show how a function returning pointer.

Show the usage of pointer to structure.

Input a string and print it.

Find the length of a string without using library function.

Print individual characters of string in reverse order.

Read a sentence and replace lowercase characters by uppercase and vice-versa.

Concatenate two strings manually.

Check whether a character is Hexadecimal Digit or not.

Read a file and remove the spaces between two words of its content.

Split string by space into words.

Print the current time and the time that has passed since 9 November 1989.

Create and store information in a text file.

Write and read multiple lines in a text file.

Replace a specific line with another text in a file.

Append multiple lines at the end of a text file.

Encrypt a text file.

Pars the results.txt file, doubles the contained values and saves the results in a new file.