Navigation

    ask avan logo
    • Register
    • Login
    • Search
    • Categories
    • Unsolved
    • Solved
    Log in to post
    • All categories
    • Coding Question & Answers
    •      Javascript + jQuery
    •      Java
    •      PHP
    •      Ruby on Rails
    •      Hosting
    •      Git and Github
    •      Linux
    •      Domain Names and DNS
    •      Coding Tools
    •      HTML CSS
    •      Bootstrap
    •      Node.js + Express
    •      React.js
    •      Angular.js
    •      Python
    •      Spreadsheet Macros
    •      Android
    •      C#
    •      C++
    •      C
    •      Algorithm
    •      General Software / App
    • All Topics
    • New Topics
    • Watched Topics
    • Unreplied Topics

    • Padala Vamsi ujpNQUXGRi

      SOLVED Finding minimum length of tape required.
      Algorithm • • Padala Vamsi ujpNQUXGRi  

      5
      5
      Posts
      46
      Views

      Padala Vamsi ujpNQUXGRi

      Sorry, I am a full time employee, I'm little busy with work this week. Your solution may work. In codeproject some one answered the question and it seems to work. Thank you for replying to my question.

    • Charles Craft50

      SOLVED Create a console application in C# that accepts three (3) programmer-defined values and save them to an array.
      C# • • Charles Craft50  

      2
      2
      Posts
      157
      Views

      avan

      I think they just want you to initialize an array add three values to it. Here is how you can initialize an array and add values to it.

      Method 1:

      int[] arr = new int[5] arr[0] = 1; arr[1] = 2; arr[2] = 3;

      Method 2:

      int[] arr =new int[5] { 1, 2, 3 };

      https://www.completecsharptutorial.com/basic/storing-values.php

      Here 1,2,3 are programmer-defined the values

      I am not a C# sharp developer so I don't know how to create a console application. I found the following article that might need help get started in case you are confused about that part:

      https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio-code

      The only part I can't figure out if the one-line instructions above is asking for the values to be inputted through the command prompt. In that case you can use args in the main method to retrieve the command line arguments. The following article should have more info and even some examples.

      https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/main-and-command-args/command-line-arguments

      I hope this helps in some way.

    • Sana Fatima

      UNSOLVED I need a code. Please help me its urgent as I am new to coding and can't solve in 1 day :(
      Coding Question & Answers • • Sana Fatima  

      2
      2
      Posts
      67
      Views

      avan

      Hi @Sana-Fatima

      What programming language are you suppose to program this in? Is there any more information? The instructions above seem somewhat ambiguous.

    • Rachel O

      SOLVED Argument for getc to check for EOF is not working.
      C • • Rachel O  

      4
      4
      Posts
      86
      Views

      avan

      Hey @Rachel-O

      I finally figured it out. Sorry, it took me a while. I am not a C developer. But anyways, I have the answer in video format. Check it out. I also included the code down below in case you don't want to watch the video version and just want the answer.

      Let me know if you have any questions or if I can be of further help.

      #include <stdio.h> #include <stdlib.h> #include <string.h> // Include boolean #include <stdbool.h> int main(int argc, char *argv[]) { // Global variables FILE *input, *output; char c; int sentenceCounter=1,wordCounter=0; // Will be set to true whenever we encounter a period bool newSentence = true; // Make sure input and output files are specified if (argc < 3) { fprintf (output, "\nCorrect usage is: ./mimir.out <name of input file> <name of output file>\n\n"); exit(EXIT_FAILURE); } // Make sure we can open input file if((input = fopen(argv[1], "r")) == NULL) { fprintf (output, "\nUnable to open input file \"%s\".\n\n", argv[1]); exit(EXIT_FAILURE); } // Let's start the process else { // Open output stream output=fopen(argv[2],"w"); // START READING INPUT FILE HERE c = getc(input); // As long as we have not reached the end of the input file while (c != EOF) { // New line marker? if(newSentence){ fprintf (output, "Sentence # %d\n",sentenceCounter++); fprintf (output, "--------------------------------------------------------------------------------\n"); newSentence = false; } // Process a single word while (c != ' ' && c != '\n' && c != ',' && c != '.'){ fprintf(output,"%c", c); c = getc(input); } // We have reached a new line, comma, space or period. So a new word. wordCounter++; // Period encountered. Set new sentence marker if(c == '.'){ newSentence = true; fprintf(output,"\n\n"); } // Have we reached 10 words yet? If so hit a new line. No comma needed. if(wordCounter == 10){ fprintf(output,"\n"); } // Otherwise comma is needed. else if(c == ' ' || c == ',' || c == '\n'){ fprintf(output,", "); } // Reset word counter? if(newSentence || wordCounter == 10){ wordCounter = 0; } // Consume empty space, period, comma and new line while (c == ' ' || c == '.' || c == ',' || c == '\n'){ c = getc(input); } } // End while c != EOF } fclose(input); return 0; }
    • KNV

      UNSOLVED DATA STRUCTURES IN C
      C • • KNV  

      1
      1
      Posts
      53
      Views

      No one has replied

    • Shavy Gaming

      SOLVED Write algorithms to add and delete elements from either end of the deque.
      C • • Shavy Gaming  

      2
      2
      Posts
      569
      Views

      avan

      Hey @Shavy-Gaming

      I don't know C but with a little bit of googling I was able to find a Java implementation of a deque using a one-dimensional array.

      Here is the link:

      https://codereview.stackexchange.com/questions/120722/array-based-deque-in-java

      Here is the solution found on the page. You might be able to understand it enough to implement a C version of it. Keep in mind the main method just tests the Deque in this case. Good luck!

      import java.util.NoSuchElementException; import java.util.Random; public class Deque { private final int arr[]; private int head; private int size; public Deque(int capacity) { arr = new int[capacity]; } public void addLast(int element) { checkCapacity(); arr[(head + size++) % arr.length] = element; } public void addFirst(int element) { checkCapacity(); if (head == 0) { arr[(head = arr.length - 1)] = element; } else { arr[(--head) % arr.length] = element; } size++; } public int removeFirst() { checkNotEmpty(); int ret = arr[head]; head = (head + 1) % arr.length; size--; return ret; } public int removeLast() { checkNotEmpty(); int ret = arr[(head + size - 1) % arr.length]; size--; return ret; } @Override public String toString() { StringBuilder sb = new StringBuilder("["); for (int i = 0; i < size; ++i) { sb.append(arr[(head + i) % arr.length]); if (i < size - 1) { sb.append(", "); } } return sb.append("]").toString(); } public int size() { return size; } private void checkCapacity() { if (arr.length == size) { throw new IllegalStateException("No more space is available."); } } private void checkNotEmpty() { if (size == 0) { throw new NoSuchElementException("Trying to pop an empty deque."); } } public static void main(String args[]) { Deque deque = new Deque(10); Random random = new Random(); for (int op = 0; op < 30; ++op) { if (deque.size() == 0) { int num = random.nextInt(100); System.out.print("Adding " + num + " to front: "); deque.addLast(num); System.out.println(deque); } else { boolean add = random.nextBoolean(); if (add) { boolean front = random.nextBoolean(); int num = random.nextInt(100); if (front) { System.out.print("Adding " + num + " to front: "); deque.addFirst(num); System.out.println(deque); } else { System.out.print("Adding " + num + " to back: "); deque.addLast(num); System.out.println(deque); } } else { boolean front = random.nextBoolean(); if (front) { System.out.print("Removing from front: "); deque.removeFirst(); System.out.println(deque); } else { System.out.print("Removing from back: "); deque.removeLast(); System.out.println(deque); } } } } } }
    • Ankit Chauhan

      UNSOLVED Cannot install pip install pyaudio in Python
      Python • • Ankit Chauhan  

      1
      1
      Posts
      108
      Views

      No one has replied

    • Devatha Naga Puneeth

      UNSOLVED Getting segmentation error in merging two sorted linked list
      C++ • • Devatha Naga Puneeth  

      1
      1
      Posts
      51
      Views

      No one has replied

    • Pardheev Kanti

      UNSOLVED Operating Systems
      Linux • • Pardheev Kanti  

      1
      1
      Posts
      50
      Views

      No one has replied

    • S

      SOLVED Using Mysql results to populate html
      Javascript + jQuery • ejs javascript mysql • • sequelman  

      10
      10
      Posts
      87
      Views

      S

      Now I can add the 20 other fields in need in that form. 😁

      Thanks again for your help I really appreciate it.

    • MPG Radio

      UNSOLVED Switch statement php
      PHP • php • • MPG Radio  

      5
      5
      Posts
      67
      Views

      avan

      What about an if statement within each switch case?

      switch ($date) { case 'Jan': $content = "Dahnus"; if(CONDITION HERE) { EXECUTE CODE HERE } //$content = " Pisces"; //$content = " Aries"; break; case 'Feb':
    • locus jim

      UNSOLVED Why the note pages can't show up and can't sync
      Android • • locus jim  

      3
      3
      Posts
      60
      Views

      avan

      Wish I could help @locus-jim

      but I am not great at android.

    • Miracle Seriki

      UNSOLVED Please I'm trying to spend woocommerce order to another website using api, this the code I'm using but it doesn't work pls help me
      PHP • • Miracle Seriki  

      2
      2
      Posts
      55
      Views

      avan

      Hey @Miracle-Seriki

      I tried to look into your problem but it's hard to figure out what exactly is wrong unless I can re-create the problem or at least see what error message you are receiving.

    • Ayush Gwari 0

      SOLVED Pattern problem
      Coding Question & Answers • • Ayush Gwari 0  

      3
      3
      Posts
      71
      Views

      Ayush Gwari 0

      Hey thanks avan for clearing my doubt regarding this problem and special thanks for explaining the solution very clear in video format.

    • I

      SOLVED hey avan can you teach me how to deobfuscate this javascript code to make it readable again ?
      Javascript + jQuery • • imnoob  

      2
      2
      Posts
      61
      Views

      avan

      Hey @imnoob

      Took me a long time but here you go 🙂

      https://codepen.io/avansardar/pen/zYrgmJb?editors=0010

    • Mying Humtsoe

      SOLVED can anyone one help me know to solve this...i am new to coding and i really confused.
      Coding Question & Answers • • Mying Humtsoe  

      3
      3
      Posts
      287
      Views

      Mying Humtsoe

      @avan thank you so much sir from the deepest of my heart, i have spent days trying to find answer to this problem and googling for solution but failed and i wanted to give up, you are a life saver 😥 😭

    • Alan Daniel

      SOLVED Matlab : How can I automatically let Matlab input the file in sequence?
      Coding Question & Answers • • Alan Daniel  

      5
      5
      Posts
      67
      Views

      Alan Daniel

      Thanks a lot. You are brillant!

    • Alan Daniel

      SOLVED How to retrieve data from a specific REST endpoint. (prefer using Python)
      Python • • Alan Daniel  

      5
      5
      Posts
      90
      Views

      Alan Daniel

      @avan said in How to retrieve data from a specific REST endpoint. (prefer using Python):

      equests.get(url = URL)

      extracting data in json format

      data = r.json()

      Get value for blobJson

      blobJson = data[0]["blobJson"]

      Convert string to list

      yes, thanks! it works well!

    • Alan Daniel

      UNSOLVED How to store a retrieved data in a database of my choice in my laptop using Python?
      Python • • Alan Daniel  

      1
      1
      Posts
      56
      Views

      No one has replied

    • MPG Radio

      UNSOLVED Exclude Text from the out put using printf
      PHP • • MPG Radio  

      1
      1
      Posts
      65
      Views

      No one has replied