(C programming Example for Beginners) C Program to Check Whether a Number is Even or Odd In this example, you will learn to check whether a number entered by the user is even or odd. An even number is an integer that is exactly divisible by 2. For example: 0, 8, -24 An odd number …
(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 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 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”, ÷nd); printf(“Enter divisor: …
(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 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 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 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 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? …
(C Programming Tutorials) C File Handling In this tutorial, you will learn about file handling in C. You will learn to handle standard I/O in C using fprintf(), fscanf(), fread(), fwrite(), fseek() etc. with the help of examples. A file is a container in computer storage devices used for storing data. Why files are needed? …