Progrm to find the squar root of a number in c, cpp,cplus plus

Program to find the square root of a number in c and CPP,c plus plus

In this tutorial, we will try to learn the followings;

  1. How to draw the flow chart of the square root of a number?
  2. How to find the square root of a number in C++?
  3. How to find the square root of a number in C?

Flow chart of the square root of a number

Progrm to find the squar root of a number in c, cpp,cplus plus
Figure: Program to find the square root of a number in c, CPPC++.

The square root of a number in C++

Output:

square root output
Figure: square root output.

Square root of only a Positive Number repeatedly using If else statement in C++

Let’s see the “program of the square root of a positive number in C++”.

Output Sample 1

Enter a number to find its square root: -4
Sorry it is a negative number

Output Sample 2

Enter a number to find its square root: 4
the square root of no is 2

The square root of a number repeatedly using nested if statement  in C++

Let’s see the “program of the square root of a number using nested if statement in C++”.

The square root of a number repeatedly using a do-while loop in C++

Let’s see the “program of the square root of a number repeatedly using do-while Loop in C++”.

Output:
Enter No of how many times you want to Find Square Root
2
Enter Value
3
Enter Value
4
The square root of 3 is 1.73205
The square root of 4 is 2

Square root of a number repeatedly using a For loop in C++

Let’s see the “program of the square root of a number repeatedly using For Loop in C++”.

Output:
Enter No of how many times you want to Find Square Root
2
Enter Value
3
Enter Value
4
The square root of 3 is 1.73205
The square root of 4 is 2

The square root of a number repeatedly using Array in C++

Let’s see the “program of the square root of a number using arrays in C++”.

Array: float array[HowManyTimes];

Output:
Enter No of how many times you want to Find Square Root
2
Enter Value
3
Enter Value
4
The square root of 3 is 1.73205
The square root of 4 is 2

The square root of a number in C?

Output:

square root output
Figure: square root output.
By: Prof. Fazal Rehman Shamil    CEO @ T4Tutorials.com
Whatsapp: +92 302 87 000 85     Facebook: For Discussions