Pages

Wednesday, November 30, 2011

C Programming to read four digit number and find the sum of all digits.


/* to read 4 digit number and find sum of all digits */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,n1,n2,n3,n4,S;
    printf("Enter the four digit number: ");
    scanf("%d",&n);
    n1=n%10;
    n2=(n/10)%10;
    n3=(n/100)%10;
    n4=(n/1000)%10;
    S=n1+n2+n3+n4;
    printf("The sum of numbers=%d",S);
    system("pause");
    return 0;
}

C Programming to read four digit number and find the sum of all digits.


/* to read 4 digit number and find sum of all digits */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,n1,n2,n3,n4,S;
    printf("Enter the four digit number: ");
    scanf("%d",&n);
    n1=n%10;
    n2=(n/10)%10;
    n3=(n/100)%10;
    n4=(n/1000)%10;
    S=n1+n2+n3+n4;
    printf("The sum of numbers=%d",S);
    system("pause");
    return 0;
}

C Programming to display 4 digit number in reverse order


/* to read four digit number and display the number in reverse order */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,a,b,c,d;
    printf("Enter the four digit number: ");
    scanf("%d",&n);
    a=n%10;
    printf("%d",a);
    n=n/10;
    b=n%10;
    printf("%d",b);
    n=n/10;
    c=n%10;
    printf("%d",c);
    n=n/10;
    d=n%10;
    printf("%d",d);
    system("pause");
    return 0;
}

C Programming to display 4 digit number in reverse order


/* to read four digit number and display the number in reverse order */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,a,b,c,d;
    printf("Enter the four digit number: ");
    scanf("%d",&n);
    a=n%10;
    printf("%d",a);
    n=n/10;
    b=n%10;
    printf("%d",b);
    n=n/10;
    c=n%10;
    printf("%d",c);
    n=n/10;
    d=n%10;
    printf("%d",d);
    system("pause");
    return 0;
}

C Programming to display 4 digit number in reverse order


/* to read four digit number and display the number in reverse order */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,a,b,c,d;
    printf("Enter the four digit number: ");
    scanf("%d",&n);
    a=n%10;
    printf("%d",a);
    n=n/10;
    b=n%10;
    printf("%d",b);
    n=n/10;
    c=n%10;
    printf("%d",c);
    n=n/10;
    d=n%10;
    printf("%d",d);
    system("pause");
    return 0;
}

C Programming to display 4 digit number in reverse order


/* to read four digit number and display the number in reverse order */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,a,b,c,d;
    printf("Enter the four digit number: ");
    scanf("%d",&n);
    a=n%10;
    printf("%d",a);
    n=n/10;
    b=n%10;
    printf("%d",b);
    n=n/10;
    c=n%10;
    printf("%d",c);
    n=n/10;
    d=n%10;
    printf("%d",d);
    system("pause");
    return 0;
}

C Programming to read price of three items, add 13%VAT,10% Service charge and calculate total price


/* to display total price after paying service charge and Tax of three items*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    float P1,P2,P3,P,VAT,SC,T;
    printf("Enter the price of first article: ");
    scanf("%f",&P1);
    printf("Enter the price of second article: ");
    scanf("%f",&P2);
    printf("Enter the price of third article: ");
    scanf("%f",&P3);
    P=P1+P2+P3;
    VAT=0.13*P;
    SC=0.1*P;
    T=P+VAT+SC;
    printf("The total price paid by costumer:%f",T);
    system("pause");
    return 0;
}

C Programming to read price of three items, add 13%VAT,10% Service charge and calculate total price


/* to display total price after paying service charge and Tax of three items*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    float P1,P2,P3,P,VAT,SC,T;
    printf("Enter the price of first article: ");
    scanf("%f",&P1);
    printf("Enter the price of second article: ");
    scanf("%f",&P2);
    printf("Enter the price of third article: ");
    scanf("%f",&P3);
    P=P1+P2+P3;
    VAT=0.13*P;
    SC=0.1*P;
    T=P+VAT+SC;
    printf("The total price paid by costumer:%f",T);
    system("pause");
    return 0;
}

C Programming to read basic salary, Travelling Allowance Rate, Daily Allowance Rate, House Rent Allowance Rate and TAX Rate and calculate Net Salary


/* To calculate Net Salary */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    float TA,DA,HRA,TAX,BS,NS,RTA,RDA,RHRA,RTAX;
    printf("Input Basic Salary: ");
    scanf("%f",&BS);
    printf("Enter the rate of Travelling Allowance: ");
    scanf("%f",&RTA);
    printf("Enter the rate of Daily ALlowance: ");
    scanf("%f",&RDA);
    printf("Enter the rate of House Rent Allowance: ");
    scanf("%f",&RHRA);
    printf("Enter the rate of TAX: ");
    scanf("%f",&RTAX);
    TA=RTA/100*BS;
    DA=RDA/100*BS;
    HRA=RHRA/100*BS;
    TAX=RTAX/100*BS;
    NS=BS+TA+DA+HRA-TAX;
    printf("The Net Salary is=%f",NS);
    system("pause");
    return 0;
}

C Programming to read basic salary, Travelling Allowance Rate, Daily Allowance Rate, House Rent Allowance Rate and TAX Rate and calculate Net Salary


/* To calculate Net Salary */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    float TA,DA,HRA,TAX,BS,NS,RTA,RDA,RHRA,RTAX;
    printf("Input Basic Salary: ");
    scanf("%f",&BS);
    printf("Enter the rate of Travelling Allowance: ");
    scanf("%f",&RTA);
    printf("Enter the rate of Daily ALlowance: ");
    scanf("%f",&RDA);
    printf("Enter the rate of House Rent Allowance: ");
    scanf("%f",&RHRA);
    printf("Enter the rate of TAX: ");
    scanf("%f",&RTAX);
    TA=RTA/100*BS;
    DA=RDA/100*BS;
    HRA=RHRA/100*BS;
    TAX=RTAX/100*BS;
    NS=BS+TA+DA+HRA-TAX;
    printf("The Net Salary is=%f",NS);
    system("pause");
    return 0;
}

C Programming to Convert minutes into seconds


/* To convert minutes into seconds */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    float n,b,s;
    int a;
    printf("Enter time in Minutes: ");
    scanf("%f",&n);
    a=n;
    b=n-a;
    s=a*60+b*100;
    printf("The time in seconds:%0.2f",s);
    system("pause");
    return 0;
}

C Programming to Convert minutes into seconds


/* To convert minutes into seconds */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    float n,b,s;
    int a;
    printf("Enter time in Minutes: ");
    scanf("%f",&n);
    a=n;
    b=n-a;
    s=a*60+b*100;
    printf("The time in seconds:%0.2f",s);
    system("pause");
    return 0;
}

C Programming to calculate total and percentage of 5 subjects

/*calculate total and percentage of 5 subjects */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int S1,S2,S3,S4,S5;
    float t,p;
    printf("Enter marks in subject one: ");
    scanf("%d",&S1);
    printf("Enter marks in subject two: ");
    scanf("%d",&S2);
    printf("Enter marks in subject three: ");
    scanf("%d",&S3);
    printf("Enter the marks in subject four: ");
    scanf("%d",&S4);
    printf("Enter the marks in subject five: ");
    scanf("%d", &S5);
    t=S1+S2+S3+S4+S5;
    p=t/500*100;
    printf("the total of all subjects=%f",t);
    printf("\nthe percentage of all subjects=%f",p);
    system("pause");
    return 0;
}

C Programming to calculate total and percentage of 5 subjects

/*calculate total and percentage of 5 subjects */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int S1,S2,S3,S4,S5;
    float t,p;
    printf("Enter marks in subject one: ");
    scanf("%d",&S1);
    printf("Enter marks in subject two: ");
    scanf("%d",&S2);
    printf("Enter marks in subject three: ");
    scanf("%d",&S3);
    printf("Enter the marks in subject four: ");
    scanf("%d",&S4);
    printf("Enter the marks in subject five: ");
    scanf("%d", &S5);
    t=S1+S2+S3+S4+S5;
    p=t/500*100;
    printf("the total of all subjects=%f",t);
    printf("\nthe percentage of all subjects=%f",p);
    system("pause");
    return 0;
}

C Programming to calculate perimeter of rectangle

/*to calculate perimeter of rectangle*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    float l,b,p;
    printf("Enter length of rectangle: ");
    scanf("%f",&l);
    printf("Enter breadth of rectangle: ");
    scanf("%f",&b);
    p=2*(l+b);
    printf("The perimeter of rectangle=%f",p);
    system("pause");
    return 0;
}

C Programming to calculate perimeter of rectangle

/*to calculate perimeter of rectangle*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    float l,b,p;
    printf("Enter length of rectangle: ");
    scanf("%f",&l);
    printf("Enter breadth of rectangle: ");
    scanf("%f",&b);
    p=2*(l+b);
    printf("The perimeter of rectangle=%f",p);
    system("pause");
    return 0;
}

C Programming to calculate simple intrest

/*to calculate simple intrest*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    float p,t,r,SI;
    printf("enter the principle amount: ");
    scanf("%f",&p);
    printf("enter the time: ");
    scanf("%f",&t);
    printf("enter the rate of intrest: ");
    scanf("%f",&r);
    SI=p*t*r/100;
    printf("the value of Simple Intrest=%f",SI);
    system("pause");
    return 0;
}

C Programming to calculate simple intrest

/*to calculate simple intrest*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
    float p,t,r,SI;
    printf("enter the principle amount: ");
    scanf("%f",&p);
    printf("enter the time: ");
    scanf("%f",&t);
    printf("enter the rate of intrest: ");
    scanf("%f",&r);
    SI=p*t*r/100;
    printf("the value of Simple Intrest=%f",SI);
    system("pause");
    return 0;
}

C Programming to find area and circumference of a circle

/*to find area and circumference of a circle*/
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
    float r,a,c;
    printf("Enter radius of a circle: ");
    scanf("%f",&r);
    a=M_PI*r*r;
    c=M_PI*2*r;
    printf("The area of the circle=%f",a);
    printf("\n the circumference of the circle=%f",c);
    system("pause");
    return 0;
}

C Programming to find area and circumference of a circle

/*to find area and circumference of a circle*/
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
    float r,a,c;
    printf("Enter radius of a circle: ");
    scanf("%f",&r);
    a=M_PI*r*r;
    c=M_PI*2*r;
    printf("The area of the circle=%f",a);
    printf("\n the circumference of the circle=%f",c);
    system("pause");
    return 0;
}