Skip to main content

Featured

C Pattern Programs: Square Number and Alphabet Patterns Explained

๐Ÿ”ท Square Star Pattern ๐Ÿ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { printf("* ");//keep"* " } printf("\n"); } return 0; } ๐Ÿ”ท Reverse Square Alphabet Pattern (Column-wise) ๐Ÿ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = num; i >= 1; i--) { for(int j = num; j >= 1; j--) { printf("%c ", j + 64);//%c for Character and 64 will be ASIIC VALUE } printf("\n"); } return 0; } ๐Ÿ”ท Reverse Square Alphabet Pattern (Row-wise) ๐Ÿ“‹ Copy Code #include <stdio.h> int main() { int num; ...

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

๐ŸŒ™