Computer Science, asked by prabhav128, 7 months ago

Write an algorithm to calculate the total
number of advertisements that will be
displayed from the batch.
Input
The input consists of an integer - batch,
representing the batch of advertisements,
Output
Print an integer representing the total number
of advertisements that will be displayed by the
media company.
Constraints
0 < batch <= 10^9

Answers

Answered by saranganantkakirwar
0

Answer:

gssgyj

advxshuoknbvdsxvvbhyrsdfvvddvvddhjj

Answered by aditijaink283
0

Answer:

The algorithm is as follows :

Explanation:

# include<stdio.h>

#include<stdlib.h>

/*

Constraints  0 < batchs 109?

*/

#define MIN 0

#define MAX 109

main()

{

int Batch_of_Advertisements=-1;

int a, b, c;

int No_of_Advt=0;

while(Batch_of_Advertisements<MIN || Batch_of_Advertisements>MAX)

{

 printf("\n\tEnter the Batch of Advertisements (%d to %d): ",MIN,MAX);

 scanf("%d",&Batch_of_Advertisements);

}

if(Batch_of_Advertisements <10 && Batch_of_Advertisements%2==0)

{

 No_of_Advt=Batch_of_Advertisements;

}

if(Batch_of_Advertisements >9 && Batch_of_Advertisements<100)

{

 a = Batch_of_Advertisements/10;

 b = Batch_of_Advertisements%10;

 if(a%2==0) No_of_Advt = No_of_Advt + a;

 if(b%2==0) No_of_Advt = No_of_Advt + b;

}

if(Batch_of_Advertisements >99)

{

 a = Batch_of_Advertisements/100;

 b = (Batch_of_Advertisements%100)/10;

 c = (Batch_of_Advertisements%100)%10;

 if(a%2==0) No_of_Advt = No_of_Advt + a;

 if(b%2==0) No_of_Advt = No_of_Advt + b;

 if(c%2==0) No_of_Advt = No_of_Advt + c;

}

printf("\n\tNo. of advertisements = %d",No_of_Advt);

}

#SPJ3

Similar questions