Enable contrast version

Tutor profile: Naina T.

Inactive
Naina T.
Tutor for 12 years. Software Engineer 2 at Microsoft
Tutor Satisfaction Guarantee

Questions

Subject: Java Programming

TutorMe
Question:

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

Inactive
Naina T.
Answer:

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] = 0; series[1] = 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
Naina T.
Answer:

#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 in C to accept two integers from a user, print the larger one and also print out their sum.

Inactive
Naina T.
Answer:

#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 Naina will reply soon.
Contact Naina

Request lesson

Ready now? Request a lesson.
Start Lesson

FAQs

What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Lesson" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.
BEST IN CLASS SINCE 2015
TutorMe homepage
Made in California by Zovio
© 2020 TutorMe, LLC
High Contrast Mode
On
Off