(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 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? …
(C Programming Tutorials) C Unions In this tutorial, you’ll learn about unions in C programming. More specifically, how to create unions, access its members and learn the differences between unions and structures. A union is a user-defined type similar to structs in CÂ except for one key difference. Structs allocate enough space to store all its …
(C Programming Tutorials) C Structure and Function In this tutorial, you’ll learn to pass struct variables as arguments to a function. You will learn to return struct from a function with the help of examples. Similar to variables of built-in types, you can also pass structure variables to a function. Passing structs to functions We …