Sudhir sharma has Published 1206 Articles

Write a bash script to print a particular line from a file in C

sudhir sharma

sudhir sharma

Updated on 17-Jul-2020 10:50:06

239 Views

In this program, we are given a file name text.txt. Our task is to print a particular line from the file.For this there are multiple methods in bash script, they are awk, sed, head.Syntax$> awk ‘{if(NR==LINE_NUMBER) print $0}’ filename $> sed -n LINE_NUMBERp filename $head -n LineNumber filename | tail ... Read More

Write a C program that displays contents of a given file like 'more' utility in Linux

sudhir sharma

sudhir sharma

Updated on 17-Jul-2020 10:48:40

179 Views

Here, we will write a C program that will display the contents of a file page by page as displayed in Linux using the more command.This program will show a specific number of lines on the screen first and then wait for the user to hit enter to move to ... Read More

Write a C program that won’t compile in C++

sudhir sharma

sudhir sharma

Updated on 17-Jul-2020 10:33:40

159 Views

Here, we will write some c programs that won’t compile in c++. Though c++ is considered as a successor of c that has all its features and has compatibility with c code there are some programs that won’t compiler or given a compilation error when compiled with c++ compiler.A list ... Read More

Write a program to print ‘Tutorials Point’ without using a semicolon in C

sudhir sharma

sudhir sharma

Updated on 15-Jul-2020 06:40:59

153 Views

In this problem, we have to write a program that will print ‘Tutorials Point ’ without using a semicolon.We all know that to end a statement in c semicolon is necessary. And print statement will be executed when a semicolon is added at the end.So, for printing ‘Tutorials point’ without ... Read More

Write a C program to print ‘ABCD’ repeatedly without using loop, recursion and any control structure

sudhir sharma

sudhir sharma

Updated on 15-Jul-2020 06:31:02

146 Views

In this problem, we have to write a program in c that will print a string ‘ABCD’ repeatedly without using loop, recursion and any control structure.So, we will have to call or run the same block of code infinite time but without using loop, recursion or control structure which are ... Read More

Write a function that counts the number of times a given int occurs in a Linked List in C++

sudhir sharma

sudhir sharma

Updated on 15-Jul-2020 06:26:14

336 Views

In this problem, we are given a linked list. Our task is to create a function that will be able to count the number of times a given number occurs in the linked list.Let’s take an example to understand the problem, InputLinked list = 10-> 50 -> 10 -> 20 ... Read More

Write a function that generates one of 3 numbers according to given probabilities in C++

sudhir sharma

sudhir sharma

Updated on 15-Jul-2020 06:23:43

265 Views

In this problem, we have to create a function that will generate three numbers based on the given probability.For this, we will use the built-in random number generator function which is rand(a, b) which generates random numbers within the range [a, b] with equal probability.Our task is to return only ... Read More

Write a function to delete a Linked List in C++ Programming

sudhir sharma

sudhir sharma

Updated on 15-Jul-2020 06:21:31

556 Views

Here, we will create a function that will delete all elements of a linked list one by one.In c/c++, there is no specific function to perform this task but in java, the automatic garbage collection is done to ease deleting linked list.Now, let’s see the implementation of this program, Example Live ... Read More

Print all palindromic paths from top left to bottom right in a matrix in C++

sudhir sharma

sudhir sharma

Updated on 14-Jul-2020 07:36:48

130 Views

In this problem, we are given a matix which contains aplhabets (lowercase only) and we have to print all palidromic paths in the given matrix from top left to bottom right of the matrix.Allowed moves in this problem are right and down. Diagonal moves are not allowed.Let’s take an example ... Read More

Print all palindromic partitions of a string in C++

sudhir sharma

sudhir sharma

Updated on 14-Jul-2020 07:35:42

114 Views

In this problem, we are given a palindromic string. And we have to print all the partitions of this string. In this problem, we will find all possible palindrome partitions of the string by cutting it.Let’s take an example to understand the problem -Input − string = ‘ababa’Output − ababa ... Read More

Advertisements