Questions tagged as 'c'

1
answer

Capitalize lowercase in string

I need to do a function that takes two strings, and change both of them. But if you have a capital letter at the first, the time to convert must be lowercase. I tried to do it, but I think it's wrong inside my while . What can I do? Not...
asked by 14.06.2018 / 19:29
1
answer

Programming C - Exchanging matrix elements

My code below should change the elements of the array, if it is 1 it will change by 0 and if it is 0 it will change by 1. However, the printed matrix has all the elements 0: #include <stdio.h> #include <stdlib.h> #include <math....
asked by 30.06.2018 / 22:14
2
answers

Calculation to determine if triangle is rectangle does not give expected result

The program I created receives three integer values, calculates the values inside% cos_de% and if the condition is correct it should show the SIM (the triangle is a rectangle), and if the condition is not satisfied, it should show NO. By typi...
asked by 04.04.2015 / 01:30
1
answer

How to let the string size be set by scanf ()?

My question is about theory. I know it's possible to do a string without limiting its size as: char teste[] = "Teste"; However, I would like to know if you can do the same thing, that is, not limiting the size, but without saying what...
asked by 23.08.2017 / 19:37
2
answers

Values returned in comparison of strings in C

I was reading about header string.h functions in link and I came across with a strings function (very useful after all), such as strcmp(string1, string2) . Depending on the first character that does not match, that is, it i...
asked by 03.08.2018 / 23:26
3
answers

How to sum the numeric values inside a String in C?

For example, if the user types 123456789 the program should print 45 ( 123456789 ). 1 + 2 + 3 + 4 ...) . I think the easiest way would be to store the number in a string and then add the elements in each position of the string, but I do not k...
asked by 11.09.2017 / 15:50
2
answers

Highest odd number

I spent hours trying to solve it, I started to think that the problem might be in the compiler, since it returns a different (and wrong) number with every execution What could be the mistake? #include <stdio.h> #include <stdlib.h&g...
asked by 13.06.2017 / 21:04
1
answer

Does the amount of bytes during a file read vary according to the mode chosen?

In C, if I open a file in binary mode, read it byte-by-byte and then get the file and read in text mode, the amount of bytes will be different? If so, why?     
asked by 30.05.2017 / 03:07
1
answer

Entering an arithmetic expression instead of an integer in C

I'm new to C and I made a simple program that gets two numbers and prints the sum of them: // Programa que faz uma soma simples #include <stdio.h> // Função principal do programa int main( void ) { int num1, num2, soma; printf(...
asked by 09.12.2018 / 01:26
2
answers

Maximum value for srand ((unsigned) time (NULL));

I was reading about random numbers not being so random and I saw one way out was to feed a seed with srand((unsigned)time(NULL) ); To test I generated a vector of 100,000 positions and ordered it, but it only has the number 32767...
asked by 09.09.2016 / 01:47