Home » Programming

Write a ‘C’ Program to compute the sum of all elements stored in an array using pointers

Published on 12-Dec-2021 17:17:20
C Program to compute sum of the array elements using pointers Program : #include <stdio.h> #include <conio.h> void main() { int numArray[10]; int i, sum = 0; int *ptr; printf("\nEnter 10 elements : "); for (i = 0; i < 10; i++) scanf("%d", &numArray[i]); ptr = numArray; /* a=&a[0] */ for (i = 0; i < 10; i++) { sum = sum + *ptr; ptr++; } printf("... Read More

How to Calculate Area of Circle using C Programming

Published on 12-Dec-2021 13:16:37
C Program to Calculate Area of Circle Shape : Circle Formula : Π * r * r Definition : 1. Ellipse in which the two axes are of equal length 2. Plane curve generated by one point moving at a constant distance from a fixed point 3. You can compute the area of a Circle if you know its radius. Program : #include <stdio.h> int main() { float radius, area; printf("\nEnter the radius of Circle : "); scanf("%d", &... Read More

How to Calculate Area of Rectangle using C Program

Published on 12-Dec-2021 13:06:07
C Program to Calculate Area of Rectangle Shape : Rectangle formula : area = l * b Definition : 1. A plane figure with 4 sides and 4 right angles and having Equal Opposite Sides 2. Adjucent sides makes an angle of 90 degree 3. You can compute the area of a Rectangle if you know its length and breadth Program :  #include <stdio.h> #include <conio.h> int main() { int length, breadth, area; printf("\nEnt... Read More

How to Calculate Area of Right angle Triangle using C Language

Published on 12-Dec-2021 12:56:56
C Program to Calculate Area of Right angle Triangle Definition : Triangle having one angle of measure 90 degree is called Right angle Triangle. Sides of Triangle are : base , height , hypotenuse. You can compute the area of a Tr. if you know its any two sides. Program :  #include <stdio.h> int main() { int base, height; float area; printf("\nEnter the base of Right Angle Triangle : "); scanf(... Read More

How to Find Area of Scalene Triangle using C

Published on 12-Dec-2021 12:44:54
C Program to Find Area of Scalene Triangle : #include <stdio.h> #include <math.h> int main() { int s1, s2, angle; float area; printf("\nEnter Side1 : "); scanf("%d", &s1); printf("\nEnter Side2 : "); scanf("%d", &s2); printf("\nEnter included angle : "); scanf("%d", &angle); area = (s1 * s2 * sin((M_PI / 180) * angle)) / 2; printf("\nArea of Scalene Triangle : ... Read More

How to print hello world using C Language

Published on 12-Dec-2021 9:36:41
In this example, you will learn to print "Hello, World!" on the screen in C programming. #include <stdio.h> int main() { // printf() displays the string inside quotation printf("Hello, World!"); return 0; } Output : Hello, World! ... Read More

How to convert temperature from degree centigrade to Fahrenheit using C

Published on 12-Dec-2021 9:21:47
C Program to convert temperature from degree centigrade to Fahrenheit #include <stdio.h> int main() { float celsius, fahrenheit; printf("\nEnter temp in Celsius : "); scanf("%f", &celsius); fahrenheit = (1.8 * celsius) + 32; printf("\nTemperature in Fahrenheit : %f ", fahrenheit); return (0); } Output Enter temp in Celsius : 32 Temperature in Fahrenheit : 89.59998 ... Read More

How To Send mail from your Gmail account using Python

Published on 22-Nov-2021 21:52:51
Here, we are going to learn how to send a simple basic mail using Python code. Python, being a powerful language don’t need any external library to import and offers a native library to send emails- “SMTP lib”. “smtplib” creates a Simple Mail Transfer Protocol client session object which is used to send emails to any valid email id on the internet. Different websites use different port numbers. In this article, we are using a Gmail a... Read More

How can we create recursive functions in Python?

Published on 30-Oct-2021 14:38:44
Recursion is a programming method, in which a function calls itself one or more times in its body. Usually, it is returning the return value of this function call. If a function definition follows recursion, we call this function a recursive function. Also Read : How to get a list of parameter names inside Python function? A recursive function has to terminate to be used in a program. It terminates, if with every recursive call the solution of... Read More

How to get a list of parameter names inside Python function?

Published on 30-Oct-2021 13:40:54
To extract the number and names of the arguments from a function or function[something] to return ("arg1", "arg2"), we use the inspect module. The given code is written as follows using inspect module to find the parameters inside the functions aMethod and foo. Example import inspect def aMethod(arg1, arg2): pass print(inspect.getargspec(aMethod)) def foo(a,b,c=4, *arglist, **keywords): pass print(inspect.getargspec(foo))  Output ... Read More