Skip to main content

Featured

Merge Sort in C++

  Merge Sort in C++ Introduction Merge Sort is a popular sorting algorithm that follows the Divide and Conquer approach. It divides an array into smaller subarrays, recursively sorts those subarrays, and finally merges the sorted subarrays to produce a completely sorted array. In this tutorial, we will learn how to implement Merge Sort in C++ . The program divides the array into two halves using the mid index, recursively sorts both halves, and then combines them using the merge() function. Merge Sort has a time complexity of O(n log n) in the best, average, and worst cases. Table of Contents Algorithm C++ Program Input Sample Output Output Explanation Dry Run Flow of Execution Time Complexity Space Complexity Applications Key Points Interview Questions Frequently Asked Questions Keywords Conclusion Algorithm Start the program. Read the size of the array. Read the array elements from the user. Call the mer...

WAP to print the grade for a given percentage

 Description : 

You have to read a interger value from user, it should be less than 100.

*) if percentage is greater than 90 and less than or equal to 100 - 'A'

*) if percentage is greater than 70 and less than 91 - 'B'

*) if percentage is greater than 50 and less than 71 - 'C'

*) if percentage is less than or equal to 50 - 'F' 


Sample Execution : 

Test case 1 : 

Enter the percentage : 95

The Grade is A 

Test case 2 : 

Enter the percentage : 115

Error : Please enter the percentage less than or equal to 100. 


PROGRAM:

---------------------------------------------------------------------------------------------------------------

#include<stdio.h>

int main()

{

  int percentage;

    // printf("Enter the percentage:");

    scanf("%d",&percentage); 

    if(percentage>=90 && percentage <=100)

     {

        printf("The Grade is A");

    }

      else if(percentage>=70 && percentage <=91)

     {

        printf("The Grade is B");

    }

      else if(percentage>=51 && percentage <=71)

     {

        printf("The Grade is C");

    }

     else if(percentage<=50)

    {

        printf("The Grade is F");

    }

     else 

    {

        printf("Error : Please enter the percentage less than or equal to 100.");

    }

     


---------------------------------------------------------------------------------------------------------------


sample input;

Enter the percentage:95

sample output;

The Grade is A

Comments

Popular Posts

🌙