Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
Im new to C.
I dont understand i have the " in front of the %d
#include <stdio.h>
int x,y;
int main(void)
{
printf("Indtast 2 numre du vil bytte rundt på \n");
scanf("%d", &x);
scanf("%d", &y);
printf("Dette er dine numre byttet rundt! %d, %d", y, x);
return 0;
}
The code you posted here looks fine. However, looking at the title, you seem to have missed double-quotes around %d on line 7. Save the code you just posted, and recompile. Next time, please post the compiler you are using, too.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I have a problem that this code doesn't end with output.
I appreciate if help me.
#include <stdio.h>
int main(){
int number,counter=0;
scanf("%d",&number);
while (number!=0){
number=number/10;
counter++;
}
printf("the number has %d digits",&counter);
return 0;
}
You should remove "&" from your printf statement.
& is for scanning not printing
the correct form is :
printf("the number has %d digits",counter);
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
#include<stdio.h>
void main()
{
int a,b,p;
printf("Enter values of a and b");
scanf("%d%d", &a, &b);
p=printf("a=%d b=%d p=%d",a,b, p);
}
This is the code for my question. Consider the inputs as a=2 and b=3.
Change:
p=printf("a=% b=%d p=%d",a,b, p);
to:
p = printf("a=%d b=%d\n", a, b); // <<< fix format string
printf("p=%d\n", p); // <<< print `p` *after* you have assigned a value to it
Please also enable compiler warnings from this day forward - any good compiler would have pointed out all of the above errors to you at compile-time.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I'm a new learner to C and I have found this program which is to find the area of a circle. However my compiler keeps throwing this error at me:
[Error] C:\Users\Jiachenn\Documents\C-Free\Projects\HelloWorld\main.c:11: error: syntax error before "printf"
This is my code:
#include <stdio.h>
#include <conio.h>
main()
{
int radius;
float pi =3.14f, area;
clrscr();
printf("Input the radius:");
scanf("%d",&radius);
area = pi*radius*radius
printf("\n Area of circle= %f", area);
getch();
}
Do help!
You are just missing the semicolon on the end of line
area = pi*radius*radius ;
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
#include <stdio.h>
#include <stdlib.h>
main()
{
int n;
printf("Introduce un número entero\n");
scanf("%d", &n);
printf("Has introducido el número: %d", &n);
}
Every time I run this C code I get 6487628 for n, I have uninstalled and installed it over and over again and it keeps doing that, I don´t know what else to do.
You don't want the &n in the printf(), you want n. You are displaying the memory location n is stored in
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
#include <stdio.h>
int main (void)
{
int hist,geo,phy,chem,bio;
int credits=0;
printf("Enter marks in history : ");
scanf("%d",&hist);
if(hist>40)
credits =10;
else
printf("No credits awarded for history");
printf("Credits obtained is %d",&credits);
return(0);
}
when I run the code, and I get a value of 230586 for the variable 'Credits'. Please help. I am a beginner in C
&x is like asking a question "What is the address of variable x?" , that's why you get the strange number. In order to print the variable value, please pass credits instead of &credits to the printf function.
printf("Credits obtained is %d", credits);