📖 Samacheer Kalvi · 11th TN - English Medium · Computer Science · Page 138question

Data Types, Variables and Expressions · Part 9

Chapter 3: 4 · Computer Science

(in cm): "; cin >> radius; cout << "\n Enter Height (in cm): "; cin >> height; CSA = ( *pi*radius)*height; system("cls"); cout << "\n Radius: " << radius <<"cm"; cout << "\n Height: " << height << "cm"; cout << "\n Curved Surface Area of a Cylinder is " << CSA <<" sq. cm."; Output: Curved Surface Area of a cylinder Enter Radius (in cm): Enter Height (in cm): Radius: 7cm Height: 20cm Curved Surface Area of a Cylinder is . sq. cm.

Illustration . C++ Program to find the Curved Surface Area of a cylinder (CSA) (CSA = pi r * h) Variables that are of the same type can be initialized in a single statement. Chapter Page - - Example: int x1 = - , x2 = , x3, n; . .

Dynamic Initialization A variable can be initialized during the execution of a program. It is known as “ Dynamic initialization ”. For example, int num1, num2, sum; sum = num1 + num2; The above two statements can be combined into a single one as follows: int sum = num1+num2; This initializes sum using the known values of num1 and num2 during the execution. #include <iostream> using namespace std; int main() int num1, num2; cout << "\n Enter number : "; cin >> num1; cout << "\n Enter number : "; cin >> num2; int sum = num1 + num2; // Dynamic initialization cout << "\n Average: " << sum / ; Output: Enter number : Enter number : Average: Illustration .

C++ Program to illustrate dynamic initialization In the above program, after getting the values of num1 and num2, sum is declared and initialized with the addition of those two variables. After that, it is divided by . #include <iostream> using namespace std; int main() int radius; float pi = . ; cout << "\n Enter Radius (in cm): "; cin >> radius; float perimeter = (pi+ )*radius; // dynamic initialization float area = (pi*radius*radius)/ ; // dynamic initialization cout << "\n Perimeter of the semicircle is " << perimeter << "

Related topics

Have a question about this topic?

Get an AI answer grounded in your actual textbook — with the exact page reference.

Ask AI about this topic →