Questions tagged as 'c'

1
answer

Recursion problem, C language

I have a problem, in a code that I found in that it receives a user string and returns it inverted, doing so in a recursive way. However, I do not understand why the function actually does this. Follow the code: #include <stdio.h>...
asked by 01.03.2018 / 20:38
1
answer

Traversing an array using malloc

In the course of some questions here in the OS I saw this example and I had doubts. #include<stdio.h> #include<stdlib.h> #include<conio.h> void main() { clrscr(); int *ptr,*temp; int i; ptr = (int *)malloc(4*sizeof(int)); t...
asked by 15.02.2018 / 18:27
1
answer

Error when displaying results - URI 1566 [closed]

I have made a request in the URI problem 1566 statement, but it is giving presentation error, and I do not know how to fix it. Here is my code: #include <stdio.h> #include <stdlib.h> int ordena(const void *a, const void *b);...
asked by 20.02.2018 / 02:25
1
answer

Order Growth

I needed help figuring out the correct calculation of the growth order of this code excerpt (function of N = 2 ^ M) int sum=0; for (int i = 0; i < = N; i++) for(j = 1; j <= N; j++) for(k = 1; k <= N; k=k+j) sum++; T...
asked by 25.01.2018 / 09:51
2
answers

What does while (x--) mean in C language?

I came across this code and I did not understand the while(a--) loop, what does it mean? int main(){ char pisca[10], a = 3; short numero; while(a--){ numero = 0; while(1){ scanf("%s caw",...
asked by 08.04.2018 / 05:53
1
answer

How to dynamically allocate a string

Well, I wanted to dynamically allocate multiple names in c, I already know how to do just normal but I want to show it here in the code #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { char *nome; nome...
asked by 08.04.2018 / 16:22
2
answers

Program Ignoring Scanf

I need to create an algorithm as a request below, however, every time I run the program it "skips" steps. For example: I want you to stay like this Product: "Potato" Sector: "Food" Quantity: "15" Price: "15.23" But it prints on...
asked by 13.05.2018 / 22:12
1
answer

Switch command does not work and does not display errors

I am trying to solve the following exercise: Elaborate an algorithm that assists in the control of a cattle farm that has a total of 2000 head of cattle. The database is formed by a set of structures (records) containing the following fields for...
asked by 12.05.2018 / 02:57
1
answer

What is the error in this activity in c

I need the negative values entered by the user not to enter the calculation, and also that this negative insertion is canceled by the program. The statement reads as follows:    A city council has conducted a survey among its inhabitants,...
asked by 19.12.2017 / 19:27
1
answer

Doubt with the ternary operator [duplicate]

What does the following expression mean: struct Node *temp = root->left ? root->left : root->right; I am in doubt if he is checking for the root->left pointer or comparing *temp with root->left , in whic...
asked by 12.12.2017 / 22:10