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 » Find greatest in 3 numbers Program : [php]#include<stdio.h> int main() { int a, b, c; printf("nEnter value of a, b & c : "); scanf("%d %d %d", &a, &b, &c); if ((a > b) && (a > c)) printf("na is greatest"); if ((b > c) && (b > a)) printf("nb is greatest"); if ((c > a) && (c > b)) printf("nc is greatest"); return(0); }[/php] Output : [php]Enter value for a,b & c : 12 16 20 c is greatest[/php]
Computer Science » C Program » Find sum of Two Integer Numbers Program : [php]#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); }[/php] Output : [php]Enter the two numbers : 2 4 Sum of 2 and 4 is : 6[/php]
Computer Science » C Program » Find Sum of Digits of a Number Program : [php]#include <stdio.h> int main() { long number, digit, sum = 0; printf("Enter the number :"); scanf("%ld", &number); while (number > 0) { digit = number % 10; sum = sum + digit; number = number / 10; } printf("nSum of the digits of given number is : %ld", sum); }[/php] Output : [php]Enter the number : 2882 Sum of the digits of given number is : 20[/php]
Computer Science » C Program » Calculate Sum of Odd and Even Numbers Program : [php]#include <stdio.h> int main() { int i, n; int sum_odd = 0, sum_even = 0; printf("Enter the number up to which you want to calculate sum : "); scanf("%d", &n); for (i = 1; i <= n; i++) { if (i % 2 == 0) sum_even = sum_even + i; else sum_odd = sum_odd + i; } printf("nSum of all even numbers is : %d", sum_even); printf("nSum of all odd numbers is : %d", sum_odd); }[/php] Output : [php]Enter the number up to which you want to calculate sum : 100 Sum of all even numbers is : 2550 Sum of all odd numbers is : 2500[/php]