11. Create a program to find the area of a circle.
Required Input:
radius = 5
Expected Output:
Area = 78.5
Code In Cpp
#include
#define PI 3.14
int main() {
float radius = 5;
// Logic to calculate area
return 0;
}
Output
Click Run Button to view compiled output
12. Write a program to find the square of a number.
Required Input:
n = 4
Expected Output:
Square = 16
Code In Cpp
#include
int main() {
int n = 4;
// Logic to calculate square
return 0;
}
Output
Click Run Button to view compiled output
13. Create a program to convert Celsius to Fahrenheit.
Required Input:
celsius = 25
Expected Output:
Fahrenheit = 77
Code In Cpp
#include
int main() {
float celsius = 25;
// Logic to convert Celsius to Fahrenheit
return 0;
}
Output
Click Run Button to view compiled output
14. Write a program to check whether a character is an alphabet.
Required Input:
ch = 'A'
Expected Output:
A is an Alphabet
Code In Cpp
#include
int main() {
char ch = 'A';
// Logic to check if ch is an alphabet
return 0;
}
Output
Click Run Button to view compiled output
15. Create a program to find the sum of first N natural numbers.
Required Input:
N = 5
Expected Output:
Sum = 15
Code In Cpp
#include
int main() {
int N = 5;
// Logic to find the sum of first N natural numbers
return 0;
}
Output
Click Run Button to view compiled output
16. Write a program to find the smallest of three numbers.
Required Input:
a = 5, b = 3, c = 8
Expected Output:
Smallest = 3
Code In Cpp
#include
int main() {
int a = 5, b = 3, c = 8;
// Logic to find the smallest number
return 0;
}
Output
Click Run Button to view compiled output
17. Create a program to check if a number is prime.
Required Input:
n = 7
Expected Output:
7 is Prime
Code In Cpp
#include
int main() {
int n = 7;
// Logic to check if n is prime
return 0;
}
Output
Click Run Button to view compiled output
18. Write a program to find the GCD of two numbers using the Euclidean algorithm.
Required Input:
a = 48, b = 18
Expected Output:
GCD = 6
Code In Cpp
#include
int main() {
int a = 48, b = 18;
// Logic to find GCD
return 0;
}
Output
Click Run Button to view compiled output
19. Create a program to find the reverse of a string.
Required Input:
str = "Hello"
Expected Output:
Reversed String = olleH
Code In Cpp
#include
#include
int main() {
std::string str = "Hello";
// Logic to reverse the string
return 0;
}
Output
Click Run Button to view compiled output
20. Write a program to check if a string is a palindrome.
Required Input:
str = "madam"
Expected Output:
madam is a Palindrome
Code In Cpp
#include
#include
int main() {
std::string str = "madam";
// Logic to check if str is a palindrome
return 0;
}
Output
Click Run Button to view compiled output