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

Write a program to check whether character is Upper Case, Lower Case or Digit

 Description : 

You have to read a characer and check it is  upper case, lower case, digit or none.of.above.

Sample Execution : 

Test case 1 : 

Enter the character : A

The character is Upper Case.

Test case 2 :

Enter the character : 5

The character is Digit.

Test case 3 :

Enter the character : !

The character not an alphabet or digit.

PROGRAM:

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

#include<stdio.h>

int main()

{

    char ch;

  printf("Enter a character or digit;");

    scanf("%c",&ch);

     if(ch>='A' && ch<='Z')

   { printf("%c The character is Upper Case",ch );}

    else if(ch>='a' && ch<='z')

  {

       printf("%c The character is Lower Case",ch);

   }

   else if (ch>='0' && ch<='9')

   {

       printf("The character is Digit.");

   }

   else

   {

       printf("The character  not an  alphabet or digit.");

   }

   }

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

sampleoutput;Enter a character:A

sampleinput;The character is Upper case.



Comments

Popular Posts

๐ŸŒ™