Server Side Programming Articles - Page 1234 of 2650

How to write a C program to find the roots of a quadratic equation?

Bhanu Priya
Updated on 10-Dec-2024 13:10:44

154K+ Views

Problem Applying the software development method to solve any problem in C Language. Solution Find roots of a quadratic equation, ax2+bx+c. There will be 2 roots for given quadratic equation. Analysis Input − a, b, c values Output − r1, r2 values Procedure $r_{1}=\frac{-b+\sqrt{b^2-4ac}}{2a}$ $r_{2}=\frac{-b-\sqrt{b^2-4ac}}{2a}$ Design (Algorithm) Start Read a, b, c values Compute d = b2 4ac if d > 0 then ... Read More

Difference Between For and Foreach in PHP

AmitDiwan
Updated on 02-Mar-2021 05:08:19

5K+ Views

In this post, we will understand the differences between 'for' and 'foreach' loops in PHP −The 'for' loopIt is an iterative loop that repeats a set of code till a specified condition is reached. It is used to execute a set of code for a specific number of times. Here, the number of times is the iterator variable.Syntax:for( initialization; condition; increment/decrement ) {    // code to iterate and execute }Initialization: It is used to initialize the iterator variables. It also helps execute them one at a time without running the conditional statement at the beginning of the loop's condition.Condition: ... Read More

Difference Between Object and Class in C++

AmitDiwan
Updated on 02-Mar-2021 04:57:52

945 Views

In this post, we will understand the difference between an object and a class with respect to C++ programming language.Classes in C++It is a building block of code in C++ that helps implement object oriented programming.It is a type that is defined by the user.It holds its own data members and member functions.These data members and member functions can be accessed by creating an instance of the class.They can be used to manipulate the variables and can be used to define property to tell how the objects in a class have to act.It can be understood as a blueprint for ... Read More

Difference Between C# and C++

AmitDiwan
Updated on 02-Mar-2021 04:56:56

590 Views

Let us first learn about C# and C++ −C# is a general-purpose object-oriented programming language.It is considered as a pure object-oriented programming language.It is pronounced as 'C sharp'.It was developed by Anders Hejlsberg and his team at Microsoft.Memory Management is done automatically by the garbage collector.It is the language's duty to automatically delete the object once its objective is completed.It is windows specific, i.e. it can't be used on all systems.It doesn't support multiple inheritance.The pointers in C# can only be used in the unsafe mode.It is considered as a high-level language.Once the code is compiled, it gets converted into ... Read More

Python Pandas – How to use Pandas DataFrame tail( ) function

Vani Nalliappan
Updated on 27-May-2024 11:21:00

673 Views

Write a Python code to find price column value between 30000 to 70000 and print the id and product columns of the last three rows from the products.csv file. Result for price column value between 30000 to 70000 and id and product columns last three rows are −    id product 79 80 Truck 81 82 Bike 98 99 TruckSolution 1 Read data from products.csv file and assign to dfdf = pd.read_csv('products.csv ')Apply pandas slicing to access all rows of price column between 30000 to 50000 as, df[df.iloc[:, 4].between(30000, 50000)Save the above result to df1Apply slicing to access last ... Read More

Python Pandas – How to use Pandas DataFrame Property: shape

Vani Nalliappan
Updated on 29-Feb-2024 13:29:10

965 Views

Write a Python program to read data from the products.csv file and print the number of rows and columns. Then print the ‘product’ column value matches ‘Car’ for first ten rowsAssume, you have ‘products.csv’ file and the result for number of rows and columns and ‘product’ column value matches ‘Car’ for first ten rows are −Rows: 100 Columns: 8  id product engine avgmileage price height_mm width_mm productionYear 1 2  Car    Diesel    21      16500    1530    1735       2020 4 5  Car    Gas       18      17450    1530   ... Read More

Convert vowels from upper to lower or lower to upper using C program

Bhanu Priya
Updated on 24-Mar-2021 14:29:19

2K+ Views

An array of characters is called a string.DeclarationFollowing is the declaration for an array −char stringname [size];For example − char a[50]; string of length 50 charactersInitializationUsing single character constant −char a[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constants −char a[10] = "Hello":;AccessingThere is a control string "%s" used for accessing the string till it encounters ‘\0’.The logic used to convert vowels from upper to lower or lower to upper is −for(i=0;string[i]!='\0';i++){    if(string[i]=='a'||string[i]=='e'||string[i]=='i'||string[i]=='o'||string[i]=='u'){       string[i]=toupper(string[i]);    } } printf("The result string with converted vowels is : "); puts(string);ProgramFollowing is the C program using conversion functions ... Read More

C Program to find the given number is strong or not

Sindhura Repala
Updated on 23-Jan-2025 10:53:45

43K+ Views

Recursive Factorial Calculation A strong number is a number, where the sum of the factorial of its digits equals the number itself. In C programming, a factorial is the product of all positive integers less than or equal to a given number. To calculate the factorial of a number, we use a recursive function with the argument N. This function will repeatedly call itself with a decremented value of N, multiplying the results until it reaches 1. 123!= 1!+2!+3!  =1+2+6 =9 In this case, 123 is not a strong number because the sum of the factorial of its digits ... Read More

C Program to find two’s complement for a given number

Bhanu Priya
Updated on 24-Mar-2021 14:25:47

17K+ Views

The two’s complement for a given binary number can be calculated in two methods, which are as follows −Method 1 − Convert the given binary number into one’s complement and then, add 1.Method 2 − The trailing zero’s after the first bit set from the Least Significant Bit (LSB) including one that remains unchanged and remaining all should be complementing.The logic to find two’s complement for a given binary number is as follows −for(i = SIZE - 1; i >= 0; i--){    if(one[i] == '1' && carry == 1){       two[i] = '0';    }    else ... Read More

What is enumerated data type in C language?

Bhanu Priya
Updated on 24-Mar-2021 14:24:31

3K+ Views

These are used by the programmers to create their own data types and define what values the variables of these datatypes can hold.The keyword is enum.SyntaxThe syntax for enumerated data type is as follows −enum tagname{    identifier1, identifier2, ……., identifier n };ExampleGiven below is an example for enumerated data type −enum week{    mon, tue, wed, thu, fri, sat, sun };Here, Identifier values are unsigned integers and start from 0.Mon refers 0, tue refers 1 and so on.ExampleFollowing is the C program for enumerated data type − Live Demo#include main ( ){    enum week {mon, tue, wed, thu, fri, ... Read More

Advertisements