98.3k views
5 votes
Q5) Write C++ program to find the summation of sines of the even values that can be divided by 7 between -170 and -137.

1 Answer

1 vote

Answer:

In C++:

#include <iostream>

#include <cmath>

using namespace std;

int main(){

double total = 0;

for(int i = -170; i<=-130;i++){

if(i%2 == 0 && i%7==0){

double angle = i*3.14159/180;

total+=sin(angle); } }

cout<<"Total: "<<total;

return 0; }

Step-by-step explanation:

This initializes the total to 0

double total = 0;

This iterates from -170 to - 130

for(int i = -170; i<=-130;i++){

This checks if the current number is even and is divided by 7

if(i%2 == 0 && i%7==0){

This converts the number from degrees to radians

double angle = i*3.14159/180;

This adds the sine of the number

total+=sin(angle); } }

This prints the calculated total

cout<<"Total: "<<total;

User Mostafa Soufi
by
3.7k points