Showing posts with label Programs. Show all posts
Showing posts with label Programs. Show all posts

Friday, 2 March 2012

C++ program that counts the number of words in a string or a line


This is a C++ program, with the help of which you can find out how many words are there in a string or a line. Below is the coding.

#include "iostream.h"
#include "conio.h"
#include "string.h"
main()
{
 char str[50];
 int i, count = 1;
 cout << "\n\t Enter the string ";
 gets(str);
 while((str[i]!= '\0') && (str[i+1] != ' '))
 {
  if ((str[i] == ' ') || (str[i] == '.'))
  count++;
  i++;
 }
 cout << "\n\t Number of words in a string is " << count;
 return 0;
}

Step by step explanation: 
1. Header files used are iostream.h for input and out put functions, conio.h is used for functions like getch() and clrscr(), and string.h is used for function gets() and other string related function. If you don't use any of the above header file. The possible error which may come is : "X function should have prototype", where X can be any function.
2. main() function is starting of every function. All working, calls and loops are defined under main function only.
3. gets() function can be treated as an alternative of cin, when the case comes for string.
If you find any difficulty in understanding the program, or you have any proble, you may post your comment below.

Saturday, 18 February 2012

C++ program to illustrates the basic operation of add stack, delete stack and shows stack using linked list. The stack contains data of type integer.


// This program illustrates the basic operation of add stack, delete stack 
// and shows stack using linked list. The stack contains data of type integer.

#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
// Declares a stack structure
struct node
{
int data;
node *link;
};
// Function prototype declaration for add stack, delete stack and show stack
node *push(node *top, int val); // Add stack
node *pop(node *top, int &val); // Delete stack
void show_Stack(node *top); // Show stack
// Main programming logic
void main()
{
node *top;
int val;
int choice;
char opt = 'Y'; // To continue the do loop in case
top = NULL; // Initialization of Stack
clrscr();
do
{
cout << "\n\t\t Main Menu";
cout << "\n\t1. Addition of Stack";
cout << "\n\t2. Deletion from Stack";
cout << "\n\t3. Traverse of Stack";
cout << "\n\t4. Exit from Menu";
cout << "\n\nEnter Your choice from above ";
cin >> choice;
switch (choice)
{
case 1:
do
{
cout << "Enter the value to be added in the stack ";
cin >> val;
top = push(top, val);
cout << "\nDo you want to add more element <Y/N>? ";
cin >> opt;
} while (toupper(opt) == 'Y');
break;
case 2:
opt = 'Y'; // Initialize for the second loop
do
{
top = pop(top,val);
if (val != -1)
cout << "Value deleted from Stack is " << val;
cout << "\nDo you want to delete more element <Y/N>? ";
cin >> opt;
} while (toupper(opt) == 'Y');
break;
case 3:
show_Stack(top);
break;
case 4:
exit(0);
}
}
while (choice != 4);
}
// Function body for add stack elements
node *push(node *top, int val)
{
node *temp;
temp = new node;
temp->data = val;
temp->link = NULL;
if(top ==NULL)
top = temp;
else
{
temp->link = top;
top = temp;
}
return(top);
}
// Function body for delete stack elements
node *pop(node *top,int &val)
{
node *temp;
clrscr();
if (top == NULL )
{
cout<<"Stack Empty ";
val = -1;
}
else
{
temp = top;
top = top->link;
val = temp->data;
temp->link = NULL;
delete temp;
}
return (top);
}
// Function body for show stack elements
void show_Stack(node *top)
{
node *temp;
temp = top;
clrscr();
cout<<"The values are \n";
while (temp != NULL)
{
cout <<"\n"<< temp->data;
temp = temp->link;
}
}



Step by step explanation of programme:


1. "#include <iostream.h>", "#include <stdio.h>", "#include <conio.h>", "#include <stdlib.h>", "#include <ctype.h>" are the header files.
2. declare the stack structure by 'struct node' in which integer and pointer variable is defined.
3. Declare the function of add stack(push), delete stack(pop) , show stack.
4. Define the main function(void main) in which switch condition is defined and use 'do' loop for doing 'push, pop' operation by calling the functon of 'push, pop'.
5. Use the function of 'pop,show' for delete the stack element and show the stack element.

C++ program to perform all basic operations on queue


Program to perform all basic operations on queue

#include<iostream.h>
#include<conio.h>
#include<process.h>
class stud //CLASS DECLARATION
  {
char name[20];
stud *rear,*front;
public:
void add_end();
void add_front();
void del_front();
void del_end();
void display();
stud *link;
stud()
{
front = NULL;
rear=NULL;      //CONSTRUCTOR
}
};


//FUNCTION TO ADD IN THE END OF QUEUE
void stud::add_end()
  {
stud *temp;
if(rear==NULL)
{
rear=new stud;
cout<<"\n\tEnter the name ";
cin>>rear->name;
rear->link=NULL;
front=rear;
}
  else
    {
    temp=new stud;
    cout<<"\n\tEnter the name ";
    cin>>temp->name;
    temp->link=NULL;
    rear->link=temp;
    rear=temp;
    }
  }
//FUNCTION TO ADD IN THE FRONT OF THE QUEUE
void stud::add_front()
  {
  stud *temp;
  if(front==NULL)
{
front=new stud;
cout<<"\n\tEnter the name ";
cin>>front->name;
front->link=NULL;
rear = front;
}
  else
{
temp=new stud;
cout<<"\n\tEnter the name ";
cin>>temp->name;
temp->link=NULL;
temp->link=front;
front = temp;
}
  }
//FUNCTION TO DELETE FROM THE FRONT OF THE  QUEUE
void stud::del_front()
  {
  stud *temp;
  if(front==NULL)
    cout<<"\n\t\Queue is empty \";
  else
    {
    temp=new stud;
    temp=front;
front=front->link;


temp->link=NULL;
delete(temp);
}
  }
//FUNCTION TO DELETE FROM THE END OF THE QUEUE
void stud::del_end()
  {
  stud *temp,*back;
  if(rear==NULL)
cout <<"\n\t\Queue is empty \n";
  else
{
temp = front;
while (temp->link != NULL)
{
back = temp;
temp = temp->link;
}
back->link = NULL;
rear = back;
delete(temp);
}
  }
//FUNCTION TO DISPLAY THE QUEUE
void stud::display()
  {
  stud *temp;
  clrscr();
  if(front==NULL)
cout<<"\n\t\Queue is empty \n";
  else
    {
    cout<<"\n\n\t\t THE NAMES ARE ";
    temp=new stud;
temp=front;
    while(temp->link!=NULL)
      {
      cout<<"\n\t"<<temp->name;   //DISPLAYS THE NODE DATA
      temp=temp->link;       //TO POINT TO NEXT NODE
  }
    cout<<“\n\t”<<temp->name;
    }
  }
//M A I N   P R O G R A M
void main()
  {
  stud x;
  int ch;
  char choi='y';
  while((choi=='y')||(choi=='Y'))
    {
    clrscr();
cout << "\n\n\n\t\t\t——MENU——\n";    //TO SHOW MENU
cout << "\n\t\t\t 1. Add in the front. ";
cout << "\n\t\t\t 2. Add in the last";
cout << "\n\t\t\t 3. Delete from the front";
cout << "\n\t\t\t 4. Delete from the end. ";
cout << "\n\t\t\t 5.Exit ";
cout << "\n\n\n\n\n\tEnter your choice ";
cin>>ch;
switch(ch) //STATEMENT TO REACH THE REQUIRED INSERTION
  {
  case 1:    
x.add_front();
  break;
  case 2 :    
x.add_end();
  break;
case 3 :
x.del_front();
break;
  case 4 :  
x.del_end();
break;
case 5 :  
exit(0);
  break;
  default:
  cout<<"\n\tInvalid choice ";
  }
x.display();
cout<<"\n\n\tPress y to continue.... ";
cin>>choi;
}
  }  // E N D   O F   M A I N




Step by step explanation of programme:

1. #include<iostream.h>, #include<conio.h>, #include<process.h> are the header files.
2. 'class stud' is a class declaration.
3.  'void add_end();, void add_front();,void del_front();, void del_end();, void display();, stud *link;' are all the public function i.e we can use at anywhere.
4. Use the function of 'add,delete from front of the queqe and add, delete from end of the queqe' and dislay the queqe.
5. Now use the main function for print all operation.  

C++ program to illustrates the basic operation of circular to add queue, delete queue, and show queue using array. The queue contains data of type character.


