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

Updated on 12-Dec-2021 20:35:39
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("The sum of array elements : %d", sum); } Outpu... Read More

How to check the type of triangle using C

Updated on 12-Dec-2021 17:04:29
C Program to check the type of triangle #include <stdio.h> #include <math.h> int main() { int side1, side2, side3; //Change values accordingly side1 = 5; side2 = 4; side3 = 3; if ((side1 + side2 > side3 && side1 + side3 > side2 && side2 + side3 > side1) && (side1 > 0 && side2 > 0 && side3 > 0)) { if (side1 == side2 && side2 == side3) { printf("Equilateral... Read More

Advertisements

Updated on 16-oct-2001 12:00:00

How to Calculate Area of Circle using C Programming

Updated on 12-Dec-2021 13:17: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", &radius); area = 3.14 * radius * radius;... Read More

How to Calculate Area of Rectangle using C Program

Updated 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("\nEnter the Length of Rectangle : "); scanf("%d", &... Read More

How to Calculate Area of Right angle Triangle using C Language

Updated on 12-Dec-2021 12:57:49
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("%d", &base); printf("\nEnter the heigh... Read More

Advertisements

Updated on 16-oct-2001 12:00:00

How to Find Area of Scalene Triangle using C

Updated 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 : %f", area); return (0); } Output : Ente... Read More

How to Calculate Area of Equilatral Triangle using C Language

Updated on 12-Dec-2021 9:59:37
#include<stdio.h> #include<math.h> int main() { int side; float area, r_4; r_4 = sqrt(3) / 4; printf("\nEnter the Length of Side : "); scanf("%d", &side); area = r_4 * side * side; printf("\nArea of Equilateral Triangle : %f", area); return (0); } Output : Enter the Length of Side : 5 Area of Equilateral Triangle : 10.82 Properties of Equilateral Triangle : Equilateral triangle is a triangle in which all three sides a... Read More

Advertisements

Updated on 16-oct-2001 12:00:00

How to print hello world using C Language

Updated on 12-Dec-2021 9:39:30
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 Check Whether Number is Perfect Or Not using C

Updated on 12-Dec-2021 9:31:51
C Program to Check Whether Number is Perfect Or Not #include <stdio.h> int main() { int num, i = 1, sum = 0; printf("Enter a number: "); scanf("%d", &num); while (i < num) { if (num % i == 0) { sum = sum + i; } i++; } if (sum == num) printf("%d is a Perfect Number", i); else printf("%d is Non Perfect Number", i); return 0; } ... Read More
Advertisements

ads

Codegyan » Page 8 of 10 » The Best Technical Questions And Answers