LIVE Course for free

Rated by 1 million+ students
Get app now
0 votes
285 views
in Control Statements by (31.4k points)
closed by

1. Write a C++ program to display all leap years between 1000 and 2000 excluding all century years.

OR

2. Write a C++ program to find the sum of the first 10 numbers of Fibonacci series. (Fibonacci series is 0, 1, 1,2, 3, 5, 8, 15 where 0 and 1 are the first two terms and reamaining terms are obtained by the sum of the two preceding terms.)

1 Answer

+1 vote
by (31.3k points)
selected by
 
Best answer

1. 

# include<iostream>

using namespace std;

int main ()

{

int i;

cout<<"Leap years between 1000 and 2000 is given below \n";

for (i=1000,i<=2000;i++)

{

if (i % 100 = = 0)

{

if (i % 400 = = 0)

cout<<i<<",";

}

else if  (i % 4 = = 0)

cout<<i<<",";

}

}

OR

2.

# include<iostream>

using namespace std;

void main ()

{

int i, fib1=0, fib2=1, fib3, S;

S = fib1 + fib2;

for(i=1, i <=8;i++)

{

fib3 =fib1 + fib2;

S = S + fib3;

fib1=fib2;

fib2 =fib3;

}

cout<<"The sum of first 10 numbers of Fibonacii series is "<<s;

}

Related questions

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

...