0% found this document useful (0 votes)
26 views4 pages

Fibonacci Series

fibonacci series
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views4 pages

Fibonacci Series

fibonacci series
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Fibonacci series

#include<iostream.h>

#include<conio.h>

void main() {

clrscr();

int n, first = 0, second = 1, next;

// Prompting the user for the number of terms

cout << "Enter the number of terms in the Fibonacci series: ";

cin >> n;

cout << "Fibonacci Series: ";

// Displaying the first two terms (0 and 1)

cout << first << " " << second << " ";

// Generating the Fibonacci series

for (int i = 3; i <= n; i++) {

next = first + second;

cout << next << " ";

first = second;

second = next;

getch();

}
Program to Count Vowels in a String
#include <iostream>

#include <cstring>

using namespace std;

int main() {

char str[100];

int count = 0;

cout << "Enter a string: ";

cin.getline(str, 100);

for (int i = 0; i < strlen(str); i++) {

if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u' ||

str[i] == 'A' || str[i] == 'E' || str[i] == 'I' || str[i] == 'O' || str[i] == 'U') {

count++;

cout << "Number of vowels = " << count << endl;

return 0;

Program to Find the Length of a String


#include <iostream>

#include <cstring>

using namespace std;

int main() {

char str[100];

cout << "Enter a string: ";

cin.getline(str, 100);
cout << "Length of the string = " << strlen(str) << endl;

return 0;

Program to Print Multiplication Table


#include <iostream>

using namespace std;

int main() {

int num;

cout << "Enter a number: ";

cin >> num;

for (int i = 1; i <= 10; i++) {

cout << num << " * " << i << " = " << num * i << endl;

return 0;

Program to Reverse a Number


#include <iostream>
using namespace std;

int main() {
int num, reverse = 0, remainder;
cout << "Enter a number: ";
cin >> num;
while (num != 0) {
remainder = num % 10;
reverse = reverse * 10 + remainder;
num /= 10;
}
cout << "Reversed number = " << reverse << endl;
return 0;
}

You might also like