Thursday, 21 February 2013

Swapping without third variable

| |
0 comments
#include<iostream>using namespace std;int main(){int a,b;cout<<"Enter the two numbers ";cin>>a>>b;a=a+b;b=a-b;a=a-b;cout<<"Now a="<<a<<endl<<"Now b="<<b;system ("pause");return 0;}&nbs...
Read More

Compute the sum of Cos(X) Series

| |
0 comments
#include<iostream.h>#include<conio.h>#include<math.h>int main(){ float x,t,sum;int i,n=20;cout<<"Input X : \n";cin>>x;x=x*3.1412/180;t=t+1;sum=1;for(i=1;i<=n;++i){ t=t*pow((double)(-1),(double)(2*i-1))*x*x/(2*i*(2*i-1));sum +=t;}cout<<"cos(X) ="<<sum<<"\n";system ("pause");return 0;}&...
Read More

WAP to print Pascals Triangle

| |
0 comments
#include<iostream>#include<math.h>using namespace std;int main(){    int i,j,k,l,n,m;    cout<<"Enter the number of rows :""\n";    cin>>n;        for(i=0;i<n;i++)    {                   ...
Read More
Related Posts Plugin for WordPress, Blogger...
Powered by Blogger.