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

11வது கணினி அறிவியல் : அலகு 11 : செயற்கூறுகள்

எடுத்துக்காட்டு C++ நிரல்கள் : செயற்கூறுகள்

கணினி அறிவியல் : செயற்கூறுகள் : எடுத்துக்காட்டு C++ நிரல்கள் : செயற்கூறுகள்

நிரல் 11.1 C++ மொழியில் ஒரு எழுத்தை உள்ளீடவும் மற்றும் வெளியிடுவதற்கான நிரல்

#include<iostream>

#include<stdio.h>

using namespace std;

int main()

{

      cout<<"\n Type a Character : ";

      char ch = getchar();

      cout << "\n The entered Character is: ";

      putchar(ch);

      return 0;

}

வெளியீடு:

Type a Character : T

The entered Character is: T

 

நிரல் 11.2 சரத்தை உள்ளீடு மற்றும் வெளியீடு செய்வதற்கான C++ நிரல் :

#include<iostream>

#include<stdio.h>

using namespace std;

int main()

{

      char str[50];

      cout<<"Enter a string : ";

      gets(str);

      cout<<"You entered: "

      puts(str);

      return(0);

}

வெளியீடு:

Enter a string : Computer Science

You entered: Computer Science


நிரல் 11.3

#include<iostream>

#include<stdio.h>

#include<ctype.h>

using namespace std;

int main()

{

      char ch;

      int r;

      cout<<"\n Type a Character :";

      ch = getchar();

      r = isalnum(ch);

      cout<<"\nThe Return Value of isalnum(ch) is :"<<r;

}

வெளியீடு-1:

Type a Character :A

The Return Value of isalnum(ch) is :1

வெளியீடு-2:

Type a Character :?

The Return Value of isalnum(ch) is :0


நிரல் 11.4 

#include<iostream>

#include<stdio.h>

#include<ctype.h>

using namespace std;

int main()

{

      char ch;

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

      ch = getchar();

      cout<<"\n The Return Value of isalpha(ch) is :" << isalpha(ch) ;

}

வெளியீடு -1:

Enter a charater: A

The Return Value of isalpha(ch) is :1

வெளியீடு - 2:

Enter a charater: 7

The Return Value of isalpha(ch) is :0


நிரல் 11.5

using namespace std;

#include<iostream>

#include<ctype.h>

int main()

{

      char ch;

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

      cin >> ch;

      cout<<"\n The Return Value of isdigit(ch) is :" << isdigit(ch) ;

}

வெளியீடு -1

Enter a Character: 3

The Return Value of isdigit(ch) is :1

வெளியீடு -2

Enter a Character: A

The Return Value of isdigit(ch) is :0


நிரல் 11.6

#include <string.h>

#include <iostream>

using namespace std;

int main()

{

      char source[] = "Computer Science";

      char target[20]="target";

      cout<<"\n String in Source Before Copied :"<<source;

      cout<<"\n String in Target Before Copied :"<<target; strcpy(target,source);

      cout<<"\n String in Target After strcpy function Executed :"<<target; return 0;

}

வெளியீடு:

String in Source Before Copied :Computer Science

String in Target Before Copied :target

String in Target After strcpy function Executed :Computer Science


நிரல் 11.7

#include <string.h>

#include <iostream>

using namespace std;

int main()

{

      char source[ ] = "Computer Science";

      cout<<"\nGiven String is "<<source<<" its Length is "<<strlen(source);

      return 0;

}

வெளியீடு:

Given String is Computer Science its Length is 16


நிரல் 11.8

#include <string.h>

#include <iostream>

using namespace std;

int main()

{

      char string1[] = "Computer";

      char string2[] = "Science";

      int result;

      result = strcmp(string1,string2);

      if(result==0)

      {

      cout<<"String1 : "<<string1<<" and String2 : "<<string2 <<"Are Equal";

      }

      if (result<0)

      {

      cout<<"String1 :"<<string1<<" and String2 : "<<string2 <<" Are Not Equal";

      }

}

வெளியீடு:

String1 : Computer and String2 : Science Are Not Equal


நிரல் 11.9.

#include <string.h>

#include <iostream>

using namespace std;

int main()

{

      char target[50] = "Learning C++ is fun";

      char source[50] = " , easy and Very useful";

      strcat(target, source);

      cout << target ;

      return 0;

}

வெளியீடு:

Learning C++ is fun , easy and Very useful


நிரல் 11.10

using namespace std;

#include<iostream>

#include<ctype.h>

#include<string.h>

int main()

