error C2449 and error C2059 [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 8 years ago.
Improve this question
I'm trying to do a program about printing trapezoids with their length of top and bottom edges. But i can't execute my code to see if it's working. Here's my code:
#include <stdio.h>
int main(void);
{
int top, bot, a, b;
printf("Please enter the length of top:");
scanf("%d", &top);
printf("Please enter the length of bottom:");
scanf("%d", &bot);
for(a = top; a < bot; a++) {
for(b = top; b < a+1; b++) {
printf("* ");}
printf("\n");}
return 0;
}
And here is my error texts:
error C2059: syntax error : '}'
error C2449: found '{' at file scope (missing function header?)

Remove the trailing ; from the int main(void) function line, that is not a valid syntax
int main(void) // this is wrong here: ';'
{
...

Remove the ; after int main(void).

Change
int main(void);
to
int main(void) //no semicolon

Related

Error in a recursive function to print out a series [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 2 years ago.
Improve this question
So, I am supposed to print out the following series using a C program:
I decide to use a recursive approach and come up with this code:
#include<stdio.h>
float series(int n, float x)
{
float prod;
if(n==1)
return 1;
else
{
prod = (x*x)/((2*n-2)(2*n-3)); //line 10
return prod*series(n-1,x);
}
}
int main()
{
int n;
float x;
printf("\n Enter the values of n and x : ");
scanf("%d %f",&n,&x);
printf("\n The series is :");
for(int i=1;i<=n;i++)
printf(" %f,",series(i,x));
printf("\n\n");
return 0;
}
But this gives an error on line 10:
error: called object type 'int' is not a function or function pointer
I don't see any syntactical error on the line. It would be great if you could point it out.
Thank You!
prod = (x*x)/((2*n-2)(2*n-3)); //line 10
should be
prod = (x*x)/((2*n-2)*(2*n-3)); //line 10
The compiler sees this as a function call where 2*n-2 is the function pointer and 2*n-3 is the argument.

how to solve error:expected identifier or '(' in C language [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 2 years ago.
Improve this question
#include <cs50.h>
#include <stdio.h>
int main(void);
{
int i;
do
{
i=get_int("Height:");
printf("Height:%i./n")
}
while(i>0 && i<9);
for(int j=1;j<9;j++)
{
for(int z=int i-1;z<9;z++)
{
printf("../n");
}
printf("#./n");
}
i have been trying to solve for a long time but it is not working. the error it is showing is:
mario.c:5:1: error: expected identifier or '('
{
^
1 error generated.
can anyone please tell my mistake
i am supposed to form the blocks of mario
you added a ; after main declaration and you missed one after this printf printf("Height:%i./n")
this ; should be removed int main(void);
and add one } at the end of main.
also you has to remove second int here for(int z=int i-1;z<9;z++) this should be for(int z=i-1;z<9;z++).

printing too much stars [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
I type this code on Ubuntu 14.04
#include<stdio.h>
int main() {
int i, j, n;
scanf("%",&n);
for (i=0;i<=n;i++){
for (j=0;j<=i;j++){
printf("*");
}
printf("\n");
}
return 0;
}
but it print too much stars and it Continue until I close it.
Should be:
#include<stdio.h>
int main() {
int i, j, n;
scanf("%d",&n);
for (i=0;i<=n;i++){
for (j=0;j<=i;j++){
printf("*");
}
printf("\n");
}
return 0;
}
You forgot to tell scanf you were reading in an integer by using the %d argument
There is mistake in
scanf("%",&n);
it will be:
scanf("%d",&n);
to tell the complier that the value of n is an integer type.

I get the error "expected ‘;’ before ‘!’ token" [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 8 years ago.
Improve this question
int menu () {
char choice [5];
int i;
int c;
printf("Welcome to your own personal tamaguchi!");
printf("\n 1.Name your tamaguchi.\n");
printf("\n 2.Check health and age.\n");
printf("\n 3.Feed tamaguchi.\n");
printf("\n 4. Exercise with tamaguchi.\n");
printf("Let tamaguchi sleep.n");
printf("\n 5. Close program.\n");
printf("Choose action: ");
scanf("%s", choice);
printf("\n");
for (i=0; choice[i]! = '\0'; i++){
if(!isdigit(choice[i]))
return -1;
}
c = atoi(choice);
return c;
}
They say the problem lies where ! is where choice[i]!='\0'.
I have included stdio, string, time and stdlib.
I don't know what I've done wrong, if you can see the mistake please tell me?
Thanks.
You need to change
for (i=0; choice[i]! = '\0'; i++){
to
for (i=0; choice[i] != '\0'; i++){
^
| //notice here
The operator here is not equal to !=. This is a single operator.
If you write like ! = [with a space in between], that becomes two separate operators, Logical NOT and assignment, thereby producing the error.

Getting the error: expected ‘)’ before ‘idSubject’ [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
I'm trying to compile a programme in c but I keep getting the same two errors. The errors I get are:
error: expected ‘)’ before ‘idSubject’
printf("%d" idSubject);
and the other one:
format ‘%d’ expects a matching ‘int’ argument [-Wformat=]
Here's the code:
#include <stdio.h>
#include <stdlib.h>
void averageMark (idSubjectE) {
typedef enum {FALSE,TRUE} bool;
int i;
float acum;
int idChair;
int idSubject;
int numEst;
float mark;
bool found=FALSE;
scanf("%d", &idChair);
printf ("%d", idChair);
scanf("%d", &idSubject);
while (idSubject!=0) {
scanf("%d", &numEst);
if (idSubject==idSubjectE) {
printf("%d" idSubject);
found=TRUE;
for (i=1; i<numEst*2; i++) {
if (i%2==0){
scanf("%f", &mark);
acum=acum+mark;
}
}
printf("%f", acum/(float)numEst);
}
scanf("%d", &idSubject);
}
}
int main(){
averageMark(12);
}
I've been trying and trying but I can't find the mistake,
change printf("%d" idSubject); to printf("%d", idSubject); notice the ,

Resources