0

Can you please tell me where are the problems here?

A-write a code that interacts with user as follows: 1.1 At the beginning of the code or any reset print : (function with no inputs) “ welcome to my code my name is (your name) ,if you are a male enter 1 and if you are a female enter 2 “ 1.2 After you store the number in a variable , use as an input for another functions that has no output and prints “welcome Mr” or “welcome miss” (function with no output but has an input) 2. Get the birthdate #include <stdio.h> int gender(); int birth(g); void welcoming(h); int main() { int a,x,g,h; x= gender(); welcoming(x); a= birth(g); } int gender(void) { printf("Welcome my name's Retaj"); printf("if you are a male enter 1 and if you are a female enter 2"); scanf("%d",&h); return (h); } void welcoming(gender(void)){ if (h==1){ printf("Welcome Mr"); } else {printf("Welcome Mrs"); } } int birth (int g){ printf("enter your birth date"); scanf("%d",&g); int age=2018-g; return (age); }

1st Sep 2018, 5:26 PM
Retag Tarek
Retag Tarek - avatar
1 ответ
+ 5
Retag Tarek there are two errors in code as below : 1...... for function, int gender(void) ; variable h is not accessible... so, you need to declare first before you use itas below: int h; 2....... Function should be declared as below: void welcoming(int h) whatever you used is returns value... But that value cannot be passed as function argument while declaring... you must have variable like int h in function definition... you have already passed value while calling function...
1st Sep 2018, 5:49 PM
Ketan Lalcheta
Ketan Lalcheta - avatar