Print match for input number and the defined number

int swt1 = 4;
int swt2 = 5;
int swt3 = 6;
int swt4 = 7;
int swt5 = 8;
void setup() {
  Serial.begin(9600);
  pinMode(swt1, INPUT_PULLUP);
  pinMode(swt2, INPUT_PULLUP);
  pinMode(swt3, INPUT_PULLUP);
  pinMode(swt4, INPUT_PULLUP);
  pinMode(swt5, INPUT_PULLUP);
}

void loop() {
  
  PressButtonNumber (4);
  Serial.print("");
}

void PressButtonNumber (int * SWT)
{
  if(!digitalRead(* SWT))
  {
    Serial.print(* SWT);
    while(!digitalRead(* SWT));
  }
}

I am using a UNO board

If in above code I am defining a function so that I can put any of the push button number like 4 or 5 or 6 or 7
in serial monitor
I want to print the pressed switch details in such a manner that :-
If I press 4 it ll print 1
If I press 5 it ll print 2
If I press 6 it ll print 3 .. and so on

Important thing is :-
I can define any of the switch number randomly in anywhere in code

How to convert the press button number with our personal defined number

You specified that PressButtonNumber accepts a pointer, but supplied a simple int.
This will not end well.

The "*" indicates a pointer, but you are not sending the function a pointer. Remove it.

if (SWT == 4) Serial.print(1);

etc.

Then in this way I ll have to define for each input ????

Then in place of int what I need ??

The computer does only what you tell it to do.

No, put them in an array, and supply a random (but bounds-checked!) array index.

And suppose we don't want to plan for an array in case !!
Than in that situation , there is no option sir ??
Any other way ?

Fail to plan, plan to fail.

Your choice

Actually some function don't work due to its application in some cases so in that situation we have to make it out of array world

Ya That is true but in case of so a big mount of inputs all I need to define one by one in this manner ??

Didn't understand a word of that, I'm afraid.

If you've got bugs, fix them and thoroughly test before proceeding.

No no you can see my last some of threads where a discussion was regarding the defining of inputs individually but not in array . . do you remember one ??

No, I don't remember one, and I'm not going to search for one.
If you start a new topic, then it should supply all necessary information.

Do you have an array allergy or something?

Too much trouble to type five lines of code?

No its just example
Just a sample thing for practical purpose with 5 inputs
But in case if we increase the number of pins with MEGA etc types model
and for a big work

...use a big array.

:grin: :grin: :joy: :joy:
It not about allergy
Actually I was working on it before but some unstable conditions I got while operating with that !!

Well I am trying for it first !!!!

Big array is something different or just the same one we use and with more number of elements ??

So, stabilise, retest and work on that.
Don't try and build on top of buggy code.

And yes, a big array is just like a small array, but with more elements.