C Programming Tutorials

C Example for Beginners: C Program to Swap Two Numbers

(C programming Example for Beginners) C Program to Swap Two Numbers In this example, you will learn to swap two numbers in C programming using two different techniques. Swap Numbers Using Temporary Variable #include<stdio.h> int main(){ double first, second, temp; printf(“Enter first number: “); scanf(“%lf”, &first); printf(“Enter second number: “); scanf(“%lf”, &second); // Value of …

C Example for Beginners: C Program to Find the Size of int, float, double and char

(C programming Example for Beginners) C Program to Find the Size of int, float, double and char In this example, you will learn to evaluate the size of each variable using sizeof operator. Program to Find the Size of Variables #include<stdio.h> int main(){ int intType; float floatType; double doubleType; char charType; // sizeof evaluates the …

C Example for Beginners: C Program to Compute Quotient and Remainder

(C programming Example for Beginners)   C Program to Compute Quotient and Remainder In this example, you will learn to find the quotient and remainder when an integer is divided by another integer. Program to Compute Quotient and Remainder #include <stdio.h> int main(){ int dividend, divisor, quotient, remainder; printf(“Enter dividend: “); scanf(“%d”, &dividend); printf(“Enter divisor: …

C Example for Beginners: C Program to Find ASCII Value of a Character

(C programming Example for Beginners) C Program to Find ASCII Value of a Character In this example, you will learn how to find the ASCII value of a character. In C programming, a character variable holds ASCII value (an integer number between 0 and 127) rather than that character itself. This integer value is the …

C Example for Beginners: C Program to Multiply Two Floating-Point Numbers

(C programming Example for Beginners) C Program to Multiply Two Floating-Point Numbers In this example, the product of two floating-point numbers entered by the user is calculated and printed on the screen. Program to Multiply Two Numbers #include <stdio.h> int main(){ double a, b, product; printf(“Enter two numbers: “); scanf(“%lf %lf”, &a, &b); // Calculating …

C Example for Beginners: C Program to Add Two Integers

(C programming Example for Beginners) C Program to Add Two Integers In this example, the user is asked to enter two integers. Then, the sum of these two integers is calculated and displayed on the screen. Program to Add Two Integers #include <stdio.h> int main(){ int number1, number2, sum; printf(“Enter two integers: “); scanf(“%d %d”, …

C Example for Beginners: C Program to Print an Integer that is Entered by the User

(C programming Example for Beginners) C Program to Print an Integer (Entered by the User) In this example, the integer entered by the user is stored in a variable and printed on the screen. Program to Print an Integer #include <stdio.h> int main(){ int number; printf(“Enter an integer: “); // reads and stores input scanf(“%d”, …

C Example for Beginners: C “Hello, World!” Program

(C programming Example for Beginners)   C “Hello, World!” Program In this example, you will learn to print “Hello, World!” on the screen in C programming. Program to Display “Hello, World!” #include <stdio.h> int main(){ // printf() displays the string inside quotation printf(“Hello, World!”); return 0; } Output Hello, World! How “Hello, World!” program works? …