{

      char str1[50];

      cout<<"\nType any string in Lower case :";

      gets(str1);

      cout<<"\n Converted the Source string “<<str1<<into Upper Case is "<<strupr(str1); return 0;

}

வெளியீடு:

Type any string in Lower case : computer science

Converted the Source string computer science into Upper Case is COMPUTER SCIENCE


நிரல் 11.11

using namespace std;

#include<iostream>

#include<ctype.h>

#include<string.h>

int main()

{

      char str1[50];

      cout<<"\nType any string in Upper case :";

      gets(str1);

      cout<<"\n Converted the Source string “<<str1<<into Lower Case is "<<strlwr(str1);

}

வெளியீடு:

Type any string in Upper case : COMPUTER SCIENCE

Converted the Source string COMPUTER SCIENCE into lower Case is computer science


நிரல் 11.12

#include <iostream>

#include <math.h>

using namespace std;

int main()

{

      double x = 0.5, result;

      result = cos(x);

      cout << "COS("<<x<<")= "<<result;

}

வெளியீடு:

COS(0.5)= 0.877583


நிரல் 11.13

#include <iostream>

#include <math.h>

using namespace std;

int main()

{

      double x = 625, result;

      result = sqrt(x);

      cout << "sqrt("<<x<<") = "<<result;

      return 0;

}

வெளியீடு:

sqrt(625) = 25


நிரல் 11.14

#include <iostream>

#include <math.h>

using namespace std;

int main ()

{

      double base, exponent, result;

      base = 5;

      exponent = 4;

      result = pow(base, exponent);

      cout << "pow("<<base << "^" << exponent << ") = " << result;

      double x = 25;;

      result = sin(x);

      cout << "\nsin("<<x<<")= "<<result;

      return 0;

}

வெளியீடு:

pow(5^4) = 625

sin(25)= -0.132352


நிரல் 11.15

#include<iostream>

#include<cstdlib.h>

using namespace std;

int main()

{

      int random = rand(); /* No srand() calls before rand(), so seed = 1*/

      cout << "\nSeed = 1, Random number = " << random; srand(10);

      /* Seed = 10 */

      random = rand();

      cout << "\n\nSeed = 10, Random number = " << random;

      return 0;

}

வெளியீடு:

Seed = 1, Random number = 41

Seed = 10, Random number = 71


நிரல் 11.16

#include <iostream>

using namespace std;

double area(const double r,const double pi=3.14)

{

      return(pi*r*r);

}

int main ()

{

      double rad,res;

      cout<<"\nEnter Radius :";

      cin>>rad;

      res=area(rad);

      cout << "\nThe Area of Circle ="<<res;

      return 0;

}

வெளியீடு :

Enter Radius :5

The Area of Circle =78.5


நிரல் 11.17

#include<iostream>

using namespace std;

void display(int x)

{

      int a=x*x;

      cout<<"\n\nThe Value inside display function (a * a):"<<a;

}

int main()

{

      int a;

      cout<<”\nExample : Function call by value:”;

      cout<<"\n\nEnter the Value for A :";

      cin>>a;

      display(a);

      cout<<"\n\nThe Value inside main function "<<a;

      return(0);

}

வெளியீடு :

Example : Function call by value

Enter the Value for A : 5

The Value inside display function (a * a) : 25

The Value inside main function 5


நிரல் 11.18

#include<iostream>

using namespace std;

void display(int &x) //passing address of a//

{

      x=x*x;

      cout<<"\n\nThe Value inside display function (n1 x n1) :"<<x ;

}

int main()

{

int n1;

cout<<"\nEnter the Value for N1 :";

cin>>n1;

cout<<"\nThe Value of N1 is inside main function Before passing : "<< n1; display(n1);

cout<<"\nThe Value of N1 is inside main function After passing (n1 x n1) : "<< n1; return(0);

}

வெளியீடு :

Enter the Value for N1 :45

The Value of N1 is inside main function Before passing : 45

The Value inside display function (n1 x n1) :2025

The Value of N1 is inside main function After passing (n1 x n1) : 2025


நிரல் 11.19

#include <iostream>

using namespace std;

inline float simpleinterest(float p1,float n1, float r1)

{

      float si1=(p1*n1*r1)/100;

      return(si1);

}

int main ()

{

      float si,p,n,r;

      cout<<"\nEnter the Principle Amount Rs. :";

      cin>>p;

      cout<<"\nEnter the Number of Years :";

      cin>>n;

      cout<<"\nEnter the Rate of Interest :";

      cin>>r;

      si=simpleinterest(p,n,r);

      cout << "\nThe Simple Interest = Rs."<<si;

      return 0;

}

