Questions tagged as 'c'

1
answer

Strlen problem

Can anyone tell me why this code is printing an extra number when I initialize the variable as "0": #include <stdio.h> #include <string.h> int main ( void ) { char texto[50]; int cont = 0; printf("\nInforme seu nome comp...
asked by 06.10.2016 / 21:20
4
answers

Recursive multiplication in C

I'm learning recursion in C, and I was able to do some programming using recursion. However, I'm picking up to make a simple program that the user sending two numbers, example: 6x2, I multiply them in recursion. I may even show you the code belo...
asked by 29.08.2016 / 14:26
1
answer

Why can not I use || for pointer?

I have the following code: int i=0; variable a; a.type = CHAR; a.name = malloc(sizeof(char)+1); while(*l->str++ != ' '); while(*l->str != ';' || *l->str != '='){ a.name = realloc(a.name, ((!i)?1:i)*sizeof(char)+1); a.name[i] =...
asked by 07.03.2014 / 05:37
1
answer

Conversion from Farenheit to Centigrade always gives zero

This is the exercise:    1.12.3. The conversion from Farenheit to Celsius degrees is   5   C = 9 (F - 32)   Make an algorithm that computes and writes a centigrade table based on Farenheit degrees, ranging from 50 to 150 from 1 in 1. I m...
asked by 06.04.2017 / 17:22
1
answer

Printing ASCII extended in C

Look at this simpes code written in C: unsigned char *palavra = "fantástica"; int tamanho = strlen(palavra); int i; for (i = 0; i < tamanho; i++) printf("%i ", palavra[i]); printf("\n"); Output fetched: 102 97 110 116 195 161 115...
asked by 11.06.2016 / 06:45
1
answer

Binary conversion limit in C

I developed this code in C to convert integers to binary, but the limit is 1023. Any number above that, conversion is no longer performed What is the possible reason for this? int binario(int num) { if (num == 0) return 0;...
asked by 15.02.2017 / 23:10
1
answer

Is there a problem in assigning a value to a pointer?

I'm referencing this site here How to declare pointers in C Normally when we want to start a variable of integer type, for example, we do int inteiro = 4; m but if we do int *inteiro_ptr = 4; can it imply something in the code...
asked by 22.06.2016 / 20:05
2
answers

Generating random number in C language

Let's say I have an empty array of size 8. int A[8]; And so I intend to populate it with random values whose I would have a function similar to rand(); However, I call rand() for each element of the array, so all eleme...
asked by 20.05.2015 / 00:42
1
answer

Unexpected value is being displayed

   Make a program that receives the number of hours worked, the value of the minimum wage and the number of overtime worked, calculate and show the salary to be received, following the rules below:    a. The hour worked is 1/8 of the minimum...
asked by 11.04.2015 / 02:42
1
answer

How to know if three points are clockwise or not in C / C ++?

Given three points p1, p2 and p3, what is the best way to know if this order is clockwise, counterclockwise, or neither (all three are collinear)? For example, in the following image the points are clockwise: In the same case, if the...
asked by 28.04.2016 / 18:58