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 ,
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 11 months ago.
Improve this question
#include<stdio.h>
int main() {
char l,u;
printf("Enter any lowercase number: ");
scanf(" %c",&l);
u = toupper(l);
printf("The uppercase number is: %c\n",u);
return 0;
}
The toupper() function is declared in the <ctype.h> header file. So you have to include that at the top.
#include <stdio.h>
#include <ctype.h>
int main() {
char l,u;
printf("Enter any lowercase number: ");
scanf(" %c",&l);
u = toupper(l);
printf("The uppercase number is: %c\n",u);
return 0;
}
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.
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
Im receiving warnings like this "warning: array subscript has type 'char' [-Wchar-subscripts]" in lines 11, 12 and 15. Whats wrong with my code?
#include <stdio.h>
#include <ctype.h>
int main()
{
char s[1000], i, d, a;
printf("Enter a string: ");
fgets(s, 1000, stdin );
for(i = 0; s[i] != '\0'; i++){
if (isalpha(s[i])){
a++;
}
if (isdigit(s[i])){
d++;
}
}
printf("Number of digits: %d ... Number of letters: %d ", d, a);
return 0;
}
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
I started to read about pointers and I tried to write code for a problem in which the user gives me the radius of a circle and I return to him the perimeter and the surface. When I run this code the compiler shows this :
example.c:16:15: error: expected ‘)’ before ‘float’
void circle(r,float *p,float *s)
^
My code:
#include <stdio.h>
float pi=3.14159;
void circle(float ,float *,float *);
int main()
{
float radius,perimeter,surface;
printf("insert the radius of the circle\n");
scanf("%f",&radius);
circle(radius,&perimeter,&surface);
printf("the perimeter is %f and the surface is %f\n", perimeter, surface );
return 0;
}
void circle(r,float *p,float *s)
{
*p=2*pi*r;
*s=pi*r*r;
}
You are missing the radius:
you typed: circle(r,float *p,float *s)
but what is r in the parameter? correct this by doing:
void circle(float r, float *p,float *s)
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