Skip to main content

Posts

Showing posts with the label c program

C++ Program to count the number of characters entered

In C++ Program you can write a code to count the characters of the word entered. Let's look at the coding. C++ Program to count the number of characters entered #include <iostream.h> #include <conio.h> int main () { int chcount =  0 ; const char ent = '\n' ; char ch ; std::cout << "Enter character\n" ;  std::cin.get(ch) ; while (ch!=ent) { chcount++ ; std::cout.put(ch) ; std::cin.get(ch) ; } std::cout <<"\n The number of characters = " <<chcount <<"\n" ; return 0 ;  } The output of the C++ Program Code C++ Program to count the number of characters entered

C ++ Program to read radius of a circle to calculate area and perimeter to display them

In C++ Program you can easily write a code to read the radius of a circle to calculate the area of the circle and the perimeter of the circle. Let's have a look at the C ++ Program to read radius of a circle to calculate area and perimeter to display them  #include <iostream.h> #include <stdlib.h> int main () { system ("cls") double radius, area, perimeter ; cout<<"Enter Radius of the circle : "; cin>>radius ; perimeter = 2 * 3.14159 * radius ; area = 3.14159 * radius * radius ; cout <<"The area of the circle is" ; cout<< area ; cout<<"\n The perimeter of the circle is : " ; cout<< perimeter ; return 0 ; } Out Put of the Above C++ Code  C++ Code for Circle area and Perimeter Output