Delete node linked list C++

Solution:

Solution:

//Insert at nth position linked list C++.

//This program inserts every where except the first location i.e. does not insert at head.

//This program inserts every where except the first location i.e. does not insert at head.

Solution:

//What will be its output?

#include <iostream>

using namespace std;

f();

void main(){

f();

f();

f();

}

f(){

static a = 0;

cout << a++ << ' ';

}

Reactions: |

What is Bubble Sort or Bubble Sorting?

•Sorting data

•Bubble sort (sinking sort)

•Example:

•Swapping variables
**int x = 3, y = 4;**
**y = x;**
**x = y;**

•Solution
**int x = 3, y = 4, temp = 0;**
**temp = x; // temp gets 3**
**x = y; // x gets 4**
**y = temp; // y gets 3**

__Bubble Sorting in C++:__

In Bubble Sort, we follow following steps:

•Sorting data

–Important computing application

–Virtually every organization must sort some data

•Massive amounts must be sorted

•Bubble sort (sinking sort)

–Several passes through the array

–Successive pairs of elements are compared

•If increasing order (or identical), no change

•If decreasing order, elements exchanged

–Repeat these steps for every element

•Example:

–Go left to right, and exchange elements as necessary

•One pass for each element

–Original: 3 4 2 7 6

–Pass 1: 3 __2 4__ __6 7__ (elements exchanged)

–Pass 2: __2 3__ 4 6 7

–Pass 3: 2 3 4 6 7 (no changes needed)

–Pass 4: 2 3 4 6 7

–

–Small elements "bubble" to the top (like 2 in this example)

•Swapping variables

•What happened?

–Both x and y are 3!

–Need a temporary variable

•Solution

#include<iostream>

using namespace std;

How to Open Web Page using C++?

#include <windows.h>

int main()

{

ShellExecute(NULL, "open", "http://truefastians.blogspot.com",

NULL, NULL, SW_SHOWNORMAL);

}

#include <windows.h>

int main()

{

ShellExecute(NULL, "open", "http://truefastians.blogspot.com",

NULL, NULL, SW_SHOWNORMAL);

}

Download Torch Browser, and Download Videos from any site by just a single Click.

It's my personal experience.

Reactions: |

The value of Ï€ can be determined by the series equation

Ï€=4∗(1-1/3+1/5−1/7+1/9−1/11+1/13…)

Write a program that prompts the user to enter a positive odd number n and uses recursion to approximate the value of Ï€ using the given formula including term up through 1/n.

Solution:

Ï€=4∗(1-1/3+1/5−1/7+1/9−1/11+1/13…)

Write a program that prompts the user to enter a positive odd number n and uses recursion to approximate the value of Ï€ using the given formula including term up through 1/n.

Solution:

Reactions: |

Recursive function to search through array.

Write a program that asks the user to enter 10 integers, stores these numbers in an array. The program should ask if the user would like to search an element in the array, in which case the program should then prompt the user to enter the number to look for. Use a recursive function find( int index, int target, int array[] ) that does sequential search for a target in this array. Display an appropriate message to the user after searching the element.

Solution:

Write a program that asks the user to enter 10 integers, stores these numbers in an array. The program should ask if the user would like to search an element in the array, in which case the program should then prompt the user to enter the number to look for. Use a recursive function find( int index, int target, int array[] ) that does sequential search for a target in this array. Display an appropriate message to the user after searching the element.

Solution:

Write a recursive function of determining whether a string is palindrome or not.

Note: A palindrome is a string that can be read the same both forward and backwards such as racecar, mom etc.

Note: A palindrome is a string that can be read the same both forward and backwards such as racecar, mom etc.

Solution:

Reactions: |

Labels:
C++,
Palindrome,
recursion,
recursive,
String

Write a recursive function that finds and returns the minimum or smallest elemnt in an array, where the array and its size are given as parameters.

Solution:

What will be the output?

#include <iostream>

using namespace std;

void f(int);

int main()

{

f(2);

return 0;

}

void f(int n)

{

if (n == 0)

cout << n << ' ';

else

f(n-1);

}

Reply in comments.

#include <iostream>

using namespace std;

void f(int);

int main()

{

f(2);

return 0;

}

void f(int n)

{

if (n == 0)

cout << n << ' ';

else

f(n-1);

}

Reply in comments.

Reactions: |

Write a function int Power(int a, int b) that calculates the power a^b. You are allowed to use multiplication operator *.

Solution:

Solution:

Write a function int Mul(int a, int b) that computes the product of two integers a and b. The only arithmetic operation that you are allowed to use is addition '+'.

Solution:

Solution:

Reactions: |

Write a recursive function that computes and returns the sum of all elements in an array, where the array will be created dynamically by getting the size from the user. Array and its size are given as parameters.

Solution:

Solution:

Write a recursive function in C++ that computes the sum of all numbers from 1 to n, where n is given as parameters.

Solution:

Solution:

Reactions: |

Subscribe to:
Posts (Atom)