Create a new C++ program named “partA_q1.cpp”
Write a program in C++ to calculate and display the kinetic energy (J) of a 2.4 kg mass when the user provides its velocity (km/h). Use the following equation:
1 𝑘𝑖𝑛𝑒𝑡𝑖𝑐𝑒𝑛𝑒𝑟𝑔𝑦 =2×𝑚𝑎𝑠𝑠 ×(
Question 2
Create a new C++ program named “partA_q2.cpp”
𝑣𝑒𝑙𝑜𝑐𝑖𝑡𝑦 × 1000 2 60×60 )
Write a program in C++ that will let the user know whether a number that they enter is a multiple of eleven. Hint: If there is no remainder after dividing a number by eleven, that number is a multiple of eleven.
Question 3 [7 marks]
Create a new C++ program named “partA_q3.cpp”
Write another program that performs the same task as Question 2, but this program should allow the user to test another number, if they wish to do so.
(Hint: Modify your code from Question 2.)
Question 4 [15 marks] Create a new C++ program named “partA_q4.cpp”
Write a C++ program that uses a for() loop to calculate and display the sum of the following series, for a given the number of terms (n). n is to be provided by the user and must be greater than four.
𝑠𝑢𝑚𝑜𝑓𝑠𝑒𝑟𝑖𝑒𝑠= 1 + 1 + 1 +⋯+ 1
sin (1) sin (2) sin (3) sin (n) ππππ
[8 marks]
1.
#include <iostream>
using namespace std;
int main()
{
double energy, velocity, mass=2.5;
cout<<"mass of the object is: \n"<<mass<<endl;
cout<<"\nPlease enter the value of velocity in km/hour "<<endl;
cin>>velocity;
cout<<"\nThe velocity of the object is:"<<velocity<<"km/hour"<<endl;
velocity=velocity*5/18;
cout<<"\n velocity of the object in meter/sec "<<velocity<<"m/s"<<endl;
energy =mass*velocity*velocity/2;
cout<<"\n The kinetic energy of the particle will be: "<<energy<<endl;
return 0;
}
2.
#include <iostream>
using namespace std;
int main(){
int a;
cout<<"Please enter the number"<<endl;
cin>>a;
cout<<"The entered number is : "<<a<<endl;
if(a<11){
cout<<"The entered number is less than 11, so please enter the number which is greater than 11"<<endl;
}else{
if((a%11)==1)
{
cout<<"The entered number is not divisible by 11"<<endl;
}else{
cout<<"The entered number is divisible by 11"<<endl;
}
}
return 0;
}
3.#include<iostream>
using namespace std;
int main()
{
string a;
int n;
cout<<"Please enter the number:"<<endl;
cin>>a;
cout<<"\n The entered number is:"<<a<<endl;
n=a.length();
if(((a[n-1]-'0') == 0) || ((a[n-1]-'0') == 5))
{
cout<<"\n entered number is divisible by 5"<<endl;
}else
{
cout<<"\n entered number is not divisible by 5"<<endl;
}
return 0;
}
4.#include<iostream>
#include<math.h>
using namespace std;
#define pi 3.14159265;
int main()
{
int i,n;
double sum=0;
cout<<"Please enter the number of terms in the series"<<endl;
cin>>n;
for(i=1;i<=n;i++)
{
sum=sum+sin(i);
}
cout<<"The resultant sum of the series"<<sum<<endl;
return 0;
}
Comments
Leave a comment