1. A is the brother of b - wife
2. Pointing,raghu - not
3. Pointing,arun - wife
4. A woman - aunt
5. A boy introduced - sister
6. Rajesh is the - son
7. A+B means - r is the mother
8. Q is the son - grandson
9. Showing the lady - brother
10. A+B means daughter - p is the son
11. A and B - A
12. Madan told - madan's daughter
13. Pointing he is - brother
14. Pointing, haritha - not
15. Prakash said - brother
Program solution;
1. C – Structure Pointer - Bill (Id-5291)
#include <stdio.h>
struct Bill
{
int N;
int prices[100];
double total;
};
void setTotal (struct Bill *bill)
{
for (int i = 0; i <= (bill->N) - 1; i++)
{
bill->total += bill->price[i];
}
}
int isEligibleForDiscount (struct Bill *bill)
{
if (bill->total > 2000)
{
return 1;
}
return 0;
}
int main ()
{
int index;
struct Bill bill;
scanf ("%d", &bill.N);
bill.prices[bill.N];
for (index = 0; index <= bill.N - 1; index++)
{
scanf ("%d", &bill.prices[index]);
}
setTotal (&bill);
if (isEligibleForDiscount (&bill))
{
bill.total = bill.total * 0.9;
}
printf ("%.2lf", bill.total);
return 0;
}
2. C – Function Pointer – Print OddEven (Id-5297)
#include<stdio.h>
void printOdd (int start, int end)
{
start = start % 2 != 0 ? start : start + 1;
while (start <= end)
{
printf ("%d ", start);
start += 2;
}
}
void printEven (int start, int end)
{
start = start % 2 == 0 ? start : start + 1;
while (start <= end)
{
printf ("%d ", start);
start += 2;
}
}
void dispatcher (void (*func) (int, int), int start, int end)
{
func (start, end);
}
int main ()
{
int even, start, end;
scanf ("%d %d %d", &even, &start, &end);
void (*funcPtr) (int, int) = even == 1 ? printEven : printOdd;
dispatcher (funcPtr, start, end);
return 0;
}
0 Comments