You are on page 1of 6

Name: Prathamesh Prashant Nikam Scholar No.

: 22U02050 Date:01/12/2022

Assignment III

1) Write a c program that will take a numeric number and convert it into
ASCII CODE.
/*****************
Programme created by: Prathamesh Prashant Nikam
Scholar No.: 22U02050
Branch: Computer Science and Engineering
*****************/

#include <stdio.h>

int main()
{
    char character;
    printf("Enter any character:");
    scanf("%c",&character);
    printf("\nThe ASCII Value of the character is %d",character);
    return 0;
}

Input:
K

Output:
The ASCII Value of the character is 107
Name: Prathamesh Prashant Nikam Scholar No.: 22U02050 Date:01/12/2022

2) If a five-digit number is input through the keyboard, write a program to


calculate the sum of its digits.
/*****************
Programme created by: Prathamesh Prashant Nikam
Scholar No.: 22U02050
Branch: Computer Science and Engineering
*****************/

#include <stdio.h>

int main()
{
    int num1,dig1,dig2,dig3,dig4,dig5,sum;
    printf("Enter a five digit number:");
    scanf("%d",&num1);
    dig1=num1%10;
    num1/=10;
    dig2=num1%10;
    num1/=10;
    dig3=num1%10;
    num1/=10;
    dig4=num1%10;
    num1/=10;
    dig5=num1%10;
    num1/=10;
    sum=dig1+dig2+dig3+dig4+dig5;
    printf("\nSum of digits of the number is %d",sum);
    return 0;
   
}

Input:
12345

Output:
Sum of digits of the number is 15
Name: Prathamesh Prashant Nikam Scholar No.: 22U02050 Date:01/12/2022

3) If a five-digit number is input through the keyboard, write a program to


reverse the number.
/*****************
Programme created by: Prathamesh Prashant Nikam
Scholar No.: 22U02050
Branch: Computer Science and Engineering
*****************/

#include <stdio.h>

int main()
{
    int num1,dig1,dig2,dig3,dig4,dig5,rever;
    printf("Enter a five digit number:");
    scanf("%d",&num1);
    dig1=num1%10;
    num1/=10;
    dig2=num1%10;
    num1/=10;
    dig3=num1%10;
    num1/=10;
    dig4=num1%10;
    num1/=10;
    dig5=num1%10;
    num1/=10;
    rever=(10000*dig1)+(1000*dig2)+(100*dig3)+(10*dig4)+dig5;
    printf("\nThe reversed number is %d",rever);
    return 0;
}

Input:
12345

Output:
The reversed number is 54321.
Name: Prathamesh Prashant Nikam Scholar No.: 22U02050 Date:01/12/2022

4) In a town, the percentage of men is 52. The percentage of total


literacy is 48. If total percentage of literate men is 35 of the total
population, write a program to find the total number of illiterate men and
women if the population of the town is 80,000.
/*****************
Programme created by: Prathamesh Prashant Nikam
Scholar No.: 22U02050
Branch: Computer Science and Engineering
*****************/

#include <stdio.h>

int main()
{
    int population=80000,pmen,tlit,litm,litf,ilm,ilf;
    pmen=0.52*80000.0;
    tlit=0.48*80000.0;
    litm=0.35*80000.0;
    litf=tlit-litm;
    ilm=pmen-litm;
    ilf=tlit-litf;
    printf("Total Population is %d",population);
    printf("\nNumber of illiterate men is %d",ilm);
    printf("\nNumber of illiterate women is %d",ilf);
    return 0;
}

Output:
Total Population is 80000
Number of illiterate men is 13600
Number of illiterate women is 28000
Name: Prathamesh Prashant Nikam Scholar No.: 22U02050 Date:01/12/2022

5) A cashier has currency notes of denominations 10, 50 and 100. If the


amount to be withdrawn is input through the keyboard in hundreds, find
the total number of currency notes of each denomination the cashier will
have to give to the withdrawer.
/*****************
Programme created by: Prathamesh Prashant Nikam
Scholar No.: 22U02050
Branch: Computer Science and Engineering
*****************/

#include <stdio.h>

int main()
{
    int mw,ot,fh,oh;
    printf("Enter the amount of money to be withdrawn:");
    scanf("%d",&mw);
    ot=mw/1000;
    mw%=1000;
    fh=mw/500;
    mw%=500;
    oh=mw/100;
    mw%=100;
    printf("Number of 1000 rs. notes are %d",ot);
    printf("\nNumber of 500 rs. notes are %d",fh);
    printf("\nNumber of 100 rs. notes are %d",oh);
    printf("\nRemaining Change is %d",mw);
    return 0;
}

Input:
54321

Output:
Number of 1000 rs. notes are 54
Number of 500 rs. notes are 0
Number of 100 rs. notes are 3
Remaining Change is 21
Name: Prathamesh Prashant Nikam Scholar No.: 22U02050 Date:01/12/2022

6) 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.
/*****************
Programme created by: Prathamesh Prashant Nikam
Scholar No.: 22U02050
Branch: Computer Science and Engineering
*****************/

#include <stdio.h>

int main()
{
    int n,d1,d2,d3,d4,d5,nn,k1,k2,k3,k4,k5;
    printf("Enter a five digit number:");
    scanf("%d",&n);
    d1=n%10;
    n/=10;
    d2=n%10;
    n/=10;
    d3=n%10;
    n/=10;
    d4=n%10;
    n/=10;
    d5=n%10;
    n/=10;
    k1=(d5+1);
    k2=(d4+1);
    k3=(d3+1);
    k4=(d2+1);
    k5=(d1+1);
    k1%=10;
    k2%=10;
    k3%=10;
    k4%=10;
    k5%=10;
    nn=(10000*k1)+(1000*k2)+(100*k3)+(10*k4)+k5;
    printf("New number with increment of 1 in each digit is %d",nn);
    return 0;
}

Input: 12345
Output: New number with increment of 1 in each digit is 23456.

**********************************************************************************

You might also like