C Program to Generate Multiplication Table
Multiplication Table Up to 10 #include <stdio.h> int main() { int n, i; printf(“Enter an integer: “); scanf(“%d”, &n); for (i = 1; i <= 10; ++i) { printf(“%d * %d = %d \n”, n, i, n * i); } return 0; }
C Tutorial
Multiplication Table Up to 10 #include <stdio.h> int main() { int n, i; printf(“Enter an integer: “); scanf(“%d”, &n); for (i = 1; i <= 10; ++i) { printf(“%d * %d = %d \n”, n, i, n * i); } return 0; }
Using if Statement #include <stdio.h> int main() { double n1, n2, n3; printf(“Enter three different numbers: “); scanf(“%lf %lf %lf”, &n1, &n2, &n3); if (n1 >= n2 && n1 >= n3) printf(“%.2f is the largest number.”, n1); if (n2 >= n1 && n2 >= n3) printf(“%.2f is the largest number.”, n2); if (n3 >= n1 … Read more
Reverse an Integer #include <stdio.h> int main() { int n, rev = 0, remainder; printf(“Enter an integer: “); scanf(“%d”, &n); while (n != 0) { remainder = n % 10; rev = rev * 10 + remainder; n /= 10; } printf(“Reversed number = %d”, rev); return 0; }
The Fibonacci sequence is a sequence where the next term is the sum of the previous two terms. The first two terms of the Fibonacci sequence are 0 followed by 1. The Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21 Visit this page to learn about the Fibonacci sequence. Fibonacci Series up … Read more
The factorial of a positive number n is given by: factorial of n (n!) = 1 * 2 * 3 * 4….n The factorial of a negative number doesn’t exist. And, the factorial of 0 is 1. Factorial of a Number #include <stdio.h> int main() { int n, i; unsigned long … Read more
Program to Check Leap Year #include <stdio.h> int main() { int year; printf(“Enter a year: “); scanf(“%d”, &year); if (year % 4 == 0) { if (year % 100 == 0) { // the year is a leap year if it is divisible by 400. if … Read more
Find LCM of two numbers in C What is LCM The Least Common Multiple ( LCM ) is also referred to as the Lowest Common Multiple ( LCM ) and Least Common Divisor (LCD) . For two integers a and b, denoted LCM(a,b), the LCM is the smallest positive integer that is evenly divisible by both a and b. For example, LCM(2,3) = … Read more
Functions C Human is an intelligent species, but still cannot perform all of life’s tasks all alone. He has to rely on others. You may call a mechanic to fix up your bike, hire a gardener to mow your lawn, or rely on a store to supply you groceries every month. A computer program (except … Read more
C program to convert time in Hours:Minutes:Seconds to seconds /* C program to convert time in hours:minutes:seconds to seconds */ #include <stdio.h> int main() { int hour, minute, second, timeinsec; printf(“Enter the value for hour:”); /* get hour value from user*/ scanf(“%d”, &hour); printf(“Enter the value for minute:”); /* get minute value from user */ … Read more
Selection Sort Algorithm Selection sort is an algorithm that selects the smallest element from an unsorted list in each iteration and places that element at the beginning of the unsorted list. The Selection sort algorithm is based on the idea of finding the minimum or maximum element in an unsorted array and then putting it … Read more