Search This Blog

Friday, March 17, 2017

Here I write a code for addition. Where I use 4 variable that is for integer number. If anyone wants to use floating point number or double number. Then just write float a,b,c,d,sum. then write your code and use %f  for taking your floating or double number. You can also use more variable that you want. If you have to need more variable then you have to use array[ ]. That is different.



#include<stdio.h>
int main()

{
    int a,b,c,d,sum;

    printf("Please enter your 1st value: ");
    scanf("%d",&a);
    printf("Please enter your 2nd value: ");
    scanf("%d",&b);
    printf("Please enter your 3rd value: ");
    scanf("%d",&c);
    printf("Please enter your 4th value: ");
    scanf("%d",&d);

    sum=a+b+c+d;
    printf("\nYour total number is: %d\n",sum);


    return 0;


}

Output of above code.




No comments:

Post a Comment