C++ Program to Count Number of Characters Words and Lines in a File

C++ Program to count number of characters words and lines in a file. By using this program we can find the number of letters in the letter or character entered by the user in output. It will help for the note writers and some other educanist.

#include <iostream>
using namespace std;
int main()
{
char str[100];
int i,value;
value=0;
cout<<"Enter the letter or characters\n";
cin>> str;
for(i=0; str[i] != '\0'; i++)
{
if(str[i]!=' ')
{
value++;
}
}
cout<<"The total characters are present in the program "<<value;
return 0;
}

 

Output:

Enter the letter or characters
inlarn.com
The total characters are present in the program 10

Post Increment in C++ Program

Post-increment operator: A post-increment operator is used to increase the value of a variable after the expression has been fully executed. Value is first utilized in an expression and then increased in the Post-Increment.

For Loop in C++ Program

A loop is used to continually execute a set of statements until a certain condition is met. When showing numbers from 1 to 100, for example, you might wish to set the value of a variable to 1 and display it 100 times, raising its value by 1 with each loop iteration.

Operator in C++

Increment operators are used to increase the value by one, whereas decrement operates in the opposite direction of increment. Pre-increment I The value is incremented by one before being assigned to the variable. Post-increment (i++) The value is increased after it has been assigned to the variable.

If Else Statement in C++

The if/else statement executes a block of code if a certain condition is met. If the condition is not satisfied, a different piece of code can be executed. In JavaScript, the if/else statement is a sort of “Conditional” Statement that is used to do various actions based on different scenarios.