Posts

Showing posts with the label C

Hacker Rank C Challenges #003

  Task Given a positive integer denoting  , do the following: If  , print the lowercase English word corresponding to the number (e.g.,  one  for  ,  two  for  , etc.). If  , print  Greater than 9 . Input Format The first line contains a single integer,  . Constraints Output Format If  , then print the lowercase English word corresponding to the number (e.g.,  one  for  ,  two  for  , etc.); otherwise, print  Greater than 9  instead. Sample Input 5 Sample Output five Sample Input #01 8 Sample Output #01 eight Sample Input #02 44 Sample Output #02 Greater than 9 code : #include   < assert.h > #include   < limits.h > #include   < math.h > #include   < stdbool.h > #include   < stddef.h > #include   < stdint.h > #include   < stdio.h > #include   < stdlib.h > #include   < string.h > char *...

Hacker Rank C Challengers #002

 Task Complete the function void update(int *a,int *b). It receives two integer pointers, int* a and int* b. Set the value of  to their sum, and  to their absolute difference. There is no return value, and no return statement is needed. Input Format The input will contain two integers,  and , separated by a newline. Output Format Modify the two values in place and the code stub main() will print their values.  Note: Input/ouput will be automatically handled. You only have to complete the function described in the 'task' section. Sample Input 4 5 Sample Output 9 1 So I created this Program :- Note : I import <math.h> header for use "abs " Command in Oder to get the absolute value .   #include   < stdio.h > #include   < math.h > void  update( int  *a, int  *b) {      // Complete this function       *a=*a+*b;     *b=abs(*a-( 2 **...

Hacker Rank C Challenges #001

Write a function  int max_of_four(int a, int b, int c, int d)   which reads four arguments and returns the greatest of them. here is the code I programmed #include   < iostream > #include   < cstdio > using   namespace  std; /* Add `int max_of_four(int a, int b, int c, int d)` here. */ int  max_of_four( int  a , int  b , int  c, int  d){      int  max= 0 ;      int  i;      for  (i= 1  ; i< 4  ; i++){          if  (max < a) {             max = a;         }          if  (max < b) {          ...