Tuesday 24 June 2014

47)write aprogram to evaluate the square cube and 4th power of a number

#include<iostream>
#include<cmath>
using namespace std;
int main()
{   int k;
    int x2,y3,z4;
   cout<<"enter the value of k"<<endl;
   cin>>k;
   x2=k*k;
   y3=x2*k;
   z4=y3*k;
   cout<<"the square  of k is "<<x2<<endl<<"the 3rd power of k is"<<y3<<endl<<"the 4th power of k is"<<z4;
   int i;
    cin>>i;
    return 0;
}

46)write a program to evaluate the difference between bool and int data type.

#include<iostream>
using namespace std;
int main()
{   int k=10;
   int x;
   bool z;
    z=k<15;
    x=k<4;
    x=5;
   // x=5;
    //cout<<sizeof(x)<<endl<<sizeof(z)<<endl;
    cout<<"value of z"<<z<<endl<<"value of x"<<x;
    int i;
    cin>>i;
    return 0;
}

45)write a c++ program to read an angle in degrees and evaluate and display its sine and cosine.

#include<iostream>
#include<cmath>
using namespace std;
#define pi 3.14
int main()
{   float x,theta;
    float sx,cx;
    cout<<"ener the angle in degree"<<endl;
    cin>>theta;
    x=(180/pi)*theta;
    sx=sin(x);
    cx=cos(x);
    cout<<"sine of "<<theta<<"is"<<sx;
    cout<<"cosine of "<<theta<<"is"<<cx;
    int i;
    cin>>i;
    return 0;
}

Monday 23 June 2014

43)write a program to evaluate and display the volume of a cyclinder given its area and height.

#include<iostream>
using namespace std;
#define PI 3.14
int main()
{ float radius,height,volume;
  cout<<"enter radius of cylinder  "<<endl;
  cin>>radius;
  cout<<"enter height of cylinder  "<<endl;
  cin>>height;
  volume=PI*radius*radius*height;
 cout<<"the volume of cylinder is "<<volume;
}

Write a program which reads a set of integers into an integer array and then prints "YES"if all of them are same otherwise print "NO".

#include<stdio.h> int main() { int a[10],M=0,i,n; printf("enter a value for n\n"); scanf("%d",&n); fo...