#include <stdio.h> int main() { char chr; printf("Enter a character: "); scanf("%c", &chr); /* logic to check whether it is an alphabet */ if((chr >= 'a' && chr<='z') || (chr>='A' && chr<='Z')) { printf("It is an alphabet.\n"); } else if(chr>='0' && chr<='9') /* to check digit */ { printf("It is a digit.\n"); } else /* else special character */ { printf("It is a special character.\n"); } } Sample output 1 Enter a character: A It is an alphabet. Sample output 2 Enter a character: 5 It is a digit. Sample output 3 Enter a character: @ It is a special character.
This blog assists in mastering C and C++ programming skills from basics to advanced levels.
Pages
Sunday, January 23, 2022
Check whether a character is an alphabet, digit or special character
Friday, December 31, 2021
Use of #define in C program
Use of #define
Example of #define in C program
#include<stdio.h> #include<Windows.h> #define DISPLAY printf int main() { int i; for(i=0; i<3; i++) { DISPLAY("..... Good Bye 2021 ....."); Sleep(500); system("cls"); Sleep(500); } for(i=0; i<3; i++) { DISPLAY("..... WEL COME 2022 ....."); Sleep(500); system("cls"); Sleep(500); } return 0; }
Saturday, October 2, 2021
Flowchart to check Positive Negative or Zero number
This article is specifically posted for one of the request received from the student.
Flowchart to check Positive Negative or Zero number
|
| Flowchart to Check Positive, Negative or Zero Number |
Recommended readings:
-
Flowchart to print 10, 9, ......, 1.
-
Flowchart to Add two numbers.
-
Flowchart to subtract two numbers.
-
Flowchart to print area of square.
-
Flowchart to print area of rectangle.
Sunday, August 1, 2021
C Program to perform Matrix Subtraction
Matrix Subtraction
We will write a C program to perform matrix subtraction operation.Key points for subtraction of matrices
- Two matrices should be of same order (number of rows=number of columns).
- Subtract the corresponding element of matrices.
Example: Subtraction of matrix of order 3 * 3
C Program to perform Matrix Subtraction
#include<stdio.h> int main() { int A[3][3],B[3][3],C[3][3],i, j; //Loops for Reading A matrix for ( i = 0; i < 3; i++ ) //related to row { for ( j = 0; j < 3; j++ ) //related to column { printf("Matrix A[%d][%d]:",i,j); scanf("%d", &A[i][j]) ; } } //Loops for Reading B matrix for ( i = 0; i < 3; i++ ) //related to row { for ( j = 0; j < 3; j++ ) //related to column { printf("Matrix B[%d][%d]:",i,j); scanf("%d", &B[i][j]) ; } } printf("Matrix A is as under: \n") ; /* Print Matrix A, B */ for ( i = 0; i < 3; i++ ) //related to row { for ( j = 0; j < 3; j++ ) //related to column { printf(" %d\t ",A[i][j] ); } printf("\n"); } printf("Matrix B is as under: \n") ; for ( i = 0; i < 3; i++ ) //related to row { for ( j = 0; j < 3; j++ ) //related to column { printf(" %d\t ",B[i][j] ); } printf("\n"); } printf("Matrix Subtraction is as under: \n"); for ( i = 0; i < 3; i++ ) //related to row { for ( j = 0; j < 3; j++ ) //related to column { printf(" %d\t ",A[i][j] - B[i][j] ); } printf("\n"); } return 0; }
Matrix A[0][0]:4 Matrix A[0][1]:5 Matrix A[0][2]:6 Matrix A[1][0]:7 Matrix A[1][1]:8 Matrix A[1][2]:9 Matrix A[2][0]:10 Matrix A[2][1]:11 Matrix A[2][2]:12 Matrix B[0][0]:1 Matrix B[0][1]:3 Matrix B[0][2]:2 Matrix B[1][0]:5 Matrix B[1][1]:4 Matrix B[1][2]:3 Matrix B[2][0]:2 Matrix B[2][1]:3 Matrix B[2][2]:6 Matrix A is as under: 4 5 6 7 8 9 10 11 12 Matrix B is as under: 1 3 2 5 4 3 2 3 6 Matrix Subtraction is as under: 3 2 4 2 4 6 8 8 6
Saturday, May 8, 2021
Flowchart to input 5 numbers from user and to print odd or even number.
Flowchart to read 5 numbers from user and to print odd or even number.
[ This article is posted for a request received from the visitor of the blog.]
Following flowchart will input 5 numbers one by one from the user and prints whether it is Odd or Even number.
![]() |
| Fig. Flowchart to input 5 numbers and to print Odd or Even |
Output of the flowchart:
This flowchart is generated using Raptor tool. Read more about RAPTOR here.
Top 10 Flowcharts Examples
You may like to visit following top 10 flowchart examples.
- Flowchart to check positive number.
- Flowchart to check negative number.
- Flowchart to check Odd or Even number.
- Flowchart to display Good morning message based on given time.
- Flowchart to print A to Z.
- Flowchart to print 10, 9, ......, 1.
- Flowchart to Add two numbers.
- Flowchart to subtract two numbers.
- Flowchart to print area of square.
- Flowchart to print area of rectangle.
Monday, February 15, 2021
C program to find square of given number without an argument and a return value
C Programming => Functions
C program to find square of given number using function concept. This program demonstrate use of function without an argument and a return value.
Program code
#include<stdio.h>
int square(); //function prototype declaration.
int number; //use of global variable
int main()
{
int answer;
answer = square(); //Call function.
printf("Square of %d is %d.", number, answer);
return 0;
}
//User defined function to find square()
int square()
{
printf("Enter your number:");
scanf("%d", &number);
//return answer to main function
return(number*number);
}
Output of the program
Square of 5 is 25.
Monday, January 18, 2021
Flowchart to check Odd or Even Number between 1 to 10
Flowchart to check odd or even number between 1 to 10 numbers
Output of the flowchart:
1 is odd
2 is even
3 is odd
4 is even
5 is odd
6 is even
7 is odd
8 is even
9 is odd
10 is even
----Run complete. 55 symbols evaluated.----
* * * * *
This flowchart is generated using Raptor tool. Read more about RAPTOR here.
Top 10 Flowcharts Examples
You may like to visit following top 10 flowchart examples.
- Flowchart to check positive number.
- Flowchart to check negative number.
- Flowchart to check Odd or Even number.
- Flowchart to display Good morning message based on given time.
- Flowchart to print A to Z.
- Flowchart to print 10, 9, ......, 1.
- Flowchart to Add two numbers.
- Flowchart to subtract two numbers.
- Flowchart to print area of square.
- Flowchart to print area of rectangle.





