Showing posts with label c-plus plus program. Show all posts
Showing posts with label c-plus plus program. Show all posts

Thursday 28 June 2012

c++ program that display following pattern.


for n=5
pattern:
*
* ?
* ? *
* ? * ?
* ? * ? *


#include <iostream>
using namespace std;

int main()
{
int i,j,k;
//input from user
cout<<"Enter a number ";
cin>>k;

for(i=1;i<=k;i++)
{
for(j=1;j<=i;j++)
{

c++ program that calculate the sum of : 1 1 4 8 9 27…….n terms.

#include<iostream.h>

int main()
{
int i,n;

cout<<"Enter nay number :";
    cin>>n;
for(i=1;i<=n;i++)
 

c++ program that calculate the sum of : x-x2/2!+x3/3!-x4/4!+…………….n terms

#include<iostream.h>

int main()
{
int i,n,j,fa=1,sq=1;
float ans=0.0,sum=0.0;

cout<<"Enter any number : ";
    cin>>n;
for(i=1;i<=n;i++)
{

c++ program that calculate the sum of : 1!/1+2!/4+3!/9……..n terms.

#include<iostream.h>

int main()
{
int i,n,j,fa=1,sq;
float ans=0.0,sum=0.0;

cout<<"Enter any number : ";
    cin>>n;
for(i=1;i<=n;i++)
{
 

c++ program that calculate the sum of : 1/2-2/3+3/4-4/5+…..n terms.

#include<iostream.h>
#include<conio.h>
int main()
{
int n;
float sum=0.0,i,j;
clrscr();
cout<<"Enter any number : ";
    cin>>n;

c++ program that calculate the sum of following series:

11+22+33+44….n terms

#include<iostream.h>

int main()
{
int i,n,j,sum=0,squ=0;

cout<<"Enter any number : ";
    cin>>n;

c++ program that check whether enter number is prime or not

    #include<iostream.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int n,m;
    cout<<"Please enter a number: ";
    cin>>n;
    for (int i=2;i<=(n-1);i++)
    {
    if(n%i==0)

c++ program that check whether enter number is palindrome or not

#include<iostream.h>
#include<conio.h>
int main()
{
int rem,nu,n,rev=0;
clrscr();
cout<<"Enter any number : ";

Wednesday 27 June 2012

c++ program that take number of days and print year,month and remaining days.

#include<iostream>
using namespace std;

int main( )
{
int y,d,m,i;

//user input
cout<<"Enter the number of days ";
cin>>i;
cout<<endl;

c++ program that convert Rupees(float) to paisa(int).


#include<iostream>
using namespace std;

int main( )
{
int p;
float r;

cout<<"Enter rupees= ";
cin>>r;
cout<<endl;

c++ program that swap the value of two number without using other variable.


#include<iostream>
using namesapace std;
int main()
{
int a,b;
cout<<"Enter the first number A:- \n";
cin>>a;
cout<<"Enter the second  number B:- \n";
cin>>b;

c++ program that take input one number and display it in reverse and also calculate sum of series.


#include <iostream>
using namespace std;

int main()
{
int a;
int num;
int sum = 0;
cout<<"Enter the no:";
cin>>a;
num=a;
cout<<"Reverse number is:- ";
while(a!=0)
{
cout<<a%10;
a=a/10;
}

c++ program to find whether the number is odd or even.



#include <iostream>
using namespace std;
int main ()
{   
int i;
   
// Prompt user for i and obtain integer.

  cout << "Please enter an integer"<< endl;
  cin >> i;

c++ program that multiply two given numbers without using * or / operator.


#include<iostream>
using namespace std;

int main()
{
int a,b,i,temp=0;

//taking input form user
cout<<"Enter First number for multiplication:  ";
cin>>a;

c++ program to calculate the sum of series.


#include <iostream>
using namespace std;

int main()
{
int a,i,j,temp;
int sum;
cout<<"Enter the no:";
cin>>a;
sum=0;

c++ program to generate series : 2 3 5 7 10 14 ….n terms.


#include <iostream>
using namespace std;
int main()
{
int a,i;
int num;
cout<<"Enter the no:";
cin>>a;
num=1;

c++ program to generate series : 0 1 3 6 10 ….n terms.

#include <iostream>
using namespace std;
int main()
{
int a,i,j;
int num;
cout<<"Enter the no:";
cin>>a;
num=0;
j=1;

c++ program that display the patterns.

for n=4
pattern ::
abcd
abc
ab
a

#include<iostream.h>
#include<stdio.h>

int main()
{
int i,j,k;
char x;

c++ program to find largest number among three numbers.

#include<iostream>
using namespace std;
int main()
{
int a,b,c;
//taking input form user
cout<<"Enter the First number A:";
cin>>a;
cout<<endl;
cout<<"Enter the Second number B:";
cin>>b;
cout<<endl;
cout<<"Enter the Third number C:";
cin>>c;
cout<<endl;

c++ program to implement non-preemitive Shortest job first (SJF) scheduling algorithm using function

#include <iostream>
#include<fstream>
using namespace std;
void writeFile(char fname[],int n)
{
    fstream fwrite;
    fwrite.open(fname,ios::out);
    float a,b,p;
    for(int  i=0;i<n;i++)
    {
       
        cout<<"enter arival time :";
        cin>>a;
        cout<<endl<<"enter brust time:";