Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// C++ program to print
// first n Fibonacci numbers
#include <bits/stdc++.h>
using namespace std;

// Function to print
// first n Fibonacci Numbers
void printFibonacciNumbers(int n)
{
int f1 = 0, f2 = 1, i;

if (n < 1)
return;
cout << f1 <<endl;
for (i = 1; i < n; i++) {
cout << f2 <<endl;
int next = f1 + f2;
f1 = f2;
f2 = next;
}
}

// Driver Code
int main()
{
printFibonacciNumbers(7);
return 0;
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <iostream>
using namespace std;

void halfPyramid(int n)
{
int i, j;
for(i=0; i<n; i++)
{
for(j=0; j<=i; j++)
cout<<"* ";
cout<<endl;
}
cout<<endl;
}

int main() {
int n;
cin >> n;
halfPyramid(n);
return 0;


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;
void invertedHalfPyramid(int n)
{
int i, j;
for(i=0; i<n; i++)
{
for(j=i; j<6; j++)
cout<<"* ";
cout<<endl;
}
cout<<endl;
}
int main(int argc, char **argv){
int n;
cin >> n;
invertedHalfPyramid(n);
//write your code here

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include<iostream>
using namespace std;
int main()
{
int i, j, space=10;
int n;
cin>>n;
for(i=0; i<n; i++)
{
for(j=0; j<space; j++)
cout<<" ";
space = space-2;
for(j=0; j<=i; j++)
cout<<"* ";
cout<<endl;
}
cout<<endl;
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include<iostream>

using namespace std;
int main()
{
int i, j, k;
int n;
cin>>n;
for(i=n;i>=1;i--)
{
for(j=1;j<i;j++)
{
cout<<" ";
}
for(k=n;k>=i;k--)
{
cout<<"*";
}
cout<<"\n";
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <iostream>
using namespace std;

int main()
{
int rows;

cout << "Enter number of rows: ";
cin >> rows;

for(int i = 1; i <= rows; ++i)
{
for(int j = 1; j <= i; ++j)
{
if(i==j)
cout << "* ";
else if (j<i)
cout<<" ";
}
cout << "\n";
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <iostream>

using namespace std;



bool isTriplet(int i,int j, int k)

{



int x = i * i, y = j * j, z = k * k;

if (x == y + z || y == x + z || z == x + y)

cout<< "true";
else
cout<<" false";

}




int main()

{
int a, b,c;
cin>>a>>b>>c;

isTriplet(a,b,c);

return 0;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>
using namespace std;

int main() {
int a, b, x, y, t, gcd, lcm;


cin>>x>>y;

a = x;
b = y;

while (b != 0) {
t = b;
b = a % b;
a = t;
}

gcd = a;
lcm = (x*y)/gcd;

cout<<gcd<<endl;
cout<<lcm;

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include <iostream>
#include<cmath>

#include <bits/stdc++.h>
using namespace std;


void leftRotatebyOne(int arr[], int n)
{
int temp = arr[0], i;
for (i = 0; i < n - 1; i++)
arr[i] = arr[i + 1];

arr[n-1] = temp;
}


void leftRotate(int arr[], int d, int n)
{
for (int i = 0; i < d; i++)
leftRotatebyOne(arr, n);
}


void printArray(int arr[], int n)
{
for (int i = 0; i < n; i++)
cout << arr[i] << " ";
}


void RightRotate(int a[], int n, int k)
{


k = k % n;

for(int i = 0; i < n; i++)
{
if(i < k)
{


cout << a[n + i - k] << " ";
}
else
{


cout << (a[i - k]) << " ";
}
}
cout << "\n";
}





int main()
{
int arr[8];
int n = sizeof(arr) / sizeof(arr[0]);
int k;
for(i=0;i<8;i++)
cin>>arr[i];
cin>>k;

if(k<0)
{

leftRotate(arr, 2, n);
printArray(arr, n);
}
else
{
RightRotate(Array, N, K);
printArray(arr, n);
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>
using namespace std;

int main()
{


//variable declaration
int n, n1, num = 0;


cin >> n;

n1 = n;


while (n != 0)
{
n /= 10;
num++;
}

cout << num;


return 0;
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<iostream>
using namespace std;
void print_each_digit(unsigned long long int x)
{
if(x >= 10)
print_each_digit(x / 10);

int digit = x % 10;

cout << digit << '\n';
}
int main(){
unsigned long long int i;
cin >> i;
print_each_digit(i);
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

#include <iostream>

using namespace std;

int main()
{
int num;
int a = 0;


cin >> num;
cout << "\n";

for (int i = 1; num > 0; i++) {
a = num % 10;
cout << a<<endl;
num = num / 10;
}

return 0;
}
30 changes: 30 additions & 0 deletions tempCodeRunnerFile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// C++ program to print
// first n Fibonacci numbers
#include <bits/stdc++.h>
using namespace std;

// Function to print
// first n Fibonacci Numbers
void printFibonacciNumbers(int n)
{
int f1 = 0, f2 = 1, i;

if (n < 1)
return;
cout << f1 <<endl;
for (i = 1; i < n; i++) {
cout << f2 <<endl;
int next = f1 + f2;
f1 = f2;
f2 = next;
}
}

// Driver Code
int main()
{
printFibonacciNumbers(7);
return 0;
}

// This code is contributed by rathbhupendra
Binary file added tempCodeRunnerFile.exe
Binary file not shown.