Questions tagged as 'c'

2
answers

How is a variable pointed to a pointer?

Reading this answer about pointers and arrays in C, there is the example below where the variable ptr points to the first element of this array . int array[42] = {42}; int *ptr = a; How does this pointer identify the first eleme...
asked by 08.10.2015 / 15:41
3
answers

Resolve logic error

I am doing some college exercises, however I am having a logic error in this exercise: #include <stdio.h> #include <stdlib.h> /*usuario entra com um numero, o programa devera imprimir o maior numero primo entre 1 e o numero digita...
asked by 12.02.2015 / 16:44
2
answers

Algorithm for (A + Bi) ^ n

I need to do a program that gives the formula: A + B * i ^ n You have to find the smallest value of n to be a real number Since A and B are inputs and i is part of the complex numbers. I have an outline: #include <stdio.h> #include...
asked by 01.04.2015 / 21:05
2
answers

Why did a dynamic array work without the use of malloc?

The following code snippet follows: int main(void) { int tam, vet[tam]; printf("\ndigite tam: "); scanf("%d", &tam); return 0; } I did not know this worked because I'm typing the vector size at runtime. For me, this was...
asked by 07.10.2014 / 18:54
2
answers

Why does the order of these scanf's make a difference in the result?

The program adds x1 and x2 and places the result in x1 . It does not work if x1 is read before x2 . But if you reverse this order, it works. #include <stdio.h> #include <stdlib.h> unsigned char x1,...
asked by 31.03.2015 / 18:02
4
answers

Problem accessing array element

I have a problem with the function below that truncates all words so that they have a maximum of N characters. For example: if the string contains: "freedom, equality and fraternity", the invocation of truncW(t,4) should give "libe e...
asked by 15.03.2015 / 19:34
3
answers

Aimed from Aimed C

I have a question about this: **ptr I can see all other (ptr++, &ptr, *ptr) I do not know what will be the best way to see how it works **ptr (Pointed from the dotted.) Thank you to anyone who can clarify this i...
asked by 10.03.2016 / 15:39
3
answers

C parity test

I'm having trouble creating a function that returns 0 if the number of bits set in an unsigned char is even and 1 if it is odd     
asked by 23.04.2016 / 23:52
4
answers

How can I decrease the processing time of the program?

I need to display this output: 1 2 3 PUM 5 6 7 PUM 9 10 11 PUM 13 14 15 PUM 17 18 19 PUM 21 22 23 PUM 25 26 27 PUM #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> int main(){ unsig...
asked by 03.07.2016 / 01:02
2
answers

Optimization of several ifs in something more practical

I have a string of alphabetic characters: char string[] = "aouihuiahsudasduihqmdoiqjnduiamsdoqnwuidamodkjwodkaposdj"; I want to go through it and for each character of it, say how many times it repeats itself in string . Example: #i...
asked by 04.07.2017 / 02:07