// This program illustrates the basic operation of circular to add queue, delete queue, 
// and show queue using array. The queue contains data of type character.

#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
#define MAX 20 // Show maximum array length
char queue[MAX]; // Declares array global variable
int front, rear; // Declares integer front and read
// Function prototypes to add queue, delete queue and show queue in array implementation
void add_Q(char queue[], int front, char val, int &rear); // Add queue
char del_Q(char queue[], int &front, int rear); // Delete queue
void show_Q(char queue[], int front, int rear); // Show queue
void main()
{
int choice;
char val;
char opt = 'Y'; // To continue the do loop in case
rear = -1; // Initialization of Queue
front = -1;
clrscr();
do
{
cout << "\n\t\t Main Menu";
cout << "\n\t1. Addition of Queue";
cout << "\n\t2. Deletion from Queue";
cout << "\n\t3. Traverse of Queue";
cout << "\n\t4. Exit from Menu";
cout << "\n\nEnter Your choice from above ";
cin >> choice;
switch (choice)
{
case 1:
do
{
cout << "Enter the value to be added in the queue ";
cin >> val;
add_Q(queue, front, val, rear);
cout << "Do you want to add more element <Y/N>? ";
cin >> opt;
} while (toupper(opt) == 'Y');
break;
case 2:
opt = 'Y'; // Initialize for the second loop
do
{
val = del_Q(queue, front, rear);
if (val != -1)
cout << "Value deleted from Queue is " << val;
cout << "\nDo you want to delete more element <Y/N>? ";
cin >> opt;
} while (toupper(opt) == 'Y');
break;
case 3:
show_Q(queue, front, rear);
break;
case 4:
exit(0);
}
}
while (choice != 4);
}
// Function body to add circular queue with array of character
void add_Q(char queue[], int front, char val, int &rear)
{
if ((rear + 1) %  MAX == front)
{
cout << "Queue Full ";
}
else
{
rear = (rear + 1) % MAX;
queue[rear] = val;
}
}
// Function body to delete circular queue with array of character
char del_Q(char queue[], int &front, int rear)
{
char value;
if (front == rear)
{
cout << "Queue Empty ";
value = -1;
}
else
{
front = (front + 1) % MAX;
value = queue[front];
}
return (value);
}
// Function body to show circular queue with array
void show_Q(char queue[], int front, int rear)
{
clrscr();
cout << "The values are ";
do
{
front = (front + 1) % MAX;
cout << "\n" << queue[front];
}while(front != rear);
}



step by step explanation:

1. "#include <iostream.h>(input output stream)", " #include <stdio.h>(standard input output)", " #include <conio.h>(console input outputt)",
   " #include <stdlib.h>(standard library)", #include <ctype.h> are the headers files.
2. Define array as a global variable with length of 20.
3. Define the function for 'Add Queqe, Delete Queqe, Show Queqe'.
4. Define the main function and initilise the queqe as 'rear=-1 and front=-1'.
5. define the function of add and delete in 'do' loop is define in 'switch' case .
6. 'do while' loop is used  for doing and check operation.

C++ program to find the square root of different integers.


C++ program to find the square root of different integers.

# include"iostream.h"
# include"math.h"
int sroot(int  n)
{
 return(sqrt(n));
}
long int sroot(long int  n)
{
 return(sqrt(n));
}
double sroot(double n)
{
 return(sqrt(n));
}
void main()
{
 int num;
 long int num1;
 double num2;
 cout << "Enter the value of num ";
 cin >> num;
 cout <<  "Enter the value of num1";
 cin >> num1;
 cout << "Enter the value of num2 ";
 cin >> num2;
 cout << "\nSquare root of int is " << sroot(num);
 cout << "\nSquare root of long int is " << sroot(num1);
 cout << "\nSquare root of double is " << sroot(num2);
}

step by step explaination:
1.Header file "iostream" is used to including the function and cin and cout.
2.Header file "math.h" is used to calculating the mathematical function.
3.Main is also a function of void type it is worked untill the curley brackets.

C++ program to perform all operations on strings. Count the length of two strings, concatenate two strings, compare two strings.


C++ program to perform all operations on strings. Count the length of two strings, concatenate two strings, compare two strings.

