Write a function in the program to return 1 if number is prime otherwise return 0
Sum of first N natural numbers in C
As we know natural numbers contain all the positive numbers starting from 1, 2, 3, to n numbers or infinity.
Write a program to convert string into upper case
Here is the program to convert a string to uppercase in C language,
Reverse a String in C
This topic will discuss several ways to reverse a string in the C programming language.
Write a program to sort given array in ascending order ( Use insertion sort, Bubble sort, Selection sort, Merge sort, Quickshort, Heapsort)
Insertion Sort Algorithm:
Write a program to find a character from given string
C program to search all occurrences of a character in a given string - In this post, we will explain the multitude of ways to search all occurrence of a character in a given string in c programming.
Program to replace the spaces of a string with a specific character
Explanation
In this program, we need to replace all the spaces present in the string with a specific character.
String: Once in a blue moon
String after replacing space with '-': Once-in-a-blue-moon
One of the approach to accomplish this is by iterating through the string to find spaces. If spaces are present, then assign specific character in that index. Other approach is to use a built-in function replace function to replace space with a specific character.
Algorithm
- Define a string.
- Determine the character 'ch' through which spaces need to be replaced.
- Use replace function to replace space with 'ch' character
- Program:
#include<stdio.h>#include<string.h>int main(){char str[80], ch1, ch2;int i;printf("\n Enter string :");gets(str);printf("\n Enter character to be replaced :");scanf("%c",&ch1);getchar();printf("\n Enter character to replace :");scanf("%c",&ch2);for(i=0;i<=strlen(str);i++){if(str[i]==ch1){str[i]=ch2;}}printf("\n Final string :%s", str);return 0;}
- Output:
Enter string :ABCDEF Enter character to be replaced :C Enter character to replace :A Final string :ABADEF
- Visit:
Write a C program to computer Fahrenheit from centigrade ( f=1.8*c+32 ) Here
Write a C program to find out distance travelled by the equation d=ut+at^2 Here
Write a C program to find that the accepted number is negative or positive or zero Here
Write a program to read mark of a student from keyboard the student is pass or fail ( using if else ) Here
Write a program to read three numbers from keyboard and find out maximum out of these three. (nested if else) Here
Write a program to check whether the entered character is capital, small letter, digit or any special character Here
Write a program to read marks from keyboard and your program should display equivalent grade according to following table (if else ladder) Here
Write a C program to prepare pay slip using following data Here
Write a C program to read no 1 to 7 and print relatively day Sunday to Saturday Here
Write a C program to find out the Maximum and Minimum number from given 10 numbers Here
Write a C program to input an integer number and check the last digit of number is even or odd Here
Write a C program to find factorial of a given number Here
Write a C program to reverse a number Here
Write a C program to generate first n number of Fibonacci series Here
Write a C program to find out sum of first and last digit of a given number Here
Write a C program to find the sum and average of different numbers Here
Write a program to calculate average and total of 5 students for 3 subjects Here
Read five persons height and weight and count the number of person having height greater than 170 and weight less than 50 Here
Write a program to check whether the given number is prime or not Here
Write a program to evaluate the series 1^2+2^2+2+3^2+……+n^2 Here
Write a C program to find 1+1/2+1/3+1/4+....+1/n Here
Write a C program to find 1+1/2!+1/3!+1/4!+.....+1/n! Here
Write a C program to evaluate the series sum=1-x+x^2/2!-x^3/3!+x^4/4!......-x^9/9! Here
Write a C program to read and store the roll no and marks of 20 students using array Here
Write a C program to find out which number is even or odd from list of 10 number using array Here
Write a program to find maximum element from 1-Dimensional array Here
Write a C program to calculate the average, geometric and harmonic mean of n elements in a array Here
Write a program to delete a character in given string Here
Write a program to replace a character in given string Here
Write a program to find a character from given string Here
Write a program to sort given array in ascending order Here
Write a program to reverse string Here
Write a program to convert string into upper case Here
Write a program that defines a function to add first n numbers Here
Write a function in the program to return 1 if number is prime otherwise return 0 Here
Write a function Exchange to interchange the values of two variables, say x and y. illustrate the use of this function in a calling function Here
Write a C program to use recursive calls to evaluate F(x) = x – x3 / 3! + x5 / 5 ! – x7 / 7! + … xn/ n! Here
Write a program to find factorial of a number using recursion Here
Write a function that will scan a character string passed as an argument and convert all lowercase character into their uppercase equivalents Here
Write a program to read structure elements from keyboard Here
C Program to Remove All Occurrences of a Character in a String
Write a C Program to Remove All Occurrences of a Character in a String with example.
This program allows the user to enter a string (or character array), and a character value.
In this,
we have to delete character in string: i.e.
Entering name Nilesh pPatel
we have to delete p character and make final sting like Nilesh Patel
- Program:
#include<stdio.h>#include<conio.h>int main(){char str[80], ch;int i,j;printf("\n Enter string :");scanf("%[^\n]s",str);fflush(stdin);printf("\n Enter character to delete :");scanf("%c",&ch);for(i=0;str[i]!='\0';i++){if(str[i]==ch){for(j=i;j<str[j]!='\0';j++){str[j]=str[j+1];}i--;}}printf("\n Final string :%s", str);return 0;}
- Output:
Enter string :Nilesh pPatel Enter character to delete :p Final string :Nilesh Patel
- Visit:
Write a C program to computer Fahrenheit from centigrade ( f=1.8*c+32 ) Here
Write a C program to find out distance travelled by the equation d=ut+at^2 Here
Write a C program to find that the accepted number is negative or positive or zero Here
Write a program to read mark of a student from keyboard the student is pass or fail ( using if else ) Here
Write a program to read three numbers from keyboard and find out maximum out of these three. (nested if else) Here
Write a program to check whether the entered character is capital, small letter, digit or any special character Here
Write a program to read marks from keyboard and your program should display equivalent grade according to following table (if else ladder) Here
Write a C program to prepare pay slip using following data Here
Write a C program to read no 1 to 7 and print relatively day Sunday to Saturday Here
Write a C program to find out the Maximum and Minimum number from given 10 numbers Here
Write a C program to input an integer number and check the last digit of number is even or odd Here
Write a C program to find factorial of a given number Here
Write a C program to reverse a number Here
Write a C program to generate first n number of Fibonacci series Here
Write a C program to find out sum of first and last digit of a given number Here
Write a C program to find the sum and average of different numbers Here
Write a program to calculate average and total of 5 students for 3 subjects Here
Read five persons height and weight and count the number of person having height greater than 170 and weight less than 50 Here
Write a program to check whether the given number is prime or not Here
Write a program to evaluate the series 1^2+2^2+2+3^2+……+n^2 Here
Write a C program to find 1+1/2+1/3+1/4+....+1/n Here
Write a C program to find 1+1/2!+1/3!+1/4!+.....+1/n! Here
Write a C program to evaluate the series sum=1-x+x^2/2!-x^3/3!+x^4/4!......-x^9/9! Here
Write a C program to read and store the roll no and marks of 20 students using array Here
Write a C program to find out which number is even or odd from list of 10 number using array Here
Write a program to find maximum element from 1-Dimensional array Here
Write a C program to calculate the average, geometric and harmonic mean of n elements in a array Here
Write a program to delete a character in given string Here
Write a program to replace a character in given string Here
Write a program to find a character from given string Here
Write a program to sort given array in ascending order Here
Write a program to reverse string Here
Write a program to convert string into upper case Here
Write a program that defines a function to add first n numbers Here
Write a function in the program to return 1 if number is prime otherwise return 0 Here
Write a function Exchange to interchange the values of two variables, say x and y. illustrate the use of this function in a calling function Here
Write a C program to use recursive calls to evaluate F(x) = x – x3 / 3! + x5 / 5 ! – x7 / 7! + … xn/ n! Here
Write a program to find factorial of a number using recursion Here
Write a function that will scan a character string passed as an argument and convert all lowercase character into their uppercase equivalents Here
Write a program to read structure elements from keyboard Here
The c program calculates geometric mean, average mean and harmonic mean using their respective formulas. It simply applies these formula on the given input to calculate and print the result.
In this, we are using following formula directly in the code:
Write a program that reads a series of n numbers and calculates the average, geometric and harmonic mean of n elements in an array in c
C program to find the largest number in an array
How to find max value in an array?
Algorithm to get max value: we assume that it's present at the beginning of the array.
Write a C program to find out which number is even or odd from list of 10 number using array
C program to count the total number of even and odd elements in an array. In this post, we will brief in on the numerous methods to count the total number of even and odd elements in an array in c programming.
Write a C program to read and store the roll no and marks of 20 students using array
Define a structure, student, to store the following data about a student:
Roll number (int), Marks (int)
Write a C program to evaluate the series sum=1-x+x^2/2!-x^3/3!+x^4/4!......-x^9/9!
Lets write a C program to add first seven terms of the following series 1+1/2!+1/3!+1/4!+.....+1/n!
We’ve also written the C program to ask the user to enter the number of terms of the series that has to be added. You can find code to both of it below.
C Program To Find Sum of Series 1+1/2!+1/3!+1/4!+.....+1/n!
Program to sum of series 1+1/2+1/3+1/4+....+1/n
In this program, if inverse of a sequence follow rule A.P i.e , Arithmetic progression, then it is said to be in harmonic progression can be denoted:
Program to evaluate the series 1^2+2^2+2+3^2+……+n^2
Here is source code of the C Program to Find the Sum of Series 1^2 + 2^2 + …. + n^2. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
C Program to check whether a number is prime or not
In this example, you will learn to check whether an integer entered by the user is a prime number or not.
Program to read five person height and weight:
Program to read five persons height and count the number of person having height greater than 170 and weight less than 50 using c programming
Write a program to calculate average and total of 5 students for 3 subjects (use nested for loops)
This program helps the user to enter five different values for five subjects. And then this c program calculate the Total, Average, and Percentage of those Five Subjects.
Write a C program to find the sum and average of different numbers which are accepted by user as many as user wants
In this program sum and average of the given number are calculated using while.
Write a C program to find product of digits of a number using while loop.
Write a C program in C to multiply the digits of a number.
C program to find fibonacci series for first n terms:
This C Program calculate the Fibonacci numbers in the series. The first two numbers in the Fibonacci sequence are 0 and 1 and each subsequent number is the sum of the previous two.
This program reverse the number entered by the user, and then prints the reversed number on the screen.
C Program to find factorial of a number
In this program, we will read and integer number and find the factorial using different methods - using simple method (without using user define function), using User Define Function and using Recursion.
What is factorial?
Program to check Even or Odd:
In this question, you will learn to check whether a number entered by the user is even or odd.
Program to find maximum and minimum element in array.
Write a C program to find out the Maximum and Minimum number from given 10 numbers.
As we all know, arrays are a collection of a bunch of elements in a sequential pattern in a horizontal direction. Arrays form a very important of C programming.
C Program to Print Day Name of Week using Else If
How to write a C Program to Print Day Name of Week using Else If statement, and Switch Condition with examples.
Given the following constrains and we have to calculate net salary of an employee.
C program to read and print an Employee’s Details using Structure.
Marks Grade
100-80 Distinction
79-60 First class
59-40 Second class
< 40 Fail
Program to calculate grade according to marks:
Grade mark in c program:
Write a program to read marks from keyboard and your program should display equivalent grade according to following table (if else ladder).
Write a C program to input a character from user and check whether given character is alphabet, digit or special character using if else. How to check if a character is alphabet, digits or any other special character using if else in C programming. Logic to check alphabet, digit or special character in C programming.
Write a C program to find maximum between three numbers using nested if else or nested if. How to find maximum or minimum between three numbers using if else in C programming. Logic to find maximum or minimum between three numbers in C program.
Write a c program to find the largest number among three numbers. You will learn to find the largest number among three numbers.
C program to check student is pass or fail:
The C program to display student results demonstrates the working of conditional statement in the C language.
Write a C program to check positive, negative or zero using simple if or if else. C program to input any number from user and check whether the given number is positive, negative or zero. Explain, how to find that the accepted number is negative, positive or zero in C programming.
Calculate total distance traveled by a vehicle in ' t ' seconds is given by distance.
Formula of distance:
d = ut+at^2
Where, ' u ' is the initial velocity ( meter per second ), ' a ' is the acceleration. Write a program to evaluate the distance travelled at regular intervals of time, given the value of ' u ' and ' a '. The program should provide the flexibility to the user to select his own time intervals and repeat the calculations for different values of ' u ' and ' a '.
Given below is a C program to find out distance travelled by the upper equation:
C program to convert Celsius to Fahrenheit:
Here, we learn how to write a C program to convert Fahrenheit from centigrade?. We will write the C program to convert Fahrenheit from centigrade. Write a C program to input temperature in Fahrenheit and convert it to centigrade. How to convert temperature from degree Fahrenheit to degree centigrade in C programming. Logic to convert temperature from Fahrenheit to centigrade in C.
In this c program, we will convert distance input by the user in meters, feet, inches, and centimeters. We will also write the algorithm of c program to convert distance in meters, feet, inches, and centimeters. We will firstly breakdown the problem and write an algorithm, then after that, we will write the c program and obtain the required output.
We need to take distance (in kilometers) from the user in kilometers and then convert it into meters, feet, inches, and centimeters and display as an output on the screen.
Given below is a C program to convert km in feet, meter, inch, cm:
C program to swap two numbers:
C program to interchange two numbers. Swapping means interchanging. If the program has two variables a and b where a = 1 and b = 2, after swapping them, a = 2, b = 1. In the first C program, we use a temporary variable to swap two numbers.
Logic to calculate simple interest:
Write a program to calculate simple interest. How to calculate simple interest in C programming
Write a C program to input base and height of a triangle and find area of the given triangle. How to find area of a triangle in C programming. Logic to find area of a triangle in C program.
C Program to find Area Of a Triangle using base and height
This program allows the user to enter the base and height of a triangle, and then finds the area of a triangle using those two values
In this, we will discuss C Program to Addition Subtraction, Multiplication and division:
In this post, we will learn about how to perform addition, subtraction multiplication, division of any two numbers using if else statements in c programming.
Loading latest videos...
ABOUT
I could look back at my life and get a good story out of it. It's a picture of somebody trying to figure things out.
POPULAR POSTS
Archive
- May 20261
- November 20251
- February 20241
- January 20242
- November 20234
- October 20236
- September 20236
- August 20235
- April 20231
- March 20231
- October 20221
- August 20223
- July 20222
- May 20223
- April 20222
- March 20221
- January 20221
- December 20216
- November 20214
- October 20211
- September 20216
- August 202127
- July 20216