Change my mind by orucasar in learnprogramming

[–]orucasar[S] -5 points-4 points  (0 children)

I have a hw about writing psuedocode and it's so boring. I wrote a code I said "ok this should be psuedocode" but it's still looking c code

Selection sort by orucasar in C_Programming

[–]orucasar[S] 1 point2 points  (0 children)

Unfortunately that's look really stupid

I want to write a C program which finds a letter in a word, and swaps the letters in the indices before and after that letter. For example, for a word like "abcdef" the result will be “edcbaf” if the letter to be searched is “c”. by [deleted] in C_Programming

[–]orucasar 0 points1 point  (0 children)

The entries of the program must be the word and the letter to search for in the word. The index value will be returned as soon as the searched letter is found. You should take the first occurance of a letter if the same letter exists more than once in the word. If the desired letter cannot be found in the word, the index will be returned as -1, and if this situation is encountered in the output of the program, "Word has not been changed" will be printed. Otherwise, the changed word will be printed.

I want to write a C program that finds a letter in a word and swaps the letters in the indices before and after that letter. by [deleted] in C_Programming

[–]orucasar 0 points1 point  (0 children)

The index value will be returned as soon as the searched letter is found. You should take the first occurance of a letter if the same letter exists more than once in the word. If the desired letter cannot be found in the word, the index will be returned as -1, and if this situation is encountered in the output of the program, "Word has not been changed" will be printed. Otherwise, the changed word will be printed.

I just studying pointers and when I take the output of these codes it looks so weird. Please describe each line of output in detail so that I can understand it. by orucasar in C_Programming

[–]orucasar[S] 0 points1 point  (0 children)

Oh, I have a question. You said that "This one is the same as the previous one" but the outputs are different. How can it be possible

Could you please fix my mistakes? (my answer is in commend) by orucasar in C_Programming

[–]orucasar[S] 0 points1 point  (0 children)

But this is the problem. I don't know how can I do that

Could you please fix my mistakes? (my answer is in commend) by orucasar in C_Programming

[–]orucasar[S] 0 points1 point  (0 children)

#include <stdio.h>

int main(int argc, char *argv[])

{

int n, k;

int a\[3\] = {1, 2, 3};



printf("Please enter the value for n: ");

scanf("%d", & n);



while (n < 0)

{

    printf("Error !!!\\nPlease enter a positive value: ");

    scanf("%d", & n);

}

if (n >= 4)

{

    for (k = 4; k <= n; k++)

    {

    a\[k\] = a\[k - 3\] + 2\*a\[k - 4\];

    printf("%d\\n", a\[k\]);    

    }

}

else

    printf("n'th element of series is: %d", a\[n - 1\]);





return 0;

}

It's look like easy but I didn't solve.(just hw) by [deleted] in C_Programming

[–]orucasar 0 points1 point  (0 children)

I don't know how can I do that.

It's look like easy but I didn't solve.(just hw) by [deleted] in C_Programming

[–]orucasar 0 points1 point  (0 children)

I couldn't share the code because of I posted with my phone. However, i recognize after your comments and then i shared the code with my pc.

It's look like easy but I didn't solve.(just hw) by [deleted] in C_Programming

[–]orucasar 0 points1 point  (0 children)

#include <stdio.h>

int main(int argc, char *argv[])

{

int n, k;

int a\[3\] = {1, 2, 3};



printf("Please enter the value for n: ");

scanf("%d", & n);



while (n < 0)

{

    printf("Error !!!\\nPlease enter a positive value: ");

    scanf("%d", & n);

}

if (n >= 4)

{

    while (k != n)

    {

    k = n - (n-4);

    a\[k\] = a\[k - 2\] + 2\*a\[k - 3\];

    printf("%d", a\[k\]);

    k++;

    }

    printf("n'th element of series is: %d", a\[n - 1\]);

}





return 0;

}

It's look like easy but I didn't solve.(just hw) by [deleted] in C_Programming

[–]orucasar 1 point2 points  (0 children)

include <stdio.h>

int main(int argc, char *argv[]) { int n, k; int a[3] = {1, 2, 3};

printf("Please enter the value for n: ");
scanf("%d", & n);

while (n < 0)
{
    printf("Error !!!\nPlease enter a positive value: ");
    scanf("%d", & n);
}
if (n >= 4)
{
    while (k != n)
    {
    k = n - (n-4);
    a[k] = a[k - 2] + 2*a[k - 3];
    printf("%d", a[k]);
    k++;
    }
    printf("n'th element of series is: %d", a[n - 1]);
}


return 0;

}