Powered By Blogger

21 February 2017

PROGRAM TO PRINT SUM OF 10 NUMBERS

INPUT=


 #include<iostream>
using namespace std;
int main()
{
int a[10],i,sum;
        sum=0;
        cout<<"Enter 10 elements";
        for(i=0;i<10;i++)
        {
              cin>>a[i];
              sum=sum+a[i];
        }
        cout<<"The sum is ="<<sum;
        return 0;
}

OUTPUT=

Enter 10 elements
0
2
3
4
5
6
7
8
9
10

The sum is = 54

PROGRAM TO FIND OUT MIN NUMBER FROM 10 NUMBERS

INPUT=


#include<iostream>
using namespace std;
int main()
{
       int i,a[20],min;
       min = a[0];
       cout<<"Enter 10 numbers =";
       for (i=0;i<10;i++)
       {
              cout<<"The min is = "<<a[i];
       }
       else
       {
              cout<<"The min is = "<<min;
       }
       return 0;
}

OUTPUT=


Enter 10 numbers =
3
12
13
19
0
16
34
22
57
2

The min is = 0

18 February 2017

PROGRAM TO READ ALPHABET & DISPLAY IT'S NEXT CHARACTER IN ASCII

INPUT=

#include<iostream>
using namespace std;
int main()
{
        char x;
        int i;
        cout<<"Enter the alphabet =";
        cin>>x;
        i=x+1;
        cout<<"The ASCII of next character is ="<<i;
        return 0;
}


OUTPUT=

Enter the alphabet = A

The ASCII of next character is = 65

PROGRAM TO CALCULATE VOLUME OF CYLINDER.

INPUT=



#include<iosteram>
using namespace std;
int main()
{
      float v,r,h;
      cout<<"Enter radius and height=";
      cin>>r>>h;
      v=(3.14)*r*r*h;
      cout<<"The volume of cylinder is="<<v;
      return 0;
}

OUTPUT=


Enter radius and height = 2    4

The volume of cylinder is = 50.24

PROGRAM TO PRINT NAME USING ARRAY

INPUT=

#include<iosteram>
using namespace std;
int main()
{
       char a[40]
       cout<<"Enter the no of alphabets =";
       cin>>n;
       cout<<"Enter your name =";
       for(i=0;i<n;i++)
       {
              cin>>a[i];
       }
       for(i=0;i<n;i++)
       {
              cout<<a[i];
       }
       return 0;
}


OUTPUT=

Enter the no of alphabets = 5
Enter your name = Harsh

Harsh

PROGRAM TO FIND MAXIMUM FROM 2 NUMBERS

INPUT=


#include<iostream>
using namespace std;
int main()
{
      int a,b;
      cout<<"enter 2 numbers"<<a;
      if(a>b)
      cout<<"max="<<a;
      else
      cout<<"max="<<b;
      return 0;
}

 OUTPUT=

Enter 2 numbers= 6 8

max= 8

15 February 2017

PROGRAM TO CONVERTTEMPERATURE FAHRENHEIT TO CELCUS...

INPUT=



#include<iostream.h>
using namespace std;
int main()
{
float fah, cel;
cout<<"Enter temperature in Fahrenheit : ";
cin>>fah;
cel=((fah-32*5) / 9);
cout<<"Temperature in Celsius = "<<cel;
return 0;
}


OUTPUT=

Enter temperature in Fahrenheit : 98.6


Temperature in Celsius =37.00000

11 February 2017

Program to swipe 2 number using 3rd number...

INPUT=

#include <iostream>
using namespace std;

int main()
{
    int a = 5, b = 10, temp;

    cout << "Before swapping." << endl;
    cout << "a = " << a << ", b = " << b << endl;

    temp = a;
    a = b;
    b = temp;

    cout << "\nAfter swapping." << endl;
    cout << "a = " << a << ", b = " << b << endl;

    return 0;
}


OUTPUT=


Before swapping.

a = 5, b = 10


After swapping.
a = 10, b = 5

program to exchange 2 variables without using 3rd variables...


INPUT=

#include<iostream>
using namespace std;

int main()
{
int a,b;
cout<<"\nEnter two numbers : ";
cin>>a>>b;
a=a+b;
b=a-b;
a=a-b;
cout<<"\nAfter swapping numbers are : ";
cout<<a<<" "<<b;


return 0;
}


OUTPUT=
Enter two numbers : 78 12
After swapping numbers are : 12 78

Program to find sum and average of 2 variables...

INPUT=

#include <iostream>
using namespace std; 

int main(){
    int x,y,sum;
    float average;

    cout << "Enter 2 integers : " << endl;
    cin>>x>>y;
    sum=x+y;
    average=sum/2;
    cout << "SUM=" << x << " and " << y << " is " << sum <<             
    "." << endl;
    cout << "AVERAGE= " << x << " and " << y << " is " <<       
    average << "." << endl;
}

OUTPUT=

  Enter 2 integers :
   5 10
   SUM=15
   AVERAGE=7.5

10 February 2017

C++ program to print "HELLO WORLD"...



INPUT->
 #include<iostream>
 using namespace std;

 int main()
 {
  cout << "Hello World";
  return 0;
 }



OUTPUT->
       Hello World