C languageC SolutionChapter 2Programming

Q5 If a five-digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits. For example, if the number that is input is 12391, then the output should be displayed as 23502.

Program: 68

If a five-digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits. For example, if the number that is input is 12391, then the output should be displayed as 23502.

Output

Enter N Digit's Number: 12349
Output: 23460

Lokesh Kumar

Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.

4 thoughts on “Q5 If a five-digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits. For example, if the number that is input is 12391, then the output should be displayed as 23502.

  • Logic is good but you can see your program at list once output of programe is not match as expected

    Reply
    • Mujtaba Noor Muhammad

      simple logic is that add 11111 value in inputs number
      12391
      + 11111

      23502 ans

      Reply
  • Utkarsh

    the question says that when ever a digit 9 comes the number left side to it should not be increased by 2. that is happening in your program so, I think question is not same

    Reply
  • #include <stdio.h>
    int main()

    {
    int num [5];

    printf(“Enter the numbers: “);
    //while entering the number give space between them
    scanf(“%d%d%d%d%d”,&num[0],&num[1],&num[2],&num[3],&num[4]);

    num[0]=num[0]+1;
    num[1]=num[1]+1;
    num[2]=num[2]+1;
    num[3]=num[3]+1;
    num[4]=num[4]+1;

    printf(“%d%d%d%d%d”,num[0],num[1],num[2],num[3],num[4]);

    return 0;

    }

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.