# c-program

## C program to find the election winner

In this example, we will create a simple C program that simulates an election. The program allows the user to input the names of candidates and the number of votes they received. After collecting this information, the program determines the winner based on the candidate with the highest number of …

## C Program to convert Celcius to Fahrenheit

In this program, we will learn how to convert a temperature in Celcius to Fahrenheit. The standard formula to do so is: Fahrenheit = (Celsius * 9/5) + 32 Or  Fahrenheit = (Celsius * 1.8) + 32 Program: #include <stdio.h> int main() { float temp, fTemp; printf("Enter the temperature in …

## C Program to find Simple Interest

In this program, we will learn how to calculate the simple interest for a given amount at a given rate for a period of time in years. The simple interest can be calculated by the below given formula S.I. = (Principle * Rate * Time) / 100 We will use …

## C Program to Swap Two Numbers

In this program, we will see how we can swap the values of two variables in C. To understand this program, you should know about the following topics in C: Data types Operators Input / Output We shall take two approaches, one by using a third variable and other by …

## C program to display multiplication table

In this example, you will learn how to print the table of a number given by the user. To understand this example you should have the knowledge of – Operators in C. Loops. Program Using ‘while’ loop #include <stdio.h> int main() { int num, i = 1, res; printf("Enter a …

## C Program to Find the Sum of Natural Numbers

The positive numbers such as 1,2,3,4,5…. etc are known as natural numbers. In this program, you will see how to calculate the sum up to n natural numbers. We will ask a user to enter a number and then calculate the sum up to that number. For example, if the …

## C program to Find ASCII Value of a Character

ASCII value is a numeric value assigned to every defined character (including alphabets, punctuation marks, special symbols, numbers and control characters.). For example, the ASCII value of ‘A’ is 65 whereas ASCII value of ‘a’ is 97. In C programming a character variable holds the ascii value instead of the …

## C program to take input from the user

‘User input’ in programming is simply any input a user gives during the execution of a program or application. In C, there are many standard functions to take input from the user. In this program, we will take input from the user and store it in a variable using the …

## C Program to Check Prime Number

In this program we will check if a number entered by the user is prime or not. A prime number is a number which can be divided only by 1 and itself. For example 7, 13, 17, 23 and so on. To understand this program, you must know the following …

## C program to check whether a number is even or odd

In this C program we will learn how to check whether a number entered by a user is even or not. An even number is a number that can be divided by 2 completely. For example – 2,4,12,16 etc. An odd number is the vice versa of an even number. Consider …