
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

82K+ Views
A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.AlgorithmGiven below is an algorithm to print multiplication table by using for loop in C language −Step 1: Enter a number to print table at runtime. Step 2: Read that number from keyboard. Step 3: Using for loop print number*I 10 times. // for(i=1; i

21K+ Views
A calculator is a simple tool that helps us to calculate mathematical operations easily and quickly. A basic calculator can perform simple arithmetic operations like subtraction, addition, multiplication, and division. Begin by writing the C code to create a simple calculator. Then, follow the algorithm given below to write a C program. Algorithm Step 1: Declare variables Step 2: Enter any operator at runtime Step 3: Enter any two integer values at runtime Step 4: Apply switch case to select the operator: // case '+': result = num1 + num2; ... Read More

316 Views
The formula for finding profit is as follows if the selling price is greater than cost price −profit=sellingPrice-CosePrice;The formula for finding loss is as follows if cost price is greater than selling price −loss=CostPrice-SellingPriceNow, apply this logic in the program and try to find whether the person gets a profit or loss after buying any article −ExampleFollowing is the C program to find the profit or loss − Live Demo#include int main(){ float CostPrice, SellingPrice, Amount; printf(" Enter the product Cost : "); scanf("%f", &CostPrice); printf(" Enter the Selling Price) : "); scanf("%f", &SellingPrice); if ... Read More

57K+ Views
The logic that we implement to convert Fahrenheit to Celsius is as follows −celsius = (fahrenheit - 32)*5/9;AlgorithmRefer to the algorithm given below to convert Fahrenheit to Celsius.Step 1: Declare two variables farh, cels Step 2: Enter Fahrenheit value at run time Step 3: Apply formula to convert Cels=(farh-32)*5/9; Step 4: Print celsExampleFollowing is the C program to convert Fahrenheit to Celsius − #include int main(){ float fahrenheit, celsius; //get the limit of fibonacci series printf("Enter Fahrenheit: "); scanf("%f",&fahrenheit); celsius = (fahrenheit - 32)*5/9; printf("Celsius: %f ", celsius); return 0; }OutputWhen the above program is executed, it produces the following result −Enter Fahrenheit: 100 Celsius: 37.777779

1K+ Views
Temperature conversion is nothing but converting Fahrenheit temperature to Celsius or Celsius to Fahrenheit.In this programming, we are going to explain, how to convert the Fahrenheit temperature to Celsius temperature and how to represent the same in the form of the table by using a function.ExampleFollowing is the C program for temperature conversion − Live Demo#include float conversion(float); int main(){ float fh,cl; int begin=0,stop=300; printf("Fahrenheit \t Celsius");// display conversion table heading printf("----------\t-----------"); fh=begin; while(fh

11K+ Views
The main purpose of variables is to store data in memory. Unlike constants, it will not change during the program execution. However, its value may be changed during execution.The variable declaration indicates that the operating system is going to reserve a piece of memory with that variable name.Variable declarationThe syntax for variable declaration is as follows −type variable_name;ortype variable_name, variable_name, variable_name;For example, iInt a, b; float c; double d;Here, a, b, c, d are variables. The int, float, double are the data types.Variable initializationThe syntax for variable initialization is as follows −data type variablename=value;For example, int width, height=20; char letter='R'; ... Read More

2K+ Views
ProblemDeclare int and float variables without initializing and try to print their values in C language. Explain what will happen.SolutionIf a variable is declared but not initialized or uninitialized and if those variables are trying to print, then, it will return 0 or some garbage value.Whenever we declare a variable, a location is allocated to that variable. The only thing is with the help of initialization, we are trying to occupy the memory location which is already allotted while declaration.But in the below program, we are not initializing the values in the memory locations which are reserved. But, by default, ... Read More

3K+ Views
Pointers have many but easy concepts and they are very important to C programming.Two of the arithmetic pointer concepts are explained below, which are C pointer addition and subtraction respectively.C pointer additionC pointer addition refers to adding a value to the pointer variable.The formula is as follows −new_address= current_address + (number * size_of(data type))ExampleFollowing is the C program for C pointer addition − Live Demo#include int main(){ int num=500; int *ptr;//pointer to int ptr=#//stores the address of number variable printf("add of ptr is %u ", ptr); ptr=ptr+7; //adding 7 to pointer variable printf("after adding add ... Read More

36K+ Views
A pointer is a variable that stores the address of another variable. The deceleration of a pointer is similar to that of a variable the only difference is while declaring a pointer we need to use "*". Following is the syntax to declare a pointer − type *variable_name; Similar to variables, pointers can be declared in different types. Following is an example − #Integer type pointer int *integer_pointer; #Character type pointer char *character_pointer; The following are the points to be noted − Pointers enable direct memory access and manipulation, which is crucial for ... Read More

4K+ Views
ProblemCalculate the sum of all elements of a two-dimensional array by using run-time initialization.SolutionTwo-dimensional Array is used in situations where a table of values have to be stored (or) in matrices applicationsThe syntax is as follows −datatype array_ name [rowsize] [column size];For example, int a[4] [4];Number of elements in an array = rowsize *columnsize = 4*4 = 16ExampleFollowing is the C program to calculate the sum of all elements of a two-dimensional array by using run-time initialization − Live Demo#include void main(){ //Declaring array and variables// int A[4][3], i, j, even=0, odd=0; //Reading elements into the array// ... Read More