C++ Codes
Wednesday, 27 December 2017
IMPLEMENT BINARY SEARCH IN AN ARRAY
For any c++ code ask me in the comments below.
Labels:
algorithm,
binary search,
bubble sort,
c++,
change color,
change colour,
codes,
coding,
color,
colour,
function,
gcd,
java,
learn c++,
linear search,
object,
program,
python,
search
Monday, 25 December 2017
HOW TO CHANGE COLOR OF TEXT IN C++
In this blog let us see how to change color of text in C++
C++ code to change color of the text-
Sample output for the above program-
Color codes for different color-
- BLACK 0
- BLUE 1
- GREEN 2
- CYAN 3
- RED 4
- MAGENTA 5
- BROWN 6
- LIGHTGREY 7
- DARKGREY 8
- LIGHTBLUE 9
- LIGHTGREEN 10
- LIGHTCYAN 11
- LIGHTRED 12
- LIGHTMAGENTA 13
- YELLOW 14
- WHITE 15
- BLINK 128
Note-
With reference to my c++ code above, anything written below line number 8 will be printed in Light magenta.
In order to change color once again in the program, write "SetConsoleTextAttribute(handle,(any number from above of your choice));".
This will change the color of all the text below it.
For any c++ code ask me in the comments below.
I will code and give you the answer, thus making your homework easy.
Labels:
algorithm,
binary search,
c++,
change,
change color,
change colour,
codes,
coding,
color,
colour,
factorial,
function,
gcd,
java,
learn c++,
linear search,
object,
program,
python,
search
Thursday, 21 December 2017
TO IMPLEMENT BINARY SEARCH
In this blog let us see how to implement Binary Search in an array-
Sample output for the above program-
- When the user searches value that is present in the array-
- When the user searches value that is not present in the array-
For any c++ code ask me in the comments below.
I will code and give you the answer, thus making your homework easy.
Tuesday, 19 December 2017
TO IMPLEMENT LINEAR SEARCH
In this blog let us see how to implement a Linear Search in an array-
Sample output for the above program-
- When user searches for value present in the array-
- When the value searched is present at multiple positions-
- When user searches for value NOT present in the array-
A brief explanation of the code-
- First we will take the size of the array as input.
- Then we will ask the user to enter the elements of the array.
- Then we will let user to enter a value that needs to be searched "find".
- Using 'for' loop we will run through the entire array and for each element 'if' equal to "find" we will display that particular element.
For any c++ code ask me in the comments below.
I will code and give you the answer, thus making your homework easy.
Monday, 18 December 2017
TO FIND GCD OF THREE NUMBER
In this blog let us see how to find the GCD (Greatest common divisor) of three number-
Sample output of the above code-
A brief explanation of the code-
- We take inputs from the user.
- We find the greatest number among the 3 given number and store it in a variable "max".
- "max" is used for the start of the "for" loop.
- The first "i" value that divides all the values a,b, and c is the GCD, hence we print it and break the loop.
For any c++ code ask me in the comments below.
I will code and give you the answer, thus making your homework easy.
Sunday, 17 December 2017
TO PRINT A GIVEN STRING IN A 'X' LIKE PATTERN
In this blog let us see how to print a given string in following fashion-
For example let us take a string "HELLO"
We have to print it this way-
H O
E L
L
E L
H O
Let's see the code for this problem-
For example let us take a string "HELLO"
We have to print it this way-
H O
E L
L
E L
H O
Let's see the code for this problem-
A sample output for the above program-
For any c++ code ask me in the comments below.
I will code and give you the answer, thus making your homework easy.
Saturday, 16 December 2017
TO COUNT ODD AND EVEN NUMBERS FROM AN ARRAY -C++
In this blog let us see how to count odd and even numbers from a given array-
In this code I have used a dynamic array, which means first we will ask the user for the size of the array and then we will create the array of size as given by the user,
A sample output for the above program-
The inputs given by the user-
The size of array is given as '5'
Inputs-
- 18
- 23
- 332
- 42
- 4543
For any c++ code ask me in the comments below.
I will code and give you the answer, thus making your homework easy.
Subscribe to:
Posts (Atom)