All Questions
90 questions
0
votes
0
answers
28
views
Regarding behavior of printf() function [duplicate]
Why does behavior of a printf() function, or possibly of the pre-increment/decrement operator vary when a specific parameter is passed to (in my case) a different printf() function?
Warning : Rookie ...
0
votes
1
answer
124
views
C printf() function order of evaluations? [duplicate]
What is the output?
Please kindly give answer with valid explanation.
#include<stdio.h>
int main()
{
printf("%d %d", printf("Hello World"), printf("New World"))...
-1
votes
1
answer
215
views
What is the difference between standard identifiers and predefined functions in C?
I'm starting out on C and I've come across references to standard identifiers such as printf and scanf.
What is the difference between these and predefined functions that the book later describes such ...
0
votes
1
answer
61
views
c nested scanf in printf along with another variable
I wrote the following c codes
code1
#include <stdio.h>
int main() {
int z = 9;
printf("%d\n", printf("%d%d", scanf("%d", &z), z));
return 0;
}
...
-3
votes
2
answers
472
views
How do I print a star pyramid pattern using recursion without any loop in C?
I do this but it's using a for loop. I don't want it:
#include <stdio.h>
void printPattern(int n);
int main()
{
int n = 4;
printPattern(n);
return 0;
}
void printPattern(int n)
{...
0
votes
2
answers
79
views
Strange Random Behavior in a Local Variable of a Function
I'm trying to write a program that finds the distance of an arbitrary amount of tugboats from a main ship and orders them from closest to furthest. This also involves removing tugboats that are deemd ...
0
votes
2
answers
170
views
The program has no syntax error however no result comes out
Here is the code:
#include <stdio.h>
#include <stdlib.h>
int *dec2bin(int N, int *n);
int *dec2bin(int N, int *n) {
int l = 0;
do {
if (N % 2 == 0) {
n[l] = 0;...
-1
votes
1
answer
72
views
Why is my program breaking when I add a void function to the main? It works without it
I have 2 functions + my main.
One of them is a void function that "prints out instructions"
The other is the one that actually does what I want it to do.
For some reason when the play ...
1
vote
2
answers
57
views
Cant understand why I'm getting this warning
double S = 0;
double *pSum = &S;
double P = 0;
double *pAverage = &P;
printf("The average and sum of the variables: %lf %lf", &S, &P);
I'm working with ...
0
votes
0
answers
89
views
Array passed as parameter not accessible outside of user defined function
This code is to convert a inputted decimal number to binary, hex, and octal without format specifiers. It also is supposed to print the results to a text file. Every works fine except the 3 char ...
0
votes
1
answer
54
views
Why printf prints same string when function called back to back inside same statement [duplicate]
In the below snippet, printf( ) prints same string even though the char array has been memset to 0.
#include <stdio.h>
#include <string.h>
char ip_addr[20];
char *ip_print(char *in)
{
...
0
votes
1
answer
33
views
\b function in C not working and printing Good<0x08>Afternoon
#include <stdio.h>
main()
{
printf("Good\bafternoon");
return 0;
}
**Result - **
-1
votes
1
answer
87
views
how these printf giving output any value? the functions aren't returning anything
#include <stdio.h>
int fun1(void);
int fun2(void);
int fun3(void);
int x; //global variable
void main(){
x=10;
printf("x = %d\n",x);
printf("x = %d\n",fun1());
...
1
vote
1
answer
99
views
Repetition of a printf()
I'm trying to create a game. In order to do it, I have two functions size() and ask_column().
Size() ask for the size of the grid wanted by the user. It return the number that should be 4 or 8.
int ...
0
votes
1
answer
184
views
Print each row twice in a 2D array - C
Good day! How do I print each row twice in a 2D array in C program?
for(int row = 0; row < 5; row++) {
for(int col = 0; col < 5; col++) {
printf("%d ", arr[row][col]); ...