#include<stdio.h>
int main()
{
int a, b, sum;
printf("Enter the two numbers : ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("nSum of %d and %d is : %d", a,b,sum);
return(0);
}
Computer Science » C Program » Find Sum of Two Float Numbers Program : [php]#include<stdio.h> int main() { float a, b, sum; printf("Enter two numbers : "); scanf("%f %f", &a, &b); sum = a + b; printf("nSum : %.2f", sum); return(0); }[/php] Output : [php]Enter two numbers : 2.2 3.6 Sum : 5.80[/php]
Computer Science » C Program » C Program Examples "How to print hello, world! using c program ? How to find area of a circle using c program ? How to find smallest element in an array using c program ? You all must have this kind of questions in your mind. Below article will solve this puzzle of yours. Just take a look.” - Here we have listed all the programs in C programming language, categorised under different progamming concepts like Basic, Area, Mathematical, Number, Array etc. Check the respective category to view all the programs under that category. C Programs - Basic C Programs C Programs - Number Programs C Programs - Area Programs C Programs - Mathematical Programs C Programs - Array Programs C Programs - Electrical Programs C Programs - Pyramid Programs
Computer Science » C Program » Calculate Sum and Average of an Array Program : [php]#include <stdio.h> int main() { int Arr[50]; int n, i, sum = 0; float average; printf("Enter the number of elements in Array : "); scanf("%d", &n); for (i = 0; i < n; i++) { printf("nEnter element %d : ", i + 1); scanf("%d", &Arr[i]); sum = sum + Arr[i]; } average = (float)sum/n; printf("nThe sum of the elements array is : %d", sum); printf("nThe average of the elements array is : %0.2f", average); return 0; }[/php] Output : [php]Enter the number of elements in Array : 5 Enter element 1 : 20 Enter element 2 : 30 Enter element 3 : 40 Enter element 4 : 50 Enter element 5 : 60 The sum of the elements array is : 200 The average of the elements array is : 40.00[/php]