Programmator
Programmator
  • Home
  • Download
  • Social
    • YouTube
    • Instagram
    • Facebook
    • Telegram
  • Features
    • C/C++
    • Java
  • Contact Us
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

  1. Define a string.
  2. Determine the character 'ch' through which spaces need to be replaced.
  3. 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

Newer Posts Older Posts Home

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.

SUBSCRIBE & FOLLOW

POPULAR POSTS

  • Software Project Management - 3171609 - WINTER 2022 GTU Paper Solution
  • Write a program to that performs as calculator (Addition, Multiplication, Division, Subtraction)
  • Write a java program to display Fibonacci series
  • Write a program for sorting using pointer
  • Write a java program to find GCD of two numbers
Powered by Blogger

Archive

  • 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

Report Abuse

Copyright

  • Home

About Me

Nilesh Patel
View my complete profile

Copyright © Programmator. Designed by ProbleSolvable