Programming in C [closed] - c

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
Sorry if question sounds stupid to you or it is too easy but i really do not know what im missing here (or im just stupid and dont understand the errors i am getting).
Im still starting to learn about C programming.
So what im trying to do is to find out how many times will "Red" print on the screen.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i;
for(i=4;i<15,i=i+3); { printf(“Blue\n”);
printf(“Red\n”);
printf(“White\n”);
}
return 0;
}
The errors i am getting are:
Error expected ';' before ')' token
Error stray '\223' in program
Error stray '\' in program
I was trying to find examples on the internet but nothing appears
Every help is appreciated. After all I'm learning.

Your for statement has a comma where it should have a semicolon. The "i<15" part should be followed by a comma.
(Also, since your entire for statement has a semicolon immediately after it, before the block, Red will only be printed once.)

Related

I am new, trying to learn programming in c [closed]

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 4 months ago.
Improve this question
#include <studio.h>
int main(void) {
printf("Watch, Where, You, Walking!\n");
return 0;
}
This is the code I wrote, and here is the error message that I got:
C:\Users\exoar\OneDrive\Computer\collect2.exe [Error] ld returned 1 exit status
You have a spelling error in the first line:
#include <stdio.h> // this is the correct include-statement
Edit: This is probably not the solution to the problem. Nonetheless this is a further problem of the code.

Why C gave a weird output when adding floats and integers? [closed]

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 4 months ago.
Improve this question
I am learning C right now and I understand that I can't add an integer with a decimal like so:
#include <stdio.h>
int main() {
printf("%d",15+9.0);
return 0;
However when running this I expected some sort of an error. Instead, I got a weird output:
-1866308488
Can someone help me understand why it gave me this output?
As #PaulMcKenzie said, C expected an int based on the %d format specifier. You gave it a double instead. C often gives unexpected behavior instead of throwing an error like Java or C#. What happens to a double variable when %d is used in a printf? says that the resulting behavior is undefined and OS-specific.

syntax error: 'constant' while using flex [closed]

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
Well topic speak for himself, here example of a code(lex file before compilation):
%{
#include<stdio.h>
int Upperc=0;
int Lowerc=0;
%}
%%
[A-Z] {printf("Upperccase\t");Upperc++;}
[a-z] {printf("Lowerccase\t");Lowerc++;}
%%
main()
{
printf("Enter a string\n");
yylex();
printf("Upperccase=%d and Lowerccase=%d",Upperc,Lowerc);
}
for some reason when trying to run at vs13, I'm always getting syntax error: 'constant' , there is no line or any information about there error except this,
please help me understand what is wrong, thanks!
Well, as it seems after 5 hours of not understanding the problem ( and 20 minutes after posted here, that the issue was with VS13 ,after installing VS10 everything was fixed...
Thank you all!

How can I detect my coding mistake when I receive this message [closed]

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 7 years ago.
Improve this question
link to the code: http://gyazo.com/f0f4004eb606607ecaa021b5e22e6e06
I am getting the following error when i am running th code.
"error: expected identifieror '(' "
I use gedit to write this code.
I would appreciate some support guys ;)
Thanks in advance!,
Vicente
There's shouldn't be a semicolon in the int main(void); declaration.
Try replacing line 4 with: int main(void) instead.
Also, please read up on C function declaration syntax
https://msdn.microsoft.com/en-us/library/c4d5ssht.aspx.
int main(void);
^you should not do this.
And you forgot to put ; after this statement -
int height=n
And also n is not declared in your program.

Type expected declaration or statement at end of input [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
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.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Improve this question
I am making a C program that is a simple calculator without a GUI, called "Quical". (Check out the code on Github). I am somewhat new to C, and so I am making some syntax errors. One of the errors is this:
expected declaration or statement at end of input
Another one of the errors that comes up is this:
else without a previous if
Here is my code.
Hopefully, this can shed some light as to why I am getting these syntax errors. Any help would be much appreciated.
Your braces don't match. You have something like
main()
{
some statement
{
}
another
{
}
and it ends.
It is saying it wants a statement here. Try that and see what the next error is.

Resources