Results for Cpp Tutorials

Multiplication Table using C++ program

January 04, 2020


C++ program to print Multiplication Table

                    Hello, In this blog we see the c++ program code to print multiplication table. In this program user give the input and depends on that integer number the multiplication table will displayed.

Code:
#include<iostream.h>
#include<conio.h>
void main()
{
 int s;
 clrscr();
    cout<<"Enter the number to print the multiplication table: ";
    cin>>s;
    cout<<"\n";
 for(int i=1; i <= 10; i++)
 {
     cout<<s;
     cout<<" * ";
     cout<<i;
     cout<<" = ";
     cout<<s*i;
     cout<<"\n";
 }
getch();
}


         In the above code we use variable 's' to store the input value. And by using for loop the actual multiplication table is displayed.

Output:

Enter the number to print the multiplication table: 9
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
9 * 10 = 90

Multiplication Table using C++ program Multiplication Table using C++ program Reviewed by Amit Waghmare on January 04, 2020 Rating: 5

Cpp language code to print fibonacci series

January 02, 2020

CPP LANGUAGE CODE TO PRINT FIBONACCI SERIES


Introduction
                 

                              Fibonacci series means if we are giving input as 7 then the output is 0  1  1  2  3  5.
Means in output first digit is 0 then second is 1, addition of first and second digit is third digit i.e.0+1=1, next is 1+1=2, then 2+1=3, then 3+2=5.
                    The next digit is 5+3=8 but 8 is greater than 7(8>7) i.e.(8!<7) so the control is transfer to the
out of the loop.The actual code is as follows:

code:

#include<iostream.h>
#include<conio.h>
void main()
{
int no,a=0,b=1,c=0;
clrscr();
cout<<"Enter the number to print fibonacci series:";
cin>>no;
while(no>c)
{
cout<<c;
c=a+b;
b=a;
a=c;
}
getch();
return 0;
}
------------------------------------------------------------------------------------------------------------
Output:
           Enter the number to print fibonacci series:7
           0  1  1  2  3  5
     



Cpp language code to print fibonacci series Cpp language code to print fibonacci series Reviewed by Amit Waghmare on January 02, 2020 Rating: 5

Arithematic operators Program

December 28, 2019

Simple program for performing Arithmetic operation



First we see what does Arithmetic Operator mean?

        Arithmetic operator is a mathematical function  that takes two inputs and performs a calculation on them. They are used in common arithmetic and most computer languages contain a set of such operators that can be used within equations to perform a number of types of sequential calculation. Basic arithmetic operators include:
  • Addition (+): It displays the addition of two numbers. Eg. 4+6=10
  • Subtraction (-):It performs the subtraction of two numbers. Eg.5-2=3
  • Multiplication (×):It performs the Multiplication of two numbers. Eg.5*7=35
  • Division (÷):It performs the Division of two numbers. Eg. 6/2=3
  • Modula(%):It displays the remainders. Eg. 6%4=2
     Computers use different symbols in programming to represent multiplication (*) and division (/). More complex operators such as square root (√) also act as arithmetic operators but the basic plus, minus, multiply and divide are the fundamental operators.

C language code for addition, subtraction, multiplication, division and modulo:

#include<studio.h>
#include<condo.h>
float main ()
{
float a, b,add, sub, mul, div, rem;
closcr();
printf ("ENTER THE TWO NUMBERS TO FIND THE ADDITION ,SUBTRACTION, MULTIPLICATION, DIVISION, REMAINDER\n");
scanf ("%f%f",&a&b);
add=a+b;
sub=a-b;
mul=a×b;
div=a/b;
rem=a%b;
printf ("ADDITION=%f\n", add);
printf ("SUBTRACTION=%f\n", sub);
printf ("MULTIPLICATION=%f\n", mul);
printf ("DIVISION=%f\n", div);
printf ("REMAINDER=%f\n", rem);
getch();
return();
}
                Friends in this code we perform all operations. If we use floating points then it accepts the integers also, so better way use float points.
                In this code clrscr() is new concept.It means that the previous output is clear. Try it automatically you learn.
The following images show the actual code and output screen.

                This is the input screen I.e.coding screen.




              This Window shows that there is no error in the code.

              This is the final output screen with example.

              Friends such information I was typing on mobile so remainder operations are not possible but on the latest version it did or on the computer it did easily.
              If any query is there then write in the comment box.Thank you...
     




