0% found this document useful (0 votes)
50 views12 pages

#Include #Include #Include

The document contains C++ code for multiple programs that perform calculations related to prime numbers, factorials, powers, and averages. The programs take user input, perform loops and mathematical operations, and output results to the console.

Uploaded by

Ashutosh Shaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views12 pages

#Include #Include #Include

The document contains C++ code for multiple programs that perform calculations related to prime numbers, factorials, powers, and averages. The programs take user input, perform loops and mathematical operations, and output results to the console.

Uploaded by

Ashutosh Shaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

3

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

void main()
{clrscr();
int vol,res;
float cur;

cout<<"enter the voltage\t";


cin>>vol;

cout<<"enter the value of resistence\t" ;


cin>>res;
cur=vol/res;
cout<<"The current is\t"<<cur;

getch();
}

16

#include<iostream.h>
#include<math.h>

void main()
{
int x,y,count1;
float t;
cout<<"enter any no. greater than 3"<<endl;
cin>>x;
t=x/2;
for(y=2;y<=t;y++)
{
if(x%y==0)
count1=1; }

if(count1==1)
cout<<"the no is not prime";
else
cout<<"the no.is prime";

getch ();}
17
#include<iostream.h>
#include<math.h>
void main()

{
int n,m,x,y,z,count1=0,a=0,b=0;
float t;
cout<<"enter any two no. greater than 3"<<endl;
cin>>m>>n;
while(m<=n)
{
t=sqrt(m);
count1=0;
for(y=2;y<=t;y++)
{
if(m%y==0)
count1=1;
}
if(count1!=1)
cout<<"the prime no is "<<m<<"\n";}
m++;
}
getch();}
18
#include<iostream.h>
#include<math.h>

void main()
{
int n,m,x,y,z,count1=0,a=0,b=0;

float t;
cout<<"enter any two no. greater than 3"<<endl;
cin>>m>>n;
while(m<=n)
{
t=m/2;
count1=0;
for(y=2;y<=t;y++)
{
if(m%y==0)
count1=1;
}

if(count1==1)
cout<<"the no is not prime\n";

else
{cout<<"the no.is prime\n";
a=a+1;}
m++;
}
cout<<"\n The no of prime no.is"<<a;
getch();
}

21
#include<iostream.h>
#include<math.h>
void main()
{

int x,y,n,z,sum=0;

cout<<"enter any no. and the n(th)term \n";


cin>>x>>n;
for(z=1;z<=n;z++)
{
y=pow(x,z);
sum = sum + y;
}
cout<<sum;
getch();
}

22
#include<iostream.h>
#include<math.h>
void main()
{
int x,y,n,z,sum=0;

cout<<"enter any no. and the n(th)term \n";


cin>>x>>n;
for(z=1;z<=n;z++)
{
y=pow(x,z);
sum = sum + y;

cout<<(2*x)-sum;
getch();
}

23
#include<iostream.h>
#include<math.h>

void main()
{
float a=0,x,b=0,y,n,z,sum=0;
cout<<"enter any no. and the n(th)term \n";
cin>>x>>n;
while(a<n&&b<n)
{
a++;
b++;
y=(pow(x,a))/b;
sum = sum + y;
}
cout<<sum+1;
getch();

24
#include<iostream.h>
#include<math.h>

void main()
{
float a=0,x,b=0,i,y,n,z,sum=0,f;
cout<<"enter any no. and the n(th)term \n";
cin>>x>>n;
while(a<n&&b<n)
{
a++;
b++;
f=1;
for(i=1;i<=b;i++)
{ f=f*i;
}
y=(pow(x,a))/f;
cout<<y<<" ";
sum = sum + y;
}
cout<<"="<<sum+1;
getch;

}
26
#include<iostream>
#include<math.h>
void main()
{
float b=0,i,y,n,z,sum=0,f;
int x,a=0;
cout<<"enter any no. and the n(th)term \n";
cin>>x>>n;
{
while(a<2*n&&b<2*n)
{
a++;
b++;
if(a%2!=0)
{
f=1;
for(i=1;i<=b;i++)
{ f=f*i;
}
y=(pow(x,a))/f;
sum = sum + y;
}}
cout<<"="<<sum+1-x;
getch();

}}

13
#include<iostream.h>
void main()
{
int i,x,n,m;
cout<<"enter a no. and how many multiples\n";

cin>>n>>m;
for(i=1;i<=m;i++)
{
x=i*n;

cout<<x<<endl;
}
getch();
}
14
#include<iostream.h>
void main()
{
int a,sum=0,i;
float avg;
cout<<"enter a no.";
for(i=1;i<=10;i++)
{

cin>>a;
sum=sum+a;
}
avg=sum/10;
cout<<"sum is"<<sum;
cout<<"average is"<<avg;
getch();

You might also like