Questions tagged as 'c'

1
answer

Only 2 houses after the comma

I need the final result to show the whole number and 2 boxes after the comma. Can you filter, say so, not to show all decimal places? #include <stdio.h> #include <math.h> int main() { float r, resp; // declara variavel...
asked by 07.12.2016 / 22:41
1
answer

I can not print, in the main function, values coming from a vector created in another function received by a double pointer

The following source code is the miniaturization of a major problem that I am working on, and I have not been able to solve the problem for two days. I need to print the values of the vector generated by the "makeVector" function, in the "mai...
asked by 03.06.2018 / 21:05
1
answer

Passing data from a struct within the function

To do a college job where I have a separate function that gets two values (WEIGHT and HEIGHT) and returns the BMI. I also have a struct called ALUNO where weight and height are stored and a vector of 20 positions that will store the structure...
asked by 26.05.2018 / 04:51
1
answer

Store the positives in one vector and the negatives in another

   Make an algorithm that reads a set of 30 integer numeric values and distributes them between two vectors, separating the positive numbers from the negative ones. The vectors must have 30 positions each. Show the vectors at the end of processi...
asked by 28.07.2018 / 22:59
1
answer

Loop is within loop for

for(pass = 0; pass < size - 1; pass++){ for(j = 0; j < size - 1; j++){ if(array[j] > array[j + 1]){ swap( &array[j], &array[j + 1]); } } } I just put a piece of code where I have a doubt...
asked by 18.01.2017 / 03:08
2
answers

Find even and odd in float language variable C

There are some errors in my program when I try to find the odd and even of a float variable. #include<stdio.h> #include<string.h> void exe7(float vet[]){ int i; for(i=0;i<5;i++){ scanf("%f",&vet[i]); }...
asked by 14.07.2017 / 15:26
1
answer

How to add the diagonal of an array in C?

Help me in the following exercise: Make a program that defines an array of 5x5 size integers. Then, initialize this array with random numbers between 5 and 9. Finally, your program must calculate the sum of the diagonal elements of that matri...
asked by 05.05.2016 / 01:05
2
answers

Function scanf with variable amount of parameters, how to implement?

I have a text file (txt) that contains the following values: 12 90 These two values I keep and my variables a and b , that is a is equal 12 and b is equal 90 , and I'm using scanf() function to...
asked by 02.05.2016 / 20:42
1
answer

error: initializer element is not constant

I'm trying to declare this buffer on global and when compiling displays the following error    error: initializer element is not constant char *ls_buffer_PPouAUT = malloc(5120*sizeof(char)); How can I resolve it?     
asked by 22.07.2016 / 15:35
2
answers

Error in program execution involving pointers

I've been doing a program in C that read string1 and erased the first occurrence of string2. In string1: "Mouse Roasted Clothes" if I put "Ra" in string2, the program erases correctly, without errors. But if I put "Ro" in string2, it gives error...
asked by 23.07.2016 / 19:00