Server Side Programming Articles - Page 2067 of 2650

Reverse a link list using stack in C++

Ajay yadav
Updated on 29-Nov-2019 10:59:50

219 Views

Linked list allocates memory dynamically, is used to implement a stack. This program showcase the reversal of the link list in c++ programming. Here, the aspirant can adopt the following approach to get the expected results. The algorithm is as follows;AlgorithmSTART    Step 1: create an empty stack of type node pointer    Step 2: Traverse the list and push all of its nodes onto a stack    Step 4: Traverse the list from the head node again    Step 5: pop a value from the stack top    step 6: connect them in reverse order    Step 7: PRINT ... Read More

Replacing space with a hyphen in C++

Ajay yadav
Updated on 29-Nov-2019 10:55:18

2K+ Views

In this C++ program, the space in the string will be replaced with the hyphen. Firstly, the length of the string is determined by the length() function of the cstring class, then hyphen is filled into the space of the sentence by traversing the string as follows.Example Live Demo#include #include using namespace std; int main(){    // raw string declaration    string str = "Coding in C++ programming";    cout

Sqrt, sqrtl, and sqrtf in C++ programming

Ajay yadav
Updated on 29-Nov-2019 10:52:02

293 Views

Math ClassThis article demonstrates the usage of math class essentials functions sqrt(), sqrtl(), and sqrtf() to calculate the square root of double, long, and float type variables with precision respectively. The Math class of C++ offers a wide range of functions to calculate mathematical calculations including sin, cos, square root, ceil, floor, etc..It is, therefore, mandatory to import the definition of header class library in the program in order to avail all calculative methods.Sqrt MethodThe double sqrtl () method of the Math class returns the square root of a double variable with precision. The syntax of this function is ... Read More

String at () in C++

Ajay yadav
Updated on 29-Nov-2019 10:46:04

585 Views

AbstractThis short tutorial is an overview of the C++ String class at() functionality in order to access a sequence of characters from the string. In the forthcoming section, an aspiring reader can through string class programming examples to get a thorough understanding of the manipulation of at() functions.String ClassIn programming terms, the strings are typical, a double-quotes representation, contain a collection of characters. The string class is a container class too, to iterate over all its characters using an iterator operator []. Besides, The String class handles all operations related to memory and null termination. Anyone can perform plenty of ... Read More

Swap Upper diagonal with Lower in C++

Ajay yadav
Updated on 29-Nov-2019 10:42:25

326 Views

This tutorial is designed to swap the upper row of a three-diagonal array to its lower one using c++ code. Moreover, if a three-diagonal array is an input, the coveted results must be something like that as;For this, the course of action is briefed in the algorithm as follows;AlgorithmStep-1: Input a diagonal array Step-2: Pass it to Swap() method Step-3: Traverse the outer loop till 3 Step-4: increment j= i+ 1 in the inner loop till 3 Step-5: put the array value in a temp variable Step-6: interchange the value arr[i][j]= arr[j][i] Step-7: put the temp data to arr[j][i] Step-8: ... Read More

Toggle all characters in the string in C++

Ajay yadav
Updated on 29-Nov-2019 10:38:12

945 Views

This program translates the characters of a string into uppercase. However, this task can be easily achieved by using the toUpper() method of the c++ class library. But in this program, we perform this by calculating the ASCII value of characters in uppercase. The Algorithm is as follows;AlgorithmSTART    Step-1: Declare the array of char    Step-2: Check ASCII value of uppercase characters which must grater than A and lesser than Z    Step-3: Check ASCII value of lower characters which must grater than A and lesser than Z ENDThe toggleChar() method gets the array of characters as an input. ... Read More

Write a program for Happy Woman’s Day in c++

Ajay yadav
Updated on 29-Nov-2019 10:35:27

465 Views

The woman day which is celebrated on 7th October worldwide is carved into a c++ programming code as following;Example#include using namespace std; int main(){    // Initializing size of    // design    int n = 5;    // Loop to print Circle    // (Upper part of design)    // Outer loop to    // control height of    // design    for (int i = 0; i

Getting File Information in Perl

Mohd Mohtashim
Updated on 29-Nov-2019 10:29:21

624 Views

You can test certain features very quickly within Perl using a series of test operators known collectively as -X tests. For example, to perform a quick test of the various permissions on a file, you might use a script like this −#/usr/bin/perl my $file = "/usr/test/file1.txt"; my (@description, $size); if (-e $file) {    push @description, 'binary' if (-B _);    push @description, 'a socket' if (-S _);    push @description, 'a text file' if (-T _);    push @description, 'a block special file' if (-b _);    push @description, 'a character special file' if (-c _);    push @description, ... Read More

Positioning inside a File in Perl

Mohd Mohtashim
Updated on 29-Nov-2019 10:24:09

352 Views

You can use to tell function in Perl to know the current position of a file and seek function to point a particular position inside the file.Perl tell FunctionThe first requirement is to find your position within a file, which you do using the tell function −tell FILEHANDLE tellThis returns the position of the file pointer, in bytes, within FILEHANDLE if specified, or the current default selected filehandle if none is specified.Perl seek FunctionThe seek function positions the file pointer to the specified number of bytes within a file −seek FILEHANDLE, POSITION, WHENCEThe function uses the fseek system function, and you have ... Read More

Copy, Rename and Delete Files in Perl

Mohd Mohtashim
Updated on 29-Nov-2019 10:22:33

2K+ Views

Here is the Perl example, which opens an existing file file1.txt and read it line by line and generate another copy file file2.txt.#!/usr/bin/perl # Open file to read open(DATA1, "file2.txt"); # Copy data from one file to another. while() {    print DATA2 $_; } close( DATA1 ); close( DATA2 );Renaming a fileHere is the Perl example, which shows how we can rename a file file1.txt to file2.txt. Assuming file is available in /usr/test directory.#!/usr/bin/perl rename ("/usr/test/file1.txt", "/usr/test/file2.txt" );This function renames takes two arguments and it just renames the existing file.Deleting an Existing FileHere is an example, which shows how ... Read More

Advertisements