Blog Page 2

C Program to Implement Stack

This C Program implements stack. Stack is an area of memory that holds all local variables and parameters used by any function, and remembers the order in which functions are called so that function returns occur correctly. Each time a function is called, its local variables and parameters are “”pushed onto”" the stack. When the function returns, these locals...

C Program to solve Knapsack Problem using Greedy Algorithm

C Program to solve Knapsack Problem using Greedy Algorithm : Below you can find how to implement knapsack problem using greedy method. What actually Problem Says ? Given a set of items, each with a weight and a value. Determine the number of each item to include in a collection so that the total weight is less than a given limit and...

C Program to Read a String of Text from File

C Program to Read a String of Text from File : This program reads the content of program.txt file and stores it in a string c if of this file and this c program is same and the name of file matches but, if this there is no file named program.txt then, this program displays Error! opening file and...

C Program to Store Information Using Structures with Dynamic Memory Allocation

C Program to Store Information Using Structures with Dynamic Memory Allocation : This program asks user to store the value of n and allocates the memory for the n structure variable dynamically using malloc() function. C Program to Store Information Using Structures with Dynamic Memory Allocation : #include <stdio.h> #include<stdlib.h> struct name { int a; char c; }; int main(){ ...

C Program to Remove all Characters in a String Except Alphabet

This program takes a strings from user and removes all characters in that string except alphabets. This program takes a string from user and for loop executed until all characters of string is checked. If any character inside a string is not a alphabet, all characters after it including null character is shifted by 1 position backwards. C Program to...

C Program to Store Information of a Student Using Structure

In this program, a structure(student) is created which contains name, roll and marks as its data member. Then, a structure variable(s) is created. Then, data (name, roll and marks) is taken from user and stored in data members of structure variable s. Finally, the data entered by user is displayed. C Program to Store Information of a Student Using Structure: #include...