Most voted "c" questions
C is a general-purpose computer programming language used for operating systems, games, and other high-performance jobs and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the UNIX operating system.
Learn more…4,811 questions
Sort by count of
-
-2
votes1
answer817
viewsImplement numerical sum with successor and predecessor only
Consider a numerical system that does not have the addition operation implemented and that you have only operators (functions) successor and predecessor. Then, it is asked to write a function…
-
-2
votes1
answer691
viewsDoubt with bool in C
Well, I did this vector test, but I’m having a problem with the bool type, which never turns false and displays the message of not found. #include <stdio.h> #include <stdlib.h> #include…
-
-2
votes1
answer40
viewsCheck data received by the user
How can I check if the user typed a die the way I’m hoping? For example, I want him to type an integer value. How do I know if the value he typed was an integer and not a char or float, and if the…
casked 6 years, 6 months ago user112981 1 -
-2
votes2
answers45
viewsUse of cinnamon in macros
Good evening! I want to test a condition that will be implemented in the macro. The value for the test will be informed by the user. My code generates an error when compiling. What can it be? Thank…
-
-2
votes3
answers7818
viewsRead multiple scanf numbers separated by space
I need to make a program that receives a number of elements from a vector, and then each element of that vector, but in the same scanf with spaces. Only I don’t know how to do this, someone can help…
-
-2
votes1
answer139
viewsHttp requests using the C language in windows?
How to make http requests using the C language in windows ? No need to post code, just a good reference is enough for me :) But if anyone has any examples will be of great help ;)
-
-2
votes1
answer186
viewsWhat is a specific C function for?
What is a C function for, its usefulness?
-
-2
votes1
answer129
viewsPrepare a program in C that receives 6 integer numbers and then the program should present the sum of these numbers on the screen, I could only here
int main() { int N1, N2, N3; printf("Digite o primeiro numero: ", N1); scanf("%d", &N1); printf("Digite o segundo numero: ", N2); scanf("%d", &N2); …
casked 6 years, 5 months ago ErmesonMartins Oliveira 15 -
-2
votes1
answer46
viewsReading of a String
If I have a string that is: String s = "2123dog"; How can I calculate the first character 2 to transform the next 2 characters into an integer, and 4 to transform the name that is dog? The result…
-
-2
votes1
answer34
viewsHow to verify that the limit of a vector has not been exceeded?
Good afternoon, gentlemen! I’m doing a college paper that asks me to create an agenda. I did most of the code, but I’m not able to see the light so that when the user tries to register a person in…
-
-2
votes1
answer146
viewsTable test result is not the same as compiled?
The code below when executed returns the result to m = 0, but doing the test table the result should be -2. I can’t prove the 0as a result unless the variable t++ when in (t * t++), only at this…
-
-2
votes1
answer34
viewsDoubts about strings
I have a proposal to print on a theater ticket, date, time, part name (to be typed and read by scanf) and customer’s armchair number, // declaração da variável. char PecaTeatral[255]; // pulando…
-
-2
votes1
answer1276
viewsHow to change the color of a console line in C?
so I’d like to know how do I change the color of that line... It’s a college project, and I’ve done research on other forums and everything, but I can never get an answer that works. I’m using the…
-
-2
votes1
answer32
viewsError in passing a structure by reference C
In this exercise it is necessary to change only the characters a by b, ie output of the printf should be like this {B, 1.5, 2.7} {A, 3.9, 4.2} typedef struct{char n;float x;float y;}Ponto; void…
casked 6 years ago Erich Alves Fratini 11 -
-2
votes1
answer1708
viewsProblem with swapping vector positions
Good morning! Using Dev C++, I am making the following problem in C: Make a program in C that reads a 20-position vector of the real type. Replace the first position with the 11th, the 2nd with the…
-
-2
votes1
answer64
viewsMiscalculation
#include <stdio.h> #include <stdlib.h> float dobro_do_maior(float x, float y) { float dobro; if(x > y) { dobro = x * 2; }else{ dobro = y * 2; } return dobro; } void main() { float a,…
-
-2
votes1
answer149
viewsI wrote this code in Dev C++, it compiled but does not perform the operation
When I run and type a number it does not multiply, it only displays the message " Price:" and not the multiplication result. #include<stdio.h> main() { int quantidade; double valor;…
-
-2
votes1
answer48
viewsHow do I get each row of my matrix to store a substring?
Suppose the user typed: I am very beautiful Each row of the Matrix would store a substring thus: I am much beautiful
-
-2
votes2
answers452
viewsString comparison in C
How could I print the variable sex outside the if-else (has to be outside of it). This code is printing blank and I can’t understand why. #include <stdio.h> #include <stdlib.h> #include…
-
-2
votes3
answers869
viewsFactorial in C, beginning of programming
include stdio.h include stdlib.h include math.h int main() { int n, prod=1,x; printf ("Digite um numero:"); scanf ("%D", &n); for (=1; x<=n; x++) { Prod*= x; } printf ("Fat= %D\n", prod);…
-
-2
votes1
answer82
viewsIncreasing list in c
#include <stdio.h> #include <stdlib.h> int main() { int total = 10; char letra = '*'; char *retorno; retorno = (char *) malloc(total + 1); for (int i=0; i<total; i++) { retorno[i] =…
-
-2
votes1
answer559
viewsVector union
How do I join 2 vectors into 1 single vector ? Without repeating the numbers ? Question: Make a program that reads two vectors of 10 elements. Create a vector that is the union between the two…
-
-2
votes2
answers48
viewsgalley that part " if ((S%10=0) && (S<Vt))" is not going
#include<stdio.h> main() { char R[1]; int S, SQ, Nc, Vt; Nc=1000; Vt=10000; SQ=S/10; while(R!="N" || Nc>0) { printf("limite:%d",Vt); printf("\nDigite quanto deseja sacar:");…
casked 5 years, 6 months ago Pedro Sabença 1 -
-2
votes1
answer70
viewsExplanation of the code
Hello, could you explain the part of that code? int nota[2]; scanf( "%s %d", nome, &horas ); And that part int i = 0; while( i < 2 ) { scanf( "%d", ¬a[i] ); if( nota[i] > 100 ||…
casked 5 years, 5 months ago betafico123 3 -
-2
votes1
answer262
viewsHow to generate a variable with random value in C
Good night, you guys. Well, I’m taking a C programming course and in this course I have a challenge, to create a game of jokenpô. I started doing the code part of the game and such and the part that…
casked 5 years, 4 months ago Luciano Santos 1 -
-2
votes1
answer54
viewsConcatenate and show on screen
I don’t know how to print the strcat on the screen, I don’t know how to concatenate to the position typed in the scanf_s. int main() { char string1[10], string2[10]; int RU[1]; char NomeSobrenome;…
casked 5 years, 4 months ago Fabio Santos 1 -
-2
votes1
answer4019
viewsPq ta giving this error -> error: expected ?;' before ?)' token
I made an algorithm to determine if a number is prime or not, but when compiling it is giving this error when compiling in Ubuntu’s own terminal. #include <stdio.h> int main(){ int n, i,…
-
-2
votes2
answers61
viewsRandom generation
Hello. I was asked a question in a random number study in C. How would I generate a value in an interval that is not continuous? Generate a value between 10 to 15 or 20 to 25, for example.
-
-2
votes2
answers3763
viewsCount letters and pick initials of the name
The program does not print the first letter of each name. nome[i]=nome[i+1]; I need to make a program that enters the name of the person, tells how many letters A has the name of that person and…
-
-2
votes1
answer146
viewsHow to create a C function that searches for words in txt files in a predefined directory?
void pesquisarexerword() { DIR *dir; char *strdir, *strget, t, *str; struct dirent *lsdir, *dirarq; FILE *arq; do{ printf("\n Digite o Diretorio que…
-
-2
votes1
answer61
viewsC language code print pairs from one to fifty
Programming exercise in C: Statement: "Write a program that prints all pairs between 2 and 50. To know if the number is even, just see if the rest of the division by 2 is equal to 0." what I did:…
-
-2
votes1
answer161
viewsDivide sum of values of a vector
I’m trying to divide/multiply all the numbers between themselves using vectors. for example: type 4 numbers and divide them all: 5/5/2/1 but I can’t get the division. follow the program: float…
-
-2
votes1
answer88
viewsWhy does a variable passed to function not keep the changed value when it exits the function?
I want the variables latitude and longitude to be updated, but only the variables lon and lat are being changed. I cannot add latitude = latitude - 1 or longitude= longitude + 1.…
-
-2
votes1
answer53
viewsRewrite 2-digit maximum input numbers for output
I need to rewrite two-digit numbers at most input to the output, stopping processing the input after reading the number 42. Input: 1 2 88 42 99 Output: 1 2 88 My code is like this, I can’t…
-
-2
votes1
answer63
viewsWhat is the code for "par = par + 1"?
#include<stdio.h> #include<locale.h> int main(){ int par=0, num, i; setlocale(LC_ALL,"Portuguese"); for (i=1; i<=10; i++){ …
casked 4 years, 3 months ago Yander Alves 57 -
-2
votes1
answer670
viewsError : Too few Arguments to Function 'Fdelta'
When I try to declare a function there is error Too few Arguments to Function 'Fdelta' which could be?…
-
-2
votes2
answers69
viewsI’m creating a three-lane game but I can’t get to the next question
Save save everyone, everything jewel with you? I hope so, I have this code on C he’s okay, but I’m trying to implement more questions and I can’t. Follows the code: #include<stdio.h>…
casked 6 years, 10 months ago GSS ÁUDIO FILME 1 -
-2
votes1
answer193
viewsError 'dia' undeclared (first use in this Function) what to do?
What can I do? variable not declared in function?…
-
-2
votes1
answer30
viewsA function that reads only the last integer number written in a text file and returns?
FILE * save; int funcao () { int d; char linha[100]; save = fopen ("light.txt" , "r"); if (save == NULL) { …
-
-2
votes4
answers3044
viewsProblem using Setlocale in C
Hey, guys, good morning. I’m starting in C programming (I come from Python and Javascript). I have a problem using the setLocale function, which defines the type of language used, allowing the use…
-
-2
votes1
answer39
viewsCalculate the product within a for loop
I need to calculate the product of 3 numbers inside a loop for, but the code I made is going wrong, multiplying something bizarre that I couldn’t even understand, for example, if I input 1, 1, 1, it…
-
-2
votes1
answer90
viewsprinting calendar with wrong days
good day galley I made an agoritimo that generates the calendar of a given year however for bisext years it is returning days correctly but for years not bisextos it brings dates for different days,…
-
-2
votes1
answer94
viewsA program that sums up n numbers where the odd numbers will be disregarded, where it works as it should
#include <stdio.h> int main() { int i, nmrs, n, soma = 0; printf("De quantos numeros quer fazer a soma? (impares serao desconsiderados)\n"); scanf("%d", &nmrs); for (i = 1; i <= nmrs;…
-
-2
votes1
answer42
viewsWhy does the code return error dumped core?
I came across the following errors: floating point Exception and dumped core for the same code. I did not understand very well why this error occurred. I put the code in a Bugger and from what I saw…
-
-2
votes1
answer46
viewsHow do I get only the units of that number
#include <stdio.h> int main(){ int hora,minuto,dia,mes,ano; scanf("%d",&hora); scanf("%d",&minuto); scanf("%d",&dia); scanf("%d",&mes); scanf("%d",&ano); printf("%02d:%02d…
casked 3 years, 6 months ago Guilherme Barros 1 -
-2
votes1
answer36
viewsHow can I check with `if` if the word typed is equal to some word in a list of strings in C?
example: #include <stdio.h> int main(){ char input[20]; char* strings[] = {"maça","banana"}; printf("tente acertar uma das minhas frutas favoritas:\n"); scanf("%s", input); if(input ==…
casked 3 years, 5 months ago anonimocbhudivbhufbhurf 3 -
-2
votes1
answer40
viewsI need to print a L1 line of a matrix in C
After reading L1 in main, I need to pass line A[L1] to a function and print this line Prints(A[L1]), only it gives an error saying that it does not recognize the parameter. What can it be? void…
-
-2
votes1
answer34
viewsSwap a character inside a string in c
Why is this substitution of a character within a string not working? int main(){ char *armazena = "XXX", letra = 'a'; letra = armazena[2]; *(armazena+1) = 'a'; printf("%c", armazena[1]); return 0; }…
casked 3 years, 4 months ago Higor Luiz 1 -
-2
votes0
answers36
viewsdivision by 1/value
I’m doing some work that needs complex mathematical equations. And I’m having a problem early on, when I try to do the 1/result split, the answer is always 0,000. I have tried using double, float,…
-
-2
votes1
answer39
viewsHow I can view a header file and where I can find it
Dear colleagues, How do I find the file location of a header file (ex. stdio.h)? I would like to know where I can find it locally on my machine to open and consult its contents. For information, if…
casked 3 years, 3 months ago moriartybr 1