Computer Science, asked by SanjayDisale06, 2 months ago



The Torris County Visa Center generates the
token number for its applicants from their
application ID. The application ID is a numeric
value. The token number is generated in a
specific form. The even digits in the applicant's
ID are replaced by the digit one greater than
the even digit and the odd digits in the
applicant's ID are replaced by the digit one
lesser than the odd digit. The numeric value
thus generated represents the token number
of the applicant. write an algorithm to generate the token number from the applicant id​

Answers

Answered by lalithapavi156
44

Explanation:

#include <stdio.h>

#include<stdlib.h>

int main()

{

int n,count=0;

scanf("%d",&n);

char str[100];

sprintf(str, "%d", n);

for(int i=0;str[i] != '\0';i++)

{

if(str[i]%2==0)

{

++(str[i]);

}

else

{

--(str[i]);

}

}

int output-atoi (str); printf("%d",output);

}

Answered by pruthaasl
0

Answer:

The algorithm to generate the token number from the applicant id is as follows:

  1. Declare variables to store the application id, token number, counter of the for loop, and an array to separate the numbers from the application id and store them separately.
  2. Take the application id as the input from the user.
  3. Separate the digits of the application id and store them in an array using the for loop.
  4. Check whether each digit stored in the array is even or odd.
  5. If the digit is even, its value is incremented by one.
  6. If the digit is odd, its value is decremented by one.
  7. The token number is calculated and displayed using the for loop.

#SPJ3

Similar questions