 # C Programming Code Examples

## C > Beginners Lab Assignments Code Examples

### C program to add two numbers

``` C program to add two numbers Write a C program to input two numbers from user and calculate their sum. C program to add two numbers and display their sum as output. How to add two numbers in C programming. #include <stdio.h> int main() { int number1, number2, sum; /* Read two numbers from user*/ printf("Enter first number: "); scanf("%d", &number1); printf("Enter second number:"); scanf("%d", &number2); /* Adding both number is simple and fundamental */ sum = number1 + number2; /* Prints the sum of two numbers */ printf("Sum of %d and %d = %d", number1, number2, sum); return 0; } ```

C Find Prime Numbers Between the Range - The program takes the range and finds all the 'Prime Numbers' between the range & prints. Lets first take the range of numbers between which you have to find the prime numbers as

Find the Volume and Surface Area of Cone - This C Program to calculates the volume and surface area of cone. This program is used to find the the volume and surface area of cone. Surface_Area = Pi * r * (r + sqrt(r2 + h2)) and

Sort N Numbers in Ascending Order using - C Program to sorts the numbers in ascending order using bubble sort. Bubble sort is simple "Sorting Algorithm" that works by repeatedly Stepping Through the List to be Sorted, then

C++ Language Add Digits of any Number - To add digits of any number in C++, we enter the number to add their digits & displays the "Addition Result" of the digits of the entered number on the output screen as shown here

Multiple Initialization Inside For Loop in C - 1. It is initializing two variables. Note: both are separated by comma (,). 2. It has two test conditions joined together using AND (&&) logical operator. You cannot use multiple test

Finds Factorial of Number using Recursion - This c program prompts user for entering any integer, finds the Factorial of input number & displays the output on screen. Use a recursive user defined function to perform the task. We

C Programming language WAV file player - You need a HUGE memory model to run this. Checks to see if a Sound Blaster exists at a given address, returns true if Sound Blaster found, false if not. Send a byte to the DSP

Take decimal number as input & converts - C Program take a decimal number as input. Divide the input number by 8 and obtain its remainder and quotient. Store the remainder in the array. Repeat the step 2 with quotient