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
Server Side Programming Articles - Page 1247 of 2650
333 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
58K+ 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
12K+ 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
37K+ 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
388 Views
ProblemCalculate the sum and product of all elements in an array by using the run-time compilation.SolutionA two-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[5] [5];Number of elements in array = rowsize *columnsize = 5*5 = 25ExampleFollowing is the C program to calculate the sum and product of all elements in an array by using the run-time compilation − Live Demo#include void main(){ //Declaring the array - run time// int A[2][3], B[2][3], i, j, sum[i][j], product[i][j]; ... Read More
9K+ Views
Try to print the elements in reverse order by following an algorithm given below −Step1 − Declare an array of size 5Step 2 − Enter the 5 elements in memory using for loopStep 3 − Display elements in reverse orderBy decrementing for loopThe only logic is to reverse the elements is For loop −for(i=4;i>=0;i--){ //Displaying O/p// printf("array[%d] :", i); printf("%d", array[i]); }ExampleFollowing is the C program to reverse the elements − Live Demo#include void main(){ //Declaring the array - run time// int array[5], i; //Reading elements into the array// printf("Enter elements into the array: ... Read More