#include"iostream.h"
#include"conio.h"
#include"stdio.h"
void findlength()
{
 char str[30];
 int l=0;
 cout<<"\n Enter the string (size < =30) ";
 gets(str);
 while(str[l]!='\0')
 {
  l++;
 }
 cout<<"\n Length Of the given String is: "<< l<< endl;
}
void compare()
{
 char str1[30], str2[30];
 int l1=0,l2=0,i=0,flag=0;
 cout<<"\n Enter the string1 (size< =30) ";
 gets(str1);
 while(str1[l1]!='\0')
 {
  l1++;
 }
 cout<<"\n Enter the string2 (size< =30) ";
 gets(str2);
 while(str2[l2]!='\0')
 {
  l2++;
 }
 if(l2!=l1)
 {
  cout<<"\n Strings are not Equal ";
 }
 else
 {
  for(i=0;i< l1; i++ )
  {
      if(str1[i]!=str2[i])
      {
   flag=1;
   break;
      }
  }
  if(flag==1)
  {


   cout<< "\n Strings are not Equal ";
  }
  else
  {
   cout<< "\n Strings are Equal ";
  }
 }




}


void concat()
{
 char str1[30], str2[30];
 int l1=0,l2=0,i=0,flag=0;
 cout<<"\n Enter the string1 (size< =30 ) ";
 gets(str1);
 while(str1[l1]!='\0')
 {
  l1++;
 }
 cout<<"\n Enter the string2 (size< =30 ) ";
 gets(str2);
 while(str2[l2]!='\0')
 {
  l2++;
 }
 for(i=0;i < l2;i++)
 {
  str1[l1+i]=str2[i];
 }
 str1[l1+l2]='\0';
 cout<<"\n The concatenated String is: ";
 puts(str1);


}




void main()
{
 clrscr();
 cout<<" Enter your choice \n \t1.Find length of string\n\t"
 "2.Compare two Strings \n\t3.Concatenate two strings\n\t4.Exit \n";
 char ch;
 cin>> ch;
 do
 {
  if(ch=='1')
   findlength();
  if(ch=='2')
   compare();
  if(ch=='3')
   concat();
  cout<< "Enter your choice \n \t1.Find length of string\n\t"
 "2.Compare two Strings \n\t3.Concatenate two strings\n\t4.Exit \n";
 cin>> ch;


 }while(ch!='4');
 getch();
}

Step by Step explanation:
1.Header file "iostream.h" is used for including the function like cin and cout.
2.Header file "stdio.h" , "conio.h" for including the function like printf and scanf.
3."Findlenth" is a function of void type and it is used to calculate the lenth of string.
4.compare is a function of void type and it is used to compare the two string.
5.while is a loop it is used to apply the condition.
6.if is also a loop and it is too used for apply the condition.
7.else is a condition check statement it is used in case of failing the if statement.
8.Break is a keyword and it is used to break the loop.
9.concat is a function of void type and it is used to join the two string:string becomes in the form of matrix.
10.Main is also a function of void type and it works during the curley brackets.

Friday, 17 February 2012

C++ program to input two integers that return the smallest one.


C++ program to input two integers that return the smallest one.


# include "iostream.h"
# include "conio.h"
int min(int a, int b)
{
 if (a< b )
  return(a);
 else
  return(b);
}
char min(char a, char b)
{
 if (a< b )
  return(a);
 else
  return(b);
}
double min(double a, double b)
{
 if (a< b )
  return(a);
 else
  return(b);
}
void main()
{
 int n, n1;
 char ch, ch1;
 double d, d1;
 clrscr();
 cout << "Enter two integers ";
 cin >> n >> n1;
 cout << "Enter two characters ";
 cin >> ch >> ch1;
 cout << "Enter two double precision quantity ";
 cin >> d >> d1;
 cout << "\nMinimum of two integer "<< min(n,n1);
 cout << "\nMinimum of two characters "<< min(ch,ch1);
 cout << "\nMinimum of two double precision quantity "<< min(d,d1);
}

step by step explaination:
1.Header file "iostream.h" is used to defyning the function cin and cout.
2.Header file "conio.h" is used to defying the printf and scanf function.
3.If is a "conditional statement" that is used to apply the condition.
4.else is also a "conditional statement" it is used in case of failing the if statement.
5.main is also a void type function and it is worked untill the curley brackets.

