24 Computer -- Programming Concepts and Logics

WAP to print the following series: 2, 2, 4, 6 up to 10th term.

WAP to print the following series: 

2, 2, 4, 6 up to 10th term.

The following is a program to print the following series:

2, 2, 4, 6 up to 10th term..

In  JAVASCRIPT

let a = [2]

const b = 9


    for (let i=2; i <= b; i+=2) {

       a.push(i)

     }

console.log(a)


#include<stdio.h>

#include<conio.h>

#include<string.h>


int main() {

    

    

  int i, nextTerm;

  int t1 = 2, t2 = 2;

  

  nextTerm = t1+t2;

 


  

  printf("%d, %d, ", t1, t2);

  

  for (i = 3; i <= 10; ++i) {

    printf("%d, ", nextTerm);

    t1 = t2;

    t2 = nextTerm;

    nextTerm = t1 + t2;

  }


    return 0;

}


More questions on Programming Concepts and Logics

Close Open App