வெளியீடு:

Enter the Principle Amount Rs. :60000

Enter the Number of Years     :10

Enter the Rate of Interest        :5

The Simple Interest = Rs.30000


நிரல் 11.20

#include<iostream>

using namespace std;

void display()

{

      cout<<"First C++ Program with Function";

}

int main()

{

      display(); // Function calling statement//

      return(0);

}

வெளியீடு :

First C++ Program with Function


நிரல் 11.21

#include<iostream>

using namespace std;

int display()

{

      int a, b, s;

      cout<<"Enter 2 numbers: ";

      cin>>a>>b;

      s=a+b;

      return s;

}

int main()

{

      int m=display();

      cout<<"\nThe Sum="<<m;

      return(0);

}

வெளியீடு :

Enter 2 numbers: 10 30

The Sum=40


நிரல் 11.22

#include<iostream>

using namespace std;

void display(int x, int y)

{

      int s=x+y;

      cout<<"The Sum of Passed Values: "<<s;

}

int main()

{

      int a,b;

      cout<<"\nEnter the First Number         :";

      cin>>a;

      cout<<"\nEnter the Second Number :";

      cin>>b;

      display(a,b);

      return(0);

}

வெளியீடு :

Enter the First Number :50

Enter the Second Number :45

The Sum of Passed Values: 95


நிரல் 11.23

#include<iostream>

using namespace std;

int display(int x, int y)

{

      int s=x+y;

      return s;

}

int main()

{

      int a,b;

      cout<<"\nEnter the First Number          :";

      cin>>a;

      cout<<"\nEnter the Second Number :";

      cin>>b;

      int s=display(a,b);

cout<<”\nExample:Function with Return Value and with Arguments”;

cout<<"\nThe Sum of Passed Values: "<<s; return(0);

}

வெளியீடு :

Enter the First Number :45

Enter the Second Number :67

Example: Function with Return Value and with Arguments 

The Sum of Passed Values: 112


நிரல் 11.24

#include<iostream>

#include<string.h>

using namespace std;

char *display()

{

      return (“chennai”);

}

int main()

{

      char s[50];

      strcpy(s,display());

      cout<<”\nExample:Function with Non Integer Return”<<s;

      return(0);

}

வெளியீடு :

Example: Function with Non Integer Return Chennai


நிரல் 11.25

#include<iostream>

using namespace std;

int main()

{

      int n1=150;

      int &n1ref=n1;

      cout<<"\nThe Value of N1 = "<<n1<<" and n1Reference = "<<n1ref;

      n1ref++;

      cout<<"\nAfter n1 increased the Value of N1 = "<<n1;

      cout<<" and n1Reference = "<<n1ref;

      return(0);

}

வெளியீடு :

The Value of N1 = 150 and n1Reference = 150

After n1 increased the Value of N1 = 151 and n1Reference = 151


எடுத்துக்காட்டு 1: தற்சுழற்சி முறையில் ஒரு எண்ணின் காரணியை கணக்கிடுக.

நிரல் 11.26

#include <iostream>

using namespace std;

int factorial(int); // Function prototype //

int main()

{

      int no;

      cout<<"\nEnter a number to find its factorial: ";

      cin >> no;

      cout << "\nFactorial of Number " << no <<" = " << factorial(no);

 return 0;

}

int factorial(int m)

{

      if (m > 1)

      {

      return m*factorial(m-1);

      }

      else

      {

      return 1;

}

 

}

வெளியீடு :

Enter a number to find its factorial: 5

Factorial of Number 5 = 120

 

குறிப்பு: main() செயற்கூறின் பின்பு factorial() செயற்கூறை எழுதியிருப்பதால் இந்த செயற்கூறின் முன் வடிவம் கொடுப்பது அவசியமானது.



11th Computer Science : Chapter 11 : Functions : Example C++ Programs: Functions in Tamil : 11th Standard TN Tamil Medium School Samacheer Book Back Questions and answers, Important Question with Answer. 11வது கணினி அறிவியல் : அலகு 11 : செயற்கூறுகள் : எடுத்துக்காட்டு C++ நிரல்கள் : செயற்கூறுகள் - : 11 ஆம் வகுப்பு தமிழ்நாடு பள்ளி சமசீர் புத்தகம் கேள்விகள் மற்றும் பதில்கள்.
11வது கணினி அறிவியல் : அலகு 11 : செயற்கூறுகள்