Enable contrast version

# Tutor profile: Akash S.

Inactive
Akash S.
Tutor for 5 years. Developer at Microsoft, Math Enthusiast
Tutor Satisfaction Guarantee

## Questions

### Subject:Java Programming

TutorMe
Question:

Write a program to print first 20 elements of a Fibonacci series.

Inactive
Akash S.

public class FibonacciSeries { public static void main(String[] args) { //number of elements to generate in a series int limit = 20; long[] series = new long[limit]; //create first 2 series elements series = 0; series = 1; //create the Fibonacci series and store it in an array for(int i=2; i < limit; i++){ series[i] = series[i-1] + series[i-2]; } //print the Fibonacci series numbers System.out.println("Fibonacci Series upto " + limit); for(int i=0; i< limit; i++){ System.out.print(series[i] + " "); } } }

### Subject:C++ Programming

TutorMe
Question:

For a given value of number of rows, print out a pascal's triangle.

Inactive
Akash S.

#include<iostream> //include header library using namespace std; int main() { int rows; cout << "Enter the number of rows : "; //ask user to input no. of rows cin >> rows; //store them in variable 'rows' cout << endl; // new line for (int i = 0; i < rows; i++) //run a 'for' loop equal to value of row { int val = 1; for (int j = 1; j < (rows - i); j++) { cout << " "; //print out the blanks for the left side of triangle } for (int k = 0; k <= i; k++) { cout << " " << val; val = val * (i - k) / (k + 1); //print the values for each row of pascal triangle } cout << endl << endl; } cout << endl; return 0; }

### Subject:C Programming

TutorMe
Question:

Write a program to accept two integers from a user, print the larger one and also print out their sum.

Inactive
Akash S.

# include <stdio.h> //Including the std. input output library void main(){ int x, y, sum, greaterElement ; sum = 0 ; printf( " Input the two integers : " ) ; //asking user to input integers printf( " \n " ) ; //new line scanf( "%d %d", &x, &y ) ; // scanning the inputs and storing them in x and y sum = x + y ; printf( " The Sum of the elements is: %d", sum ) ; //printing out sum printf( " \n " ) ; //new line if ( x >= y ) //if conditional statement { greaterElement = x ; } else { greaterElement = y ; } printf( " The greater of the two elements is: %d", greaterElement ) ; //print greater element }

## Contact tutor

Send a message explaining your
needs and Akash will reply soon.
Contact Akash