C Program to Swap Two Numbers using Pointer

Write a C program to swap two numbers using pointer and the temporary variable. In this example, the swapTwo function accepts two pointer variables integer types. Next, using the temporary variable, we swapped them. #include <stdio.h> void swapTwo(int *x, int *y) { int temp; temp = *x; *x = *y; *y = temp; } int … Read more

C Program to Convert Binary to Octal

Write a C program to convert binary to octal using a while loop. In this c example, the first while loop converts binary two decimal and the second loop converts a decimal to octal.  #include <stdio.h> #include<math.h> int main() { int i, octal = 0, decimal = 0; long binary; printf(“Enter the Binary Number = … Read more

C Program to Find Array Elements Greater than Average

Write a c program to find array elements greater than average using for loop. In this c example, first, we find the sum and average of array elements. Next, we used the if statement (if(arr[i] > arrAvg)) checks whether each array element is greater than average. If True, it will print that element. #include <stdio.h> … Read more

C program to Calculate Average of an Array

Write a C program to calculate average of an array using for loop. In this c example, the for loop iterate all array elements and calculate the sum. Next, we calculate the average by dividing the sum with array size. #include <stdio.h> int main() { int Size, i, sum = 0; float avg = 0; … Read more

C Program To Perform Arithmetic Operations using Functions

Write a C program to perform arithmetic operations such as addition, subtraction, multiplication, and division using functions. In this example, we created multiple functions that accept two integer values and finds the addition, subtraction, multiplication, division, and modulus. #include <stdio.h> int addition(int num1, int num2) { int sum = num1 + num2; return sum; } … Read more

C Program to Find the Absolute Value of a Number

Write a C program to find the absolute value of a number, a positive integer of a given number. In C programming, the stdlib header has an abs function that prints the absolute value. #include <stdio.h> #include <stdlib.h> int main() { int num; printf(“Enter Number to find Absolute Value = “); scanf(“%d”,&num); int abNum = … Read more

Python Program to Print Right Triangle of Fibonacci Series Numbers Pattern

Write a Python program to print right triangle of Fibonacci series numbers pattern using for loop. rows = int(input(“Enter Right Triangle of Fibonacci Numbers Rows = “)) print(“====Right Angled Triangle of Fibonacci Series Numbers Pattern====”) for i in range(1, rows + 1): First_Value = 0 Second_Value = 1 for j in range(1, i + 1): … Read more

C Program to Remove White Spaces from a String

Write a C program to remove white spaces from a string using a for loop. In this C example, for loop iterate string from the first character to last, and the if statement check for the empty or whitespace character. If True, the compiler will skip that character from storing it into the array. #include … Read more

C Program to Read Input and Print String

Write a C program to read input and print string as an output. For example, we can use the gets method to read the user input and %s formatted to print the string as an output. #include <stdio.h> int main() { char msg[100]; printf(“Please enter Any String or Message = “); gets(msg); printf(“The string that … Read more