Skip to main content

Featured

Solve LeetCode 3 Longest Substring Without Repeating Characters in C++ using the sliding window

Longest Substring Without Repeating Characters in C++ LeetCode 3 · sliding window · last index array Table of Contents Problem Statement Approach 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 Conclusion Problem Statement 3. Longest Substring Without Repeating Characters Given a string s , find the length of the longest substring that contains no repeating characters. A substring is a continuous part of the string, so "pwke" is a subsequence of "pwwkew" but not a substring. Approach We use a sliding window . The window is the part of the string between start and end , and we always keep it free of repeated characters. An array lastIndex of size 128 remembers the most recent position of every ASCII ...

Write a program to print the grade for a given percentage in c

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.");

    }

     }

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

Comments

Popular Posts

🌙