Sunday 7 March 2010

Write a C program to find a sum of series:S=1+x/1!+x2/2!+........…


Write a C program to find a sum of series:S=1+x/1!+x2/2!+........…
#include <stdio.h>
#include <math.h>

int factorial(int n)
{
if(n==1)
return 1;
else
return (n * factorial(n-1));
}

int main()
{
int x,i;
double S=1;

printf("Please input x : ");
scanf("%d", &x); fflush(stdin);

for(i=1; i<=x; i++)
{
S += pow(x,i)/ factorial(i);
}
printf("%lf", S);
getchar();
return 0;
}

cpp Programs




If else

C++ Program To Determine Whether The Seller Made Profit or Loss. Also Determine How Much Profit or Loss He Made




Companies Conducted problems:


A Milkman serves milk in packaged bottles of varied sizes. The possible size of the bottles are {1, 5, 7 and 10} litres. He wants to supply desired quantity using as less bottles as possible irrespective of the size. Your objective is to help him find the minimum number of bottles required to supply the given demand of milk.
 

wap to evaluate the following expression 1-(x/1!) + (x2/2!) - (x3/3!) + … +/- (xn/n!)


1. Write a C++ program to evaluate the following expression: 1-(x/1!) + (x2/2!) - (x3/3!) + … +/- (xn/n!) given values for x and n. These values need to be properly declared and input from the keyboard. Properly document/comment the program. Show output after execution for different values of x and n (at least 5 pairs of values).
#include<iostream.h>
#include<cmath.h>

int fact(int n)
{
if(n==0) return 1;
else return n*fact(n-1);

}
void main()
{
int x,n;
double sum=1;
clrscr();
cout << " enter values of x and n";
cin >> x >> n;
for(int i=1; i<=n; i++)
{
if(i%2==0)
sum = sum+pow(x,i)/fact(i);
else
sum = sum-pow(x,i)/fact(i);
}
cout << " sum of series given by" << sum << endl;
getch();
}

Tuesday 2 March 2010

POLYTECHNIC DIPLOMA PREVIOUS QUESTION PAPERS WITH ANSWERS FOR CPP

POLYTECHNIC DIPLOMA PREVIOUS QUESTION PAPERS WITH ANSWERS FOR CPP

·                     OCT/NOV-2012
·                     APRIL/MAY 2012
·                     OCT/NOV-2011                   
·                     APRIL/MAY 2011 (c-09) with answers
·                     APRIL/MAY 2011(C-05)
·                      
·                     OCT/NOV-2011(C-05)
·                      
·                     APRIL/MAY-2011(C00)
·                     Oct/Nov2010
·                     OCT-2005
·                     OCTOBER   -   2005(C-00)