Category Archives: Basic C Programs for Beginners

C Program Natural Numbers One to Ten

What are Natural Numbers? The natural numbers (i.e. counting numbers) are numbers which are used for counting and ordering. They can be expressed mathematically as: ℕ = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, … } . Some mathematicians consider 0 to be a natural number. C Source Code Natural Numbers from One To Ten Display #include<stdio.h> int… Read More »

Loading

Find Largest of three double numbers if and Logical Operators

Find Largest of three double numbers #include <stdio.h> int main() { int n1, n2, n3, max; printf(“Enter first number=”); scanf(“%d”,&n1); printf(“Enter second number=”); scanf(“%d”,&n2); printf(“Enter third number=”); scanf(“%d”,&n3); max = (n1 > n2) ? (n1 > n3 ? n1 : n3) : (n2 > n3 ? n2 : n3); printf(“Largest number among %d, %d and… Read More »

Loading

C Program Find Largest of Three Using Ternary Operator

Find Largest of Three Using Ternary Operator: C Program Find Largest of Three #include <stdio.h> int main() { int n1, n2, n3, max; printf(“Enter first number=”); scanf(“%d”,&n1); printf(“Enter second number=”); scanf(“%d”,&n2); printf(“Enter third number=”); scanf(“%d”,&n3); max = (n1 > n2) ? (n1 > n3 ? n1 : n3) : (n2 > n3 ? n2 :… Read More »

Loading

Find Largest of Two Numbers Ternary Operator

Find Largest of Two Numbers Ternary Operator #include<stdio.h> int main() { int num1, num2; printf(“Enter First Number=”); scanf(“%d”, &num1); printf(“Enter 2nd Number=”); scanf(“%d”, &num2); if(num1 == num2) printf(“First Number %d is equal to Second Number %d “, num1,num2); else printf(“First Number %d is not equal to Second Number %d “, num1,num2); return 0; } Output:… Read More »

Loading

Check Both Numbers are Equal if else

Check Both Numbers are Equal if else #include<stdio.h> int main() { int num1, num2; printf(“Enter First Number=”); scanf(“%d”, &num1); printf(“Enter 2nd Number=”); scanf(“%d”, &num2); if(num1 == num2) printf(“First Number %d is equal to Second Number %d “, num1,num2); else printf(“First Number %d is not equal to Second Number %d “, num1,num2); return 0; }

Loading