Arithematic operators Program Arithematic operators Program Reviewed by Amit Waghmare on December 28, 2019 Rating: 5

Consonant and Vowels

November 05, 2019




Count Consonant and Vowels

            Hello friends, here we are seeing the cpp program for the count the number of the vowel and consonant in the given string. We know a, e, i, o, u are five vowels. But how we check how many times the vowels and consonant have come in the sentence. So by using the following cpp program we easily count the number of vowels and consonant and blank spaces and also the digits in the given string.


Cpp language code for count the consonant and vowel:
#include <iostream.h>
//using namespace std;

int main()
{
    char line[150];
    int vowels, consonants, digits, spaces;

    vowels =  consonants = digits = spaces = 0;
    cout << "Enter a line of string: ";
    cin.getline(line, 150);
    for(int i = 0; line[i]!='\0'; ++i)
    {
 if(line[i]=='a' || line[i]=='e' || line[i]=='i' ||
    line[i]=='o' || line[i]=='u' || line[i]=='A' ||
    line[i]=='E' || line[i]=='I' || line[i]=='O' ||
    line[i]=='U')
 {
     ++vowels;
 }
 else if((line[i]>='a'&& line[i]<='z') || (line[i]>='A'&& line[i]<='Z'))
 {
     ++consonants;
 }
 else if(line[i]>='0' && line[i]<='9')
 {
     ++digits;
 }
 else if (line[i]==' ')
 {
     ++spaces;
 }
    }

    cout << "Vowels: " << vowels << endl;
    cout << "Consonants: " << consonants << endl;
    cout << "Digits: " << digits << endl;
    cout << "White spaces: " << spaces << endl;

    return 0;
}


Output:




Consonant and Vowels Consonant and Vowels Reviewed by Amit Waghmare on November 05, 2019 Rating: 5

Area of circle in Cpp language

November 02, 2019




Cpp program for area of circle

          Hello friends, in this blog we see the cpp program for finding the area of the circle. To find the area of the circle we must know the formula for calculating the area of circle i.e. area = pi * radius * radius
          In this formula, the value of pi is in float i.e. 3.14, so we are using float datatype. By using the following program we find the area of the circle.

C language code for Area of Circle:
#include<iostream.h>
#include<conio.h>

void main()
{
   float radius, area;/* to accept floating number*/

   cout<<"\nEnter the radius of Circle : ";
           //take input from the user

   cin>>radius;
      /* to store the floating number,
       
   area = 3.14 * radius * radius;
    // formula and answer store in area variable

   cout<<"\nArea of Circle :"<<area;  // display answer
   getch();
}
_____________________________________________________________
Output:
Enter the radius of Circle:3
Area of Circle:28.26

Enter the radius of Circle:9.54
Area of Circle: 285.776424





Area of circle in Cpp language Area of circle in Cpp language Reviewed by Amit Waghmare on November 02, 2019 Rating: 5

Volume of cylinder in Cpp language

November 02, 2019

C program for volume of Cylinder

          Hello friends, in this blog we see the cpp program for finding the Volume of cylinder. To find the volume of a cylinder we must know the formula for calculating the area of cylinder i.e. vol = pie * r * r * h.
In this formula the value of is in float i.e. 3.14, so we are using float datatype. By using the following program, we find the area of the cylinder.

C language code for Volume of cylinder:
#include<iostream.h>
#include<conio.h>

void main()
{
    float vol,pie=3.14;

    float r,h;

    clrscr();

    cout<<"ENTER THE VALUE OF RADIUS:";

    cin>>r;

    cout>>"ENTER THE VALUE OF HEIGHT:";

    cin>>h;

    vol = pie * r * r * h;

    cin>>"VOLUME OF CYLINDER IS : "<<vol;

    getch();

}
Output:­
ENTER THE VALUE OF RADIUS: 7
ENTER THE VALUE OF HEIGHT :3
VOLUME OF CYLINDER IS: 461.58

ENTER THE VALUE OF RADIUS: 4.6
ENTER THE VALUE OF HEIGHT: 6.8
VOLUME OF CYLINDER IS: 451.80832




Volume of cylinder in Cpp language Volume of cylinder in Cpp language Reviewed by Amit Waghmare on November 02, 2019 Rating: 5