Thursday, 16 February 2012

C++ program to find the area of rectangle, area of circle and area of triangle


C++ program to find the area of rectangle, area of circle and area of triangle
#include "iostream.h"
#include "conio.h"
#include "iomanip.h"


float area(float a, float b , float c);
float area(float l, float w);
float  area(float  r);
void main()
{
 char ch;
 float len, wid, n1, n2, n3, ar;
 float  radius;
 int choice1;
 clrscr();
 cout << "\n1. For area of triangle ";
 cout << "\n2. For area of rectangle ";
 cout << "\n3.  For area of circle ";
 cin >> choice1;
 if (choice1 == 1)
 {
  cout << "\nEnter the three sides of triangle : ";
  cin >> n1 >> n2 >> n3;
  ar = area(n1, n2, n3);
  cout << "\nArea of triangle is: " << ar;
 }
 if (choice1 == 2)
 {
  cout << "\nEnter the length ";
  cin >> len;
  cout << "\nEnter the width: ";
  cin >> wid;
  cout << "\nArea of rectangle is: " << area(len, wid);
 }
 if (choice1 == 3)
 {
  cout << "\nEnter the radius ";
  cin >> radius;
  cout << "\n Area of circle " << area(radius);
 }
}

step by step explanaition:

  • "iostream.h" is input output stream header file is used to including the function like cin and cout.
  • "conio.h" is console input output header file is used for including the function like 'getch()', 'clrscr()'.
  • function overloading is used on the function 'float area'. All float variable is used in 'float area' function like a,b,c,l,w,r have float value.
  • void main() is a main function in which whole body of program is defined.
  • 'char' is data type which is used to define character variable, here 'ch' is a character variable.
  • 'float' is a data type which is used to define float variable, here len(length), wid(width), n1, n2, n3, ar(area) are the float variable.
  • radius is a float variable.
  • 'int' is data type which is used to dafine integer variable, hera 'choice1' has the integer type value.
  • clrscr() is a library function of  "conio.h".
  • 'cout' function is used to show the value and  symbol '<<' is used with 'cout' function. 
  • 'cin' function is used to take input, here if 'choice1' take input like (1,2,3).
  • 'if' is to define the condition like 'choice1=1' then area of triangle will be calculated.
  • 'cout' is used to print the three side of triangle.
  • 'cin' is used to scan the value n1, n2, n3.
  • Now function is calling area(n1, n2, n3) is stored in 'ar'. 
  • print the content of ar.
  • 'choice1=2' condition define the area of rectangle.
  • enter the value of length.
  • The value of len(length) will be scan.
  • Enter the value of width.
  • The value of width will be scan.
  • The area of rectangle will be print.
  • 'choice==3' is used for calculate of area of circle.
  • enter the radius. 
  • Scan the value of radius.
  • Print the area of circle.

 To know more about programming in C and C++, just visit our step by step tutorial of this site. They will be surely helpful to you.

Wednesday, 15 February 2012

C++ program in file handling for counting lines in a file starting with 'A'

C++ program in file handling for counting lines in a file starting with 'A'

#include <fstream.h>
#include <conio.h>
#include <ctype.h>
void countLine()
{
char Aline[80];
int Count  = 0;
ifstream File("LINES.TXT");
while (File.getline(Aline, 80, '\n'))
if (Aline[0] == 'A')
Count++;
File.close();
cout << "No. of lines started with A : " << Count << endl;
}
void main( )
{
clrscr();
countLine();
}

step by step explanation:

1.the header file"conio.h"is used to include the function like getch and clrscr.
2.void countLine is also a void type function.
3.void main is also a void type function it is worked under the curley brackets.

C++ program from file handling. Copy text from one file and put it into other by making text of other file in upper case

C++ program from file handling. Copy text from one file and put it into other by making text of other file in upper case

// The program is :
#include <fstream.h>
#include <conio.h>
#include <process.h>
#include <ctype.h>
void main()
{
char in_char; // Input character
fstream in_obj, out_obj1;
in_obj.open("Report.TXT", ios::in); // Opens file for read mode
out_obj1.open("Finerep.txt", ios::out); // Opens file for write mode
if (!in_obj)
{
cerr << "\n\n*** That file does not exist ***\n";
exit(0); // Exit program
}
cout << "\nCopying ... \n";
in_obj.get(in_char);
in_char = toupper(in_char);
out_obj1.put(in_char);
while (in_obj.get(in_char))
{
if (in_char == '.')
{
out_obj1.put(in_char);
in_obj.get(in_char);
in_char = toupper(in_char);
out_obj1.put(in_char);
}
else
out_obj1.put(in_char);
}
in_obj.close();
out_obj1.close();
}

Step by step explanation:

1.the header file"conio.h"is used to include the function like getch and clrscr.
2.void main is also a void type function it is worked under the curley brackets.
3.while and if is a conditional statement it is used to check the condition.
4.else is also a conditional statement it is used when the while and if condition fails.

C++ program in text files to read and copy only vowel words from one file and put it in to other

C++ program in text files to read and copy only vowel words from one file and put it in to other

#include <fstream.h>
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
void vowelwords()
{
fstream afile,bfile;
char ch,ch1;
afile.open("TEXT1.TXT", ios::in);
bfile.open("TEXT2.TXT", ios::out);
ch1 = ' ';
clrscr();
while(afile)
{
afile.get(ch);
cout << "\nOutside " << ch;
if (( ch =='A') || (ch =='E') || (ch=='I')||(ch=='O')||(ch=='U')&&(ch1==' '))
{
while(ch != ' ')
{
afile.get(ch);
ch1 = ch;
if(ch == ' ')
break;
}
}
else
bfile.put(ch);
}
afile.close();
bfile.close();
}
void main()
{
clrscr();
vowelwords();
}

Step by step explanation:

1.the header file "iostream.h" is used to include the function cin and cout.
2.the header file"conio.h"is used to include the function like getch and clrscr.
3.void vowelwords is also a void type function.
4.while is a conditional statement it is used to check the condition.
5.void main is also a void type function it is worked under the curley brackets.

Function to count and display the number of blank spaces present in a text file

Function to count and display the number of blank spaces present in a text file

#include <fstream.h>
#include <iostream.h>
#include <ctype.h>
#include <conio.h>
void display()
{
ifstream afile;
/* If NOTES.txt contains the following line :
C++ File handing in Class-12 */
afile.open("NOTES.TXT");
char ch;
int c = 0;
while(afile)
{
afile.get(ch);
if (ch == ' ' )
c++;
}
cout << "The number of blank spaces : " << c;
}
void main()
{
clrscr();
display();
}

step by step explanation:

1.the header file "iostream.h" is used to include the function cin and cout.
2.the header file"conio.h"is used to include the function like getch and clrscr.
3.void display is also a void type function .
4.void main is also a void type function it is worked under the curley brackets.

C++ program using Function to count and display the number of alphabets present in a text file

Function to count and display the number of alphabets present in a text file

#include <iostream.h>
#include <fstream.h>
#include <ctype.h>
#include <conio.h>
void display()
{
ifstream afile;
afile.open("STORY.TXT");
char ch;
int c=0;
while(afile)
{
afile.get(ch);
if (isalpha(ch))
c++;
}
cout << "The number of alphabets are " << c;
}
void main()
{
clrscr();
display();
}

step by step explanation:

1.the header file "iostream.h" is used to include the function cin and cout.
2.the header file"conio.h"is used to include the function like getch and clrscr.
3.void display is also a void type function.
4.void main is also a void type function it is worked under the curley brackets.

C++ program to convert the lowercase letter into uppercase and to increment an integer

Program to convert the lowercase letter into uppercase and to increment an integer

# include <iostream.h>
# include <conio.h>
char convert(char ch)
{
return(ch -32);
}
int increment(int n)
{
return(++n);
}
void main()
{
int num;
char ch1;
clrscr();
cout<< "Enter a character in lower case ";
cin >> ch1;
cout << "Enter an integer ";
cin >> num;
cout<< "\nUpper Case Aplhabet is => " <<convert(ch1);
cout<< "\nIncremented Integer is => " <<increment(num);
}

step by step explanation:

1.the header file "iostream.h" is used to include the function cin and cout.
2.the header file"conio.h"is used to include the function like getch and clrscr.
3.the char convert is also a function of char type.
4.void main is also a void type function it is worked under the curley brackets.