Struct Questions
Struct Questions
1. Definition 1:A point is represented as x absis (double) and y ordinate (double) in Kartesian
Coordinate System.
Definition 2: A circle is represented as a center point and a radiun on the space.
According to these definitions:
a. Write a struct that represents a Point
b. Write a struct that represents a Circul
c. Write a function that returns a distance between two points taken as parameters.
d. Write a function that checks whether a point is inside, outside or on a circle. A point and
a circle are taken as parameters of function.
e. Write a function that returns the around of a circle taken as a parameter.
f. Write a function that returns the area of a circle taken as a parameter.
g. Write a function that returns area between two circles which have the same center
2. Time is represented as hour (int), minute (int), second (int) and milisecond (int)
a. Write a struct that represents a Time
b. Definition: 1 day = (24 hours) = 8640000 mili second According to this definition , write a
function that returns hour of a day for a given integer between 1-8640000 by user.
Example: If the integer is 8640000, the time is 0:0:0.0. If integer is 101, the time is 0:0:1.1
c. Write a function that returns a difference between two times zones. (The parameters of
functions are two time zones and the function returns a time)
3. Definition: Date is represented as day (int), month (int) and year (int). According to this
definition:
a. Write Date struct.
b. Write a function that returns a difference between two dates. (The parameters of
functions are two dates and the function returns a date) (Take 1 month=30 days)
c. Write a function that returns day of a year for a given integer bettween 1-365 and a year
information. (if it is a leap year that takes 366 days) (Consider in a leap year February takes
29 days and a year is 366 days)
Example: If year is 2019 and an integer is 10, the function must return the date as
10/1/2019. If year is 2020 (leap year) and an integer is 365, the function must return the
date as 30/12/2020.
4. Definition: A Complex number is represented as real part (double) and imaginary part
(double). According to this definition.
a. Write Komplex struct
b. Write a function that returns the conjugate of a given complex number.
c. Write a function that returns the module of a given complex number.
d. Write a function that returns the sum of given two complex numbers.
e. Write a function that returns the difference between two complex numbers.
f. Write a function that returns the multiplication of two complex numbers
g. Write a function that returns the division of two complex numbers
h. Write a function that returns nth power of a complex number. The parameters of
function are a complex number and an integer. The function must return a complex
number. The following formula calculates nth power of a complex number
i. Write a function that returns nth root of a complex number. The parameters of
function are a complex number and an integer. The following formula calculates
nth root of a complex number
𝐿𝑒𝑡 𝐶𝑜𝑚𝑝𝑙𝑒𝑥 𝑛𝑢𝑚𝑏𝑒𝑟 𝑏𝑒 𝑍 = 𝑎 + 𝑖𝑏
𝑏
𝜃 = atan ( )
𝑎
1 1 2𝑘𝜋 + 𝜃) 2𝑘𝜋 + 𝜃)
𝑧 𝑛 = 𝑟 𝑛 [cos ( ) + isin ( )]
𝑛 𝑛
𝑘 = 0,1,2, , … , 𝑛 − 1
𝑟 = √𝑎2 + 𝑏 2
j. Aşağıda verilen programın çıktısını bulunuz?
#include <stdio.h>
#include <stdlib.h>
struct Yapi
{
int b;
int c;
};
struct Yapi Sacma(int d,int *e)
{
struct Yapi q;
q.b=*e+2;
d++;
q.c=d;
*e*=2;
printf("\n%d %d",d,*e);
return q;
}
int main()
{
int m=3,n=4;
struct Yapi p;
printf("\n%d %d\n",m,n);
p=Sacma(m,&n);
printf("\n%d %d %d %d",p.b,p.c,m,n);
system("pause");
return 0;
}