All Questions
77 questions
-2
votes
3
answers
70
views
Program didnot show printf statement
This code is about creating a value based on the value previously obtained in lectures, so the important variables here are just sks(credits), b, sum, sumsksb, and nh. The program will process it into ...
-1
votes
4
answers
195
views
Printf inside a For Loop
What will this C code print?
for(printf(“1”);!printf(“0”);printf(“2”))
printf(“Sanchin”);
return 0;
I was expecting this code to result in an infinite loop but instead nothing was printed.
Should the ...
2
votes
1
answer
107
views
Why does having scanf & printf in a loop cause this output
The program in question:
#1:
int main(void) {
int size;
scanf("%d", &size);
int v[size];
for(int i = 0; i < size; ++i) {
scanf("%d", &v[i]);
printf(&...
0
votes
1
answer
33
views
printf inside a loop doesnt seem to be printing any results
I'm a beginner and I'm trying to code a program that converts decimal into binary numbers. As far as I can see, the process of storying the digits into an array seems to be going smoothly, but I cant ...
0
votes
0
answers
31
views
Printing many variables causes strange formatting
In the code below, when trying to print many variables at the same time, it causes strange formatting.
Please check the what it print now at the end of the post and how it is supposed to look:
#...
0
votes
1
answer
95
views
How can I take a variable multiple times and implement counters in while loop?
I want this program to determine if given integers are positive/negative & odd/even then increment the counters. But it doesn't work properly.
include <stdio.h>
int main() {
int evenCount=0,...
4
votes
2
answers
598
views
Multiple printf in the For-loop as part of the initialization, condition and update
Could anyone explain to me why it prints 32 and the overall concept of how this works?
#include <stdio.h>
int main()
{
int a=1;
for (printf ("3"); printf ("2"); ...
0
votes
2
answers
533
views
I need to create a decimal to binary program that can receive input of up to 100,000,000 and output the whole answer without displaying rubbish
As you've read, I created a decimal to binary program and it works well, but it cannot handle user input equal to 100,000,000. My solution is to print each character as it goes, but I do not know what ...
1
vote
2
answers
2k
views
write a program that computes and displays the factorial of a positive integer n entered by the user
Been working on this question for class. Not sure what I'm doing wrong.
Seems like I just don't have the correct format. My professor wants the output to look like "5!=1 * 2* 3* 4* 5=120"
...
-2
votes
3
answers
280
views
Reverse a given number
How to handle the test case if I enter the number 10000
and I get 1 as a result instead of getting 00001.
How to handle this case?
#include <stdio.h>
int main() {
int n, rev = 0, ...
0
votes
1
answer
79
views
Automatic loop termination
I am printing scorecard using global variables. For some reason the loop is getting terminated after 9 iterations even with an infinite loop.
Here is my code:
int runs1[12]={7,128,143,213,2,102,5,1,0,...
1
vote
1
answer
393
views
What makes Printf prints twice?
I did everything in my hands and think it's time to ask for help.
The following snippet of code runs by the main thread Only and my whole code doesn't call fork() at all.
inside another function:
...
1
vote
3
answers
79
views
Can this be solve only by loops?
Since I am kind of a beginner to programming, I try to programm as much as possible. I saw a illustration on how an integer array saves its bytes. I tried to make this illustration in c, just for the ...
3
votes
3
answers
4k
views
How to delete last character from output in c
Suppose my code is
void main()
{
for(i=1;i<5;i++)
{
printf("%d, ",i);
}
}
The output of this program will be
1, 2, 3, 4,
How can I get output like
1, 2, 3, 4
The ...
0
votes
1
answer
177
views
Variable is getting Overwritten by the subsequent variable in printf
I am not getting the complete word of the variable , it is overridden by the next element
The code goes this way.
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include &...