A vector is given by V 5 17 3 8 0 7 12 15 20 6 6 4 2 16 Wri

A vector is given by V = [5, 17, -3, 8, 0, -7, 12, 15, 20, -6, 6, 4, -2, 16]. Write a program that doubles the elements that are positive and are divisible by 3 or 5, and, raises to power of 3 the elements that are negative but greater than -5.

Solution

#include <stdio.in>

#include<math.h>

#include<conio.h>

main()

{

int n,ps,ns,I;

int a[50];

clrscr();

printf(“Enter no. of elements”);

scanf(“%d” &n);

for(i=0;i<n;i++)

{

  scanf(“d”,&a[i];

}

for(i<0;i<n;i<i++)

{

  If(a[i]>0)

  {

   If(a[i]%3==0|| a[i]%5==0)

{

    ps = a[i]*2;

   printf(“%d”ps);

   }

  }

  else

  {

   If (a[i]>-5)

   {

    ns = pow(a[i],3)

    printf(“%d”,ns);

   }

  }

}

getch();

}

This program has to be typed on turbo c.

& run & enter the vector v=(numbers);

 A vector is given by V = [5, 17, -3, 8, 0, -7, 12, 15, 20, -6, 6, 4, -2, 16]. Write a program that doubles the elements that are positive and are divisible by
 A vector is given by V = [5, 17, -3, 8, 0, -7, 12, 15, 20, -6, 6, 4, -2, 16]. Write a program that doubles the elements that are positive and are divisible by

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site