Skip to content

parvezaman/c-hackerrank-problem-solving

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

c-hackerrank-problem-solving

Problem Lists

Problem :

Problem 1: Hello World! in C

This challenge requires you to print Hello World on a single line, and then print the already provided input string to stdout. If you are not familiar with C, you may want to read about the printf() command.

Problem 2: Sum and Difference of two numbers

our task is to take two numbers of int data type, two numbers of float data type as input and output their sum:

1. Declare 4 variables: two of type int and two of type float.

2. Read 2 lines of input from stdin (according to the sequence given in the 'Input Format' section below) and initialize your 4 variables.

3. Use the and operator to perform the following operations:

3.1. Print the sum and difference of two int variable on a new line.

3.2. Print the sum and difference of two float variable rounded to one decimal place on a new line.

Problem 3: Functions in C

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.

Problem 4: Pointers in C

Complete the function void update(int *a,int *b). It receives two integer pointers, int* a and int* b. Set the value of a to their sum, and b to their absolute difference. There is no return value, and no return statement is needed.

α = (a + b)

β = |a - b|

Problem 5: Conditionals and loops

Given a positive integer denoting n, do the following:

If 1 ≤ n ≤ 9, print the lowercase English word corresponding to the number (e.g., one for 1, two for 2, etc.).

If n ≥ 9 , print Greater than 9.

Problem 6: For loop in C

For each integer n in the interval [a,b] (given as input) :

If 1 ≤ n ≤ 9, print the lowercase English word corresponding to the number (e.g., one for 1, two for 2, etc.).

Else if n > 9 and it is an even number, then print "even"

Else if n > 9 and it is an odd number, then print "odd".

Problem 7: Sum of digits of a 5 digit number

Given a five digit integer, print the sum of its digits.

Problem 8: Printing pattern using loop in C

Print a pattern of numbers from to as shown below. Each of the numbers is separated by a single space.

Problem 9: Playing with charecters

You have to print the character,ch , in the first line. Then print s in next line. In the last line print the sentence, sen .

Problem 10: 1D Arrays in C

In this challenge, create an array of size n dynamically, and read the values from stdin. Iterate the array calculating the sum of all elements. Print the sum and free the memory where the array is stored.

While it is true that you can sum the elements as they are read, without first storing them to an array, but you will not get the experience working with an array. Efficiency will be required later.

Problem 11: Arrays Reversal

If array, arr=[1,2,3] , after reversing it, the array should be,arr = [3,2,1] .

Problem 12: Bitwise operators

In this challenge, you will use logical bitwise operators. All data is stored in its binary representation. The logical operators, and C language, use 1 to represent true and 0 to represent false. The logical operators compare bits in two numbers and return true or false, 0 or 1, for each bit compared.

Bitwise AND operator & The output of bitwise AND is 1 if the corresponding bits of two operands is 1. If either bit of an operand is 0, the result of corresponding bit is evaluated to 0. It is denoted by &.

Bitwise OR operator | The output of bitwise OR is 1 if at least one corresponding bit of two operands is 1. It is denoted by |.

Bitwise XOR (exclusive OR) operator ^ The result of bitwise XOR operator is 1 if the corresponding bits of two operands are opposite. It is denoted by .

Problem 13: Calculate N th term

There is a series, S, where the next term is the sum of pervious three terms. Given the first three terms of the series,a, b, and c respectively, you have to output the nth term of the series using recursion.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages