`````` #include <stdio.h>
#define p printf
#define s scanf
main()
{

int q,num,sum,i,a,b;

{
p("enter the the total quiz:");
s("%f",&t);
p("enter the no. quiz:");
scanf("%d",&q);
p("enter five no sepeerated by enter :\n");
for(i=0;i<q;i++)
s("%d",&num[i]);
sum=0;
for(i=0;i<q;i++)
sum=sum+num[i];
p("the sum of array :%d",sum);
mul=sum/t;
p("\ntotal:%f",mul);
p("\nquiz is: %f",quiz);
}
{

p("\n\nENTER THE TOTAL OF ASSIGNMENT");
s("%d",&a);
p("enter the number of assignment");
s("%d",&b);
for(i=0;i<b;i++)
s("%d",&num[i]);
for(i=0;i<b;i++);
d=d+num[i];
p("the sum of assignment is %f:",d);

}

getch();
return 0;
}
``````

You have a for without any statements in it at line 38, as line 37 ends in ;. It looks strange for me as it has not effect except increasing i, so line 39 is in effect d += num[b].

Also learn to use proper indention for your code.

whats wrong in my codes

1) `main()` is an INT function
2) `define`ing printf and scanf makes the code difficult to follow and is unnecessarily confusing
3) As pyTony mentions, you need to

## All 6 Replies

You have a for without any statements in it at line 38, as line 37 ends in ;. It looks strange for me as it has not effect except increasing i, so line 39 is in effect d += num[b].

Also learn to use proper indention for your code.

whats wrong in my codes

1) `main()` is an INT function
2) `define`ing printf and scanf makes the code difficult to follow and is unnecessarily confusing
3) As pyTony mentions, you need to format your code properly.
4) Use a standard function (`getchar()`) instead of the nonstandard `getch()`.

That's what I see.

Also, when asking for help, details are important. "Wrong Answer" tells us nothing. What did you get and what did you expect based on what input was used?

instead of #define, use typedef keyword..
this keyword is actually meant to define a different name to the existing keyword.
so i think that will be more preferable.

In line 38 there is semicolon after for

for(i=0;i<b;i++);

instead of #define, use typedef keyword..
this keyword is actually meant to define a different name to the existing keyword.
so i think that will be more preferable.

Wrong. What happened when you tried it in order to verify your information before posting?

Wrong. What happened when you tried it in order to verify your information before posting?

My bad... typedef is for data types. Sorry!!

commented: it's bad to post wrong info +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.