You are on page 1of 6

#include <stdio.

h>

void main()
{
int agents, i, a =0, b =0, c=0;
double volume;

printf("How many insurance agents in your company? ");


scanf("%d", &agents);

for (i = 0; i <= 4; i++)


{
printf("Insurance agent no. %d sales volume:", i + 1);
scanf("%lf", &volume);
}

for (i = 0; i <= 4; i++)


{
if (volume > 80000)
a = a + 1;
else if (volume >= 30000 && volume <= 80000)
b = b + 1;
else if (volume < 30000)
c = c + 1;
}

printf("There are %d excellent sales agent, %d good sales agents and %d poor sales
agent inyour company.\n ",a,b,c );
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void main(void)
{
char copy[20]="";
char student_name[20];
char student_id[9];
char student_age[3];
int a;
int count = 0;

printf("Enter your name:");


scanf("%s", &student_name);
printf("Enter your student ID:");
scanf("%s", &student_id);
printf("Enter your age:");
scanf("%s", &student_age);

strncpy(copy, student_name, 6);


strncat(copy, student_id, 2);
strncat(copy, student_age, 2);

printf("Your passcode is:%s\n", copy);


const char* c = copy;
for (a = 0; c[a]; a++)
{
if (c[a] != "");
count ++;
}
printf("The passcode has %d characters.\n", count);

#include <stdio.h>
int MPA(int amount);
int Kinokaya(int amount);
int Pupil(int amount);

void main()
{
int amount,M, K, P, sum= 0, y =0, total = 0;

printf("Enter planned use amount of BB1M voucher: ");


scanf("%d", &amount);

if (amount < 500)


{
printf("Please enter valid usage amount of voucher.\n");
printf("It must be a multiplier of *50.\n");
printf("Enter planned use amount of BB1M voucher: ");
scanf("%d", &amount);
}

M = MPA(amount);
K = Kinokaya(amount);
P = Pupil(amount);

if (M > K && M > P)


printf("MPA bookstore has the best value for BB1M usage\n");

int MPA(int amount)


{
int cash, total;

cash = amount / 250 * 50;


total = amount + cash;

printf("Total cash value for MPA bookstore is %d\n", total);


return total;

int Kinokaya(int amount)


{
int cash, sum;
cash = 50;
sum = amount + cash;

printf("Total cash value for Kinokaya bookstore is %d\n", sum);


return sum;

}
int Pupil(int amount)
{
int cash, y;

cash = 60;
y = amount + cash;

printf("Total cash value for Pupil bookstore is %d\n", y);

return y;
}

#include <stdio.h>

void main(void)
{
int a[5];
int i, count = 0, j;
for (i = 0; i < 5; i++)
{
printf("Enter a number: ");
scanf("%d", &a[i]);
}

for (i = 0; i <5; i++)


{
count = 1;

for (j = i + 1; j <= 5 - 1; j++)


{
if (a[i] == a[j] && a[i] != '\0')
{
count++;
a[j] = '\0';
}
}

if (a[i] != '\0')
{
printf("No. %d appears %d times\n", a[i], count);

}
}

#include <stdio.h>
double getCarryMark();
double getFinalMark();
double calculateScore(double C, double F);
void printMessage();
void printMenu();

int main()
{
double C, F, total;
int x, i;

printMenu();
printf("How many students? ");
scanf("%d", &x);

for (i = 1; i <= x; i++)


{
printf("\nStudent: %d\n", i);
C = getCarryMark();
F = getFinalMark();
total = calculateScore(C, F);
printMessage(total);

void printMenu()
{
printf("Hello!\n");
}

double getCarryMark()
{
double y;

printf("Enter your carry mark: ");


scanf("%lf", &y);

if (y > 50)
{
printf("Invalid data. The value is from 0 to 50. Please re-enter the value.\n");
scanf("%lf", &y);
}

return y;
}

double getFinalMark()
{
double z;

printf("Enter your final exam mark: ");


scanf("%lf", &z);
if (z > 100)
{
printf("Invalid data. The value is from 0 to 100. Please re-enter the value.\n");
scanf("%lf", &z);
}

return z;
}

double calculateScore(double y, double z)


{
double a, b, total;

a = y;
b = z;

z = (0.5) * z;
total = y + z;
printf("Total score is %.2lf\n", total);

return total;
}

void printMessage(double total)


{

if (total >= 80 && total <= 100)


printf("You are an extraordinary student.\n");
else if (total >= 60 && total <= 79)
printf("You are good at this course.\n");
else if (total >= 50 && total <= 59)
printf("Not good enough but don't give up easily.\n");
else if (total >= 0 && total <= 49)
printf("You better repeat this course.\n");

}
#include <stdio.h>

void main()
{
int num[20], i, total = 0;

for (i = 0; i <= 19; i++)


{
printf("Enter the numbers: ");
scanf("%d", &num[i]);
}

printf("Odd numbers are: ");


for (i = 0; i <= 19; i++)
{
if (num[i] % 2 != 0)
{

printf("\n %d \n", num[i]);


total = total + num[i];
}

printf("The total of odd numbers are: %d \n", total);

You might also like