Home | 11 ஆம் வகுப்பு | 11வது கணினி அறிவியல் | அடிப்படை C++ நிரல்கள் தரவு வகைகள், மாறிகள் மற்றும் வெளிப்பாடுகள்
   Posted On :  12.11.2022 06:02 pm

11வது கணினி அறிவியல் : அலகு 9 : C++ ஓர் அறிமுகம்

அடிப்படை C++ நிரல்கள் தரவு வகைகள், மாறிகள் மற்றும் வெளிப்பாடுகள்

அடிப்படை C++ நிரல்கள் தரவு வகைகள், மாறிகள் மற்றும் வெளிப்பாடுகள்

எடுத்துக்காட்டு 9.1 இரண்டு முழு எண்களை பெற்று அதனுடைய கூட்டுத் தொகையை காண்பிக்கும் C++ நிரல்

//Program to receive two integer numbers and display their sum

#include <iostream>

using namespace std; int main()

{

      int num1, num2, sum;

      //variables num1, num2, and sum are declared as integers

      cout << "\n Enter Number 1: ";

      cin >> num1;

      cout << "\n Enter Number 2: "; cin >> num2;

      sum = num1 + num2;

      cout << "\n The sum of " << num1 << " and " << num2 << " is " << sum;

}


எடுத்துக்காட்டு 9.2 ஏதேனும் ஒரு குறியுருவைப் பெற்று அதனுடைய அடுத்த குறியுருவை தெரிவிக்கும் நிரல்.

#include <iostream>

using namespace std;

int main()

{

      char ch;

      cout << "\n Enter a character: ";

      cin >> ch;

      ch = ch + 1;

      cout << "\n The Next character: " << ch;

}

 

வெளியீடு:

Enter a character: A

The Next character: B

 


எடுத்துக்காட்டு நிரல் 9.3 ஒரு ASCII மதிப்பை பெற்று அதற்குரிய குறியுருவை காண்பிக்கும் C++ நிரல்

#include <iostream>

using namespace std;

int main ()

{

      int n;

      char ch;

      cout << "\n Enter an ASCII code (0 to 255): ";

      cin >> n;

      ch = n;

      cout << "\n Equivalent Character: " << ch;

}

 

வெளியீடு: 

Enter an ASCII code (0 to 255): 100

Equivalent Character: d


எடுத்துக்காட்டு 9.4 ஒரு வட்டத்தின் பரப்பளவைக் காண உதவும் C++ நிரல் 

#include <iostream>

using namespace std;

int main()

{

      float r, area;

      cout << "\n Enter Radius: ";

      cin >> r;

      area = 3.14 * r * r;

      cout << "\n The Area of the circle is " << area;

}

 

வெளியீடு: 

Enter Radius: 6.5

The Area of the circle is 132.665


எடுத்துக்காட்டு 9.5: C++ தரவினத்தின் அளவை கண்டறிவதற்கான நிரல்

#include <iostream>

using namespace std;

int main()

{

      short a;

      nsigned short b;

      signed short c;

      int d;

      unsigned int e;

      signed int f;

      long g;

      unsigned long h;

      signed long i;

      char j;

      unsigned char k;

      signed char l;

      float m;

      double n;

      long double p;

      cout << "\n Size of short = " << sizeof(a);

      cout << "\n Size of unsigned short = " << sizeof(b);

      cout << "\n Size of signed short = " << sizeof (c);

      cout << "\n Size of int = " << sizeof(d);

      cout << "\n Size of unsigned int = " << sizeof(e);

      cout << "\n Size of signed int = " << sizeof(f);

      cout << "\n Size of long = " << sizeof(g);

      cout << "\n Size of unsigned long = " << sizeof(h);

      cout << "\n Size of signed long = " << sizeof(i);

      cout << "\n Size of char = " << sizeof(j);

      cout << "\n Size of unsigned char = " << sizeof(k);

      cout << "\n Size of signed char = " << sizeof(l);

      cout << "\n Size of float = " << sizeof(m);

      cout << "\n Size of double = " << sizeof(n);

      cout << "\n Size of long double = " << sizeof(p);

}


வெளியீடு: (Dev C++ ல் தொகுத்து இயக்கப்படுகிறது) 

Size of short = 2

Size of unsigned short = 2

Size of signed short = 2

Size of int = 4

Size of unsigned int = 4

Size of signed int = 4

Size of long = 4

Size of unsigned long = 4

Size of signed long = 4

Size of char = 1

Size of unsigned char = 1

Size of signed char = 1

Size of float = 4

Size of double = 8

Size of long double = 12


எடுத்துக்காட்டு 9.6 உருளையின் வளைந்த மேற்பரப்பை கண்டறியும் நிரல் (CSA = 2 pi rh) 

#include <iostream>

using namespace std;

int main()

{

      float pi = 3.14, radius, height, CSA;

      cout << "\n Curved Surface Area of a cylinder";

      cout << "\n Enter Radius (in cm): ";

      cin >> radius;

      cout << "\n Enter Height (in cm): ";

      cin >> height;

      CSA = (2*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.";

}

 

வெளியீடு: 

Curved Surface Area of a cylinder

Enter Radius (in cm): 7

Enter Height (in cm): 20

Radius: 7cm

Height: 20cm

Curved Surface Area of a Cylinder is 879.2 sq. cm.


எடுத்துக்காட்டு 9.7 இயங்கு நிலை தொடக்க மதிப்பிருத்தலை விளக்கும் C++ நிரல்

#include <iostream>

using namespace std;

int main()

{

      int num1, num2;

      cout << "\n Enter number 1: ";

      cin >> num1;

      cout << "\n Enter number 2: ";

      cin >> num2;

      int sum = num1 + num2; // Dynamic initialization

      cout << "\n Average: " << sum /2;

} 

வெளியீடு: 

Enter number 1: 78

Enter number 2: 65

Average: 71


எடுத்துக்காட்டு 9.8 அரைவட்டத்தின் சுற்றளவு மற்றும் பரப்பை கண்டறியும் C++ நிரல்

#include <iostream>

using namespace std;

int main()

{

      int radius;

      float pi = 3.14;

      cout << "\n Enter Radius (in cm): ";

      cin >> radius;

      float perimeter = (pi+2)*radius; // dynamic initialization

      float area = (pi*radius*radius)/2; // dynamic initialization

      cout << "\n Perimeter of the semicircle is " << perimeter << " cm";

      cout << "\n Area of the semicircle is " << area << " sq.cm";

}

 

வெளியீடு: 

Enter Radius (in cm): 14

Perimeter of the semicircle is 71.96 cm

Area of the semicircle is 307.72 sq.cm

 

எடுத்துக்காட்டு 9.9 குறிப்பு மாறிகளை அறிவிக்கும் C++ நிரல்

#include <iostream>

using namespace std;

int main()

{

      int num;

      int &temp = num; //declaration of a reference variable temp

      num = 100;

      cout << "\n The value of num = " << num;

      cout << "\n The value of temp = " << temp;

}

 

வெளியீடு:

The value of num = 100

The value of temp = 100


எடுத்துக்காட்டு 9.10 சம்பளக் கணக்கீட்டிற்கான நிரல்

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

      float basic, da, hra, gpf, tax, gross, np;

      char name[30];

      cout << "\n Enter Basic Pay: ";

      cin >> basic;

      cout << "\n Enter D.A : ";

      cin >> da;

      cout << "\n Enter H.R.A: ";

      cin >> hra;

      gross = basic+da+hra; // sum of basic, da nad hra

      gpf = (basic+da) * 0.10; // 10% 0f basic and da

      tax = gross * 0.10; //10% of gross pay

      np = gross - (gpf+tax); //netpay = earnings - deductions

      cout << setw(25) << "Basic Pay : " << setw(10)<< basic<< endl;

      cout << setw(25) << "Dearness Allowance : "<< setw(10)<<da<< endl;

      cout<<setw(25)<<"House Rent Allowance : "<<setw(10)<< hra<<endl;

      cout << setw(25) << "Gross Pay : " << setw(10) << gross << endl;

      cout << setw(25) << "G.P.F : " << setw(10) << gpf << endl;

      cout << setw(25) << "Income Tax : " << setw(10)<< tax << endl;

      cout << setw(25) << "Net Pay : " << setw(10) << np << endl;

}


வெளியீடு: 

Enter Basic Pay: 12000

Enter D.A : 1250

Enter H.R.A : 1450

Basic Pay : 12000

Dearness Allowance : 1250

House Rent Allowance : 1450

Gross Pay : 14700

G.P.F : 1325

Income Tax : 1470

Net Pay : 11905

(HOT: Try to make multiple output statements as a single cout statement)


setprecision ( )

எடுத்துக்காட்டு:

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

      float hra = 1200.123;

      cout << setprecision (5) << hra;

}

எடுத்துக்காட்டு:

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

      cout.setf(ios::fixed);

      cout << setprecision(2)<<0.1;

}

(1) உள்ளுறை இனமாற்றம் (Implicit type conversion):

எடுத்துக்காட்டு:

#include <iostream>

using namespace std;

int main()

{

      int a=6;

      float b=3.14;

      cout << a+b;

}

(2) வெளியுறை இனமாற்றம் (Explicit type conversion)

எடுத்துக்காட்டு:

#include <iostream>

using namespace std;

int main( )

{

      float varf=78.685;

      cout << (int) varf;

}

எடுத்துக்காட்டு:

#include <iostream>

using namespace std;

int main()

{

double varf=178.25255685;

cout << (float) varf << endl;

cout << (int) varf << endl;

}

வெளியீடு: 

178.253

178


1. மூன்று பாட மதிப்பெண்களின் கூட்டுத்தொகையை கண்டறியும் C++ நிரல் 

#include <iostream>

using namespace std;

int main()

{

      int m1, m2, m3, sum;

      cout << "\n Enter Mark 1: ";

      cin >> m1;

      cout << "\n Enter Mark 2: ";

      cin >> m2;

      cout << "\n Enter Mark 3: ";

      cin >> m3;

      sum = m1 + m2 + m3;

      cout << "\n The sum = " << sum;

}

கொக்கப்படும் மதிப்பெண்களின் சராசரியை கணக்கிடும் வகையில், மேலே கொடுக்கப்பட்டுள்ள நிரலில் வேண்டிய மாற்றங்களை செய்து இயக்குக. 


2. வட்டத்தின் பரப்பளவை கண்டறியும் C++ நிரல்.

 

#include <iostream>

using namespace std;

int main()

{

      int radius;

      float area;

      cout << "\n Enter Radius: ";

      cin >> radius;

      area = 3.14 * radius * radius;

      cout << "\n The area of circle = " << area;

}


3. கீழே கொடுக்கப்பட்டுள்ள நிரலின் பிழைகளை கண்டறிக

#include <iostream>

Using namespace std;

int main( )

{

      cout << “Enter a value ”;

     cin << num1 >> num2

      num+num2=sum;

      cout >> “\n The Sum= ” >> sum;

}


4. கீழே கொடுக்கப்பட்டுள்ள நிரலில் எந்த வகையான பிழை உள்ளது என்று கண்டறிக: 

#include <iostream>

using namespace std;

int main()

{

      int h=10; w=12;

      cout << "Area of rectangle " << h+w;

}


11th Computer Science : Chapter 9 : Introduction to C++ : Basic C++ Programs in Data Types, Variables and Expressions in Tamil : 11th Standard TN Tamil Medium School Samacheer Book Back Questions and answers, Important Question with Answer. 11வது கணினி அறிவியல் : அலகு 9 : C++ ஓர் அறிமுகம் : அடிப்படை C++ நிரல்கள் தரவு வகைகள், மாறிகள் மற்றும் வெளிப்பாடுகள் - : 11 ஆம் வகுப்பு தமிழ்நாடு பள்ளி சமசீர் புத்தகம் கேள்விகள் மற்றும் பதில்கள்.
11வது கணினி அறிவியல் : அலகு 9 : C++ ஓர் அறிமுகம்