Questions: 1 978

Answers by our Experts: 1 850

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

C program to check whether a number can be expressed as sum of two prime number using function

Complete the function ‘find_path_dfs()’ which finds cost of going from the source vertex (src) to destination vertex (dst) using Depth First Search (DFS) algorithm. Use stack for implementing DFS algorithm.


void find_path_dfs(int * graph, int size, int src, int dst)

{

  int visited[size] ={0};

  struct node * top =NULL; //Make a stack for holding the visited vertices

  int crnt_visiting =src;

  int crnt_exploring =src;

  int path_cost =0;

  bool PATH_FOUND =false;

  while(!PATH_FOUND)

  {

    visited[crnt_visiting] =1;

    struct element temp;

    if(crnt_visiting==dst) //If the vertex is found

   {

      printf("\nPath found: ");

      printf("\nCost: %d\n", path_cost);

      while(!isStackEmpty(&top))

     {

        printf("Pop\n");

        pop(&top);

     }

      PATH_FOUND=true;

      continue;

   }

    else  //Explore this vertex

    { //Complete this function. You are free to make any changes to this function. Make sure that path cost is correctly found.

    }}}



Write a c program to calculate sum of square root from 1 to n number.



Instructions:

  1. Input two integers in one line. The first inputted integer will be the starting point, and the second one shall serve as the ending point.
  2. Use the power of loops to loop through the starting point until the ending point (inclusive), and print out each number within the range with the corresponding format shown on the sample output.
  3. However, skip the printing of statement if the integer is divisible by 4.
  4. Tip: Utilize the continue keyword to complete the process.

Input


1. The starting point

2. The ending point

Output

The first line will contain a message prompt to input the starting point.

The second line will contain a message prompt to input the ending point.

The succeeding lines will contain the appropriate messages.

Enter·the·starting·point:·2
Enter·the·ending·point:·10
Loading...2%
Loading...3%
Loading...5%
Loading...6%
Loading...7%
Loading...9%
Loading...10%




We've already done looping through a series of numbers and printing out its squares, so how about we level it up and go with cubes this time?


I have a condition though; I don't want to be associated with numbers that are divisible by 3 or 5 so if an integer is divisible by either of the two, don't make their cube values appear on the screen, please.


Care to fulfill my request?


Instructions:

  1. Print out the cube values of the numbers ranging from 1 to 1000 (inclusive). However, if the number is divisible by either 3 or 5, do not include them in printing and proceed with the next numbers.
  2. Tip: When skipping through special values, make use of the keyword continue and put them inside a conditional statement.

Output

Multiple lines containing an integer.

1
8
64
343
512
.
.
.
  1. Input two integers in one single line. The first inputted integer must be within 0-9 only.
  2. Using loops, identify if the first inputted integer (0-9) is present in the second inputted integer. If it is found, print "Yes". Otherwise, print "No".

Input


1. The digit to be found

2. The integer to be searched

Output


The first line will contain a message prompt to input the digit to be found.

The second line will contain a message prompt to input the integer.

The last line contains the appropriate string.

Enter·the·digit·(0·-·9):·1
Enter·the·integer:·231214238
Yes

Test Case 2

Expected Output

Enter the digit (0 - 9): 0
Enter the integer: 123456
No









Let’s play a game of FizzBuzz! It’s quite the same with your childhood "PopCorn" game, but with a little bit of twist to align it with programming.


Are you ready?


Instructions:

  1. Input a positive integer in one line. This will serve as the ending point of your loop.
  2. Loop from 1 to the ending point (inclusive) and perform the following statements:
  3. If the number is only divisible by 3, print "Fizz"
  4. If the number is only divisible by 5, print "Buzz"
  5. If the number is divisible by both 3 and 5, print "FizzBuzz"
  6. If nothing is true in the previous conditions, skip the number

Input

1. An integer

Output

The first line will contain a message prompt to input the integer.

The succeeding lines contain strings.

radio_button_unchecked

Test Case 1

Expected Output

Enter n: 15
Fizz
Buzz
Fizz
Fizz
Buzz
Fizz
FizzBuzz

radio_button_unchecked

Test Case 2

Expected Output

Enter n: 20
Fizz
Buzz
Fizz
Fizz
Buzz
Fizz
FizzBuzz
Fizz
Buzz






How to Attempt?





Charles and the Necklace





Charles wants to buy a necklace in which:





1. There is a minimum of 1 pearl and maximum of X pearls such that





each pearl has its own magnificent coefficient. 2. The pearls should be in non-decreasing order of their magnificence power.





You are given the maximum number of pearls in a necklace and the range of the magnificent coefficients of the pearls. Find the number of necklaces that can be made that follow the mentioned conditions.

Question 1



Revisit Later



Compil



How to Attempt?



Placement Season Begins



The placement season has begun in a college. There are N number of students standing outside an interview room in a line. It is given that a person who goes in first has higher chances of getting selected.



Each student has a number associated with them known as the problem solving capability (PSC). The higher the capability, the higher the chances of selection. Now, each student wants to know the number of students ahead of him/her who have more problem-solving capability than him/her.



Find this number for each student.



Input Specification:



input1: An integer N. which denotes the number of students present. input2: An array of size N, denoting the problem-solving capability of the students



Consider a square matrix A of size Nx N and an integer X which is an element of A. Find the row number R and column number C of X in A, and calculate the sum of Rand even, find the sum of the digits of all even numbers in the matrix, and if the sum is odd, then find the sum of digits of all odd numbers in the matrix.



Read the input from STDIN and print the output to STDOUT. Do not write arbitrary strings while reading the input or while printing, as these contribute to the standard outp



Constraints: 1) 1<N<= 35.



II) 0 <= RC < N.



III) X is always an element of A.



IV) Elements of A are unique.

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS