Need help !

Hi, my son needs help. There is a fault line 7 and still?
1 #include<stdio.h>
2 #include<math.h>
3 main()
4 {
5 int A
6 ;float x
7 ;printf("unesite broj")
8 scanf("%d",&A );
9 if((10<A)&&(A<50))
10 k=pow (A,2);
11 else
12 if((A>100)&&(A<150))
13 k=sqrt(A)
14 else
15 printf("uslov nije ispunjen");
16 printf("rezultat je %f",k);
17 }


serbian language
unesite broj --> input number
uslov nije ispunjen--> condition is not met
rezultat je ---> the result is
Last edited on
Hello majstor,


PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code.

It makes it easier to read your code and also easier to respond to your post.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.

I found the second link to be the most help.


I hope this translation works.

If you format your code your code properly the error messages should make a litttle more sense and point to the correct line numbers.

For the compiler what you have will work because the compiler does not care about white space or where something is.

To a person this is much easier to read and understand and a great help to finding problems.

This code will give you an idea of how it can be done. The comments in the code tell what is missing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<stdio.h>
#include<math.h>

main()  // <--- Should be "int main()". Треба да буде "инт маин ()"
{
	int A:  // <--- Should be a ; Треба да буде;
	float x;  // <--- Not used right now. Тренутно се не користи.

	printf("unesite broj")  // <<--- missing ; миссинг;
	scanf("%d", &A);
	
	if ((10 < A) && (A < 50))
		k = pow(A, 2);
	else if ((A > 100) && (A < 150))
		k = sqrt(A);  // <<--- missing ; миссинг;
	else
		printf("uslov nije ispunjen");

	printf("rezultat je %f", k);

	return 0;  // <--- Added. Аддед
}


This is what I see for now although I did not have a chance to compile it yet.

Line 13 is most often written as: k = A * A;

Надам се да овај превод функционише.

Ако форматирате код исправно, поруке о грешкама би требало да имају мало више смисла и указују на тачне бројеве редова.

За компајлер ће радити оно што имате, јер компајлеру није стало до белог простора или тамо где је нешто.

За особу је то много лакше читати и разумјети, аи велика помоћ у проналажењу проблема.

Овај код ће вам дати идеју о томе како се то може учинити. Коментари у коду говоре шта недостаје

Изнад кода овде.

То је оно што видим за сада, иако још нисам имао прилику да га компајлирам.

Линија 13 се најчешће пише као: k = A * A;

Hope that helps,

Andy
Thank you
Topic archived. No new replies allowed.