Skip to main content

Featured

Mastering Hollow Square Patterns in C: Stars, Numbers, Alphabets & Binary

๐Ÿ”ข C Program to Print Hollow Continuous Number Square ๐Ÿ“„ Source Code: #include <stdio.h> int main() { int num, k = 0; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { if(i == 1 || i == num || j == 1 || j == num) { // k increments sequentially only along the borders printf("%d ", k++); } else { printf(" "); } } printf("\n"); } return 0; } ๐Ÿ“‹ Copy Code ๐Ÿ’ป Expected Output (Input: 5): Enter the number: 5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ๐Ÿ”ข C Program to Print Standard Hollow Binary Row Square ๐Ÿ“„ Source Code (Fixed Specifier): #include <stdio.h> int main() { ...

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

๐ŸŒ™