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 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 » Find Factorial of a Number Program : [php]#include <stdio.h> int main() { int i, fact = 1, num; printf("Enter the number : "); scanf("%d", &num); if (num <= 0) fact = 1; else { for (i = 1; i <= num; i++) { fact = fact * i; } } printf("nFactorial of %d is : %5d", num, fact); }[/php] Output : [php]Enter the number : 5 Factorial of 5 is : 120[/php]
Computer Science » C Program » Print Alternate Numbers in an Array Program : [php] int main() { int array[9]; int i; printf("Enter the element of the array : "); for (i = 0; i < 9; i++) scanf("%d", &array[i]); printf("nAlternate elements of the entered array : n"); for (i = 0; i < 9; i += 2) printf( "%dn", array[i]) ; }[/php] Output : [php]Enter the element of the array : 1 2 3 4 5 6 7 8 9 Alternate elements of the entered array : 1 3 5 7 9[/php]
Computer Science » C Program » Swap of Two Numbers using Pointers Program : [php]#include <stdio.h> int main() { int x,y,temp,*a,*b; printf("Enter the two numbers : "); scanf("%d%d",&x,&y); printf("nBefore swapping : n x = %dn y = %dn",x,y); a = &x; b = &y; temp = *b; *b = *a; *a = temp; printf("After swapping : n x = %dn y = %dn",x,y); return 0; }[/php] Output : [php]Enter the two numbers : 10 20 Before swapping : x = 10 y = 20 After swapping : x = 20 y = 10[/php]