0

Write a program containing a function that takes 2 integer parameters x and y and returns the value of x2 + y2. The main program should then allow the input of two integer values a and b and display the value of a2+b2.
Can someone help me?am having this error:
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token

Whats wrong in this program?

I write n compile my program using linux terminal.

#include <stdio.h>

int submain(int a,int b)
{
	return (a*a)+(b*b);
}

int main
{
	int x,y,ans;

	printf("Enter value of x: ");
	scanf("%d", &x);
	printf("Enter value of y: ");
	scanf("%d", &y);
	ans=submain(x,y);
	printf("(x*x)+(y*y) %d",ans);
	return 0;
	
}
2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by techyworld
0

You are not using the correct format for the main function. You are missing the () arguments section.

It should look like this or something similar:

int main(int argc, char *argv[])
{
  // Code here
  return 0;
}

Edited by Mouche: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.