0% found this document useful (0 votes)
64 views26 pages

Assignment#02 of CP

The document contains code for a Covid-19 analyzer program that takes in patient data and determines the severity of the case. It includes: 1) Functions to output different medication recommendations based on the severity of the case determined by the input data. 2) A main function that gets patient data as input, calls the performTest function to analyze the data and determine the case severity, and outputs the results including the recommended medications. 3) The performTest function takes in patient data, compares it to thresholds to determine the case severity ("case" 1-5 or "no case"), and outputs the results and recommendation.

Uploaded by

Abdullah Abid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views26 pages

Assignment#02 of CP

The document contains code for a Covid-19 analyzer program that takes in patient data and determines the severity of the case. It includes: 1) Functions to output different medication recommendations based on the severity of the case determined by the input data. 2) A main function that gets patient data as input, calls the performTest function to analyze the data and determine the case severity, and outputs the results including the recommended medications. 3) The performTest function takes in patient data, compares it to thresholds to determine the case severity ("case" 1-5 or "no case"), and outputs the results and recommendation.

Uploaded by

Abdullah Abid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Name: Abdullah Abid Reg.

# BEE193041 Course: CP

Assignment#02
Q#01
Covid-19 Analyzer Program

Code:
#include<stdio.h>
#include<iostream>
void TakeCare()
{
printf("Take Care\n");

}
void Medication1()
{

printf("\n\n\n\n\n**********Medication**********\n\n\n\n\n");

printf("\n\n\n*****Medication 1*****\n\n\n");
printf("Arbidol tablets 200 mg tid\n");
printf("Lopinavir/Ritonav ir 2 tablets po q12h\n");
printf("Interferon spray 1 spray pr. tid\n");
}
void Medication2()
{
printf("\n\n\n\n\n**********Medication**********\n\n\n\n\n");

printf("\n\n\n*****Medication 2*****\n\n\n");
printf("Arbidol tablets 200 mg tid\n");
printf("Lopinavir/Ritonav ir 2 tablets po q12h\n");
printf("Interferon spray 1 spray pr. tid\n");
printf("NS 100 ml+Ambroxol 30mg ivgtt bid\n");
}
void Medication3()
{
printf("\n\n\n\n\n**********Medication**********\n\n\n\n\n");

printf("\n\n\n*****Medication 3*****\n\n\n");
printf("Arbidol tablets 200 mg tid\n");
printf("Lopinavir/Ritonav ir 2 tablets po q12h\n");
printf("Interferon spray 1 spray pr. tid\n");
printf("NS 100ml + pantoprazole 40 mg ivgtt qd\n");
printf("NS 100ml + methylprednisolone 40mg ivgtt qd\n");
printf("Caltrate 1 tablet qd Immunoglobulin 20 g ivgtt qd\n");
printf("NS 100 ml+Ambroxol 30mg ivgtt bid\n");
}
void Medication4()
{
printf("\n\n\n\n\n**********Medication**********\n\n\n\n\n");

printf("\n\n\n*****Medication 4*****\n\n\n");
printf("Arbidol tablet 200 mg po. tid\n");
printf("opinavir/Ritonavir 2 tablets q12h (or darunavir 1 tablet qd)\n");
printf("NS 1 0 ml+ methylprednisolone 40 mg iv ql 2h \n");
printf("NS 100 ml+ pantoprazole 40 mg ivgtt qd\n");
printf(" lmmunoglobulin 20 g ivgtt qd \n");
printf(" Thymic peptides 1.6 mg ih biw \n");
printf(" Thymic peptides 1.6 mg ih biw \n");
printf(" NS 10 ml+ Ambroxol 30 mg iv bid\n");
printf("NS 50 ml+ isoproterenol 2 mg ivvp once \n");
printf(" Human serum albumin 1og ivgtt qd \n");
printf(" NSlO0 ml+ piperacillin/tazobacta m 4.5 ivgtt qBh\n");
printf("Enteral nutrition suspension {Peptisorb liquid) 500 ml nasogastric feeding
bid\n");

}
int performTest(char name[30], int age, char gender[8], float fev, char pmm[10], int rts,
int lp, char aof[10])
{
if (fev >= 97 && fev <= 98.6 || pmm == "No" && rts >= 12 || rts <= 20 && lp == 0
|| aof == "No")
{
printf("Name:%s\n\n\n", name);
printf("Age:%i\n\n\n", age);
printf("Gender:%s\n\n\n", gender);
printf("Fever:%f\n\n\n", fev);
printf("Pneumonia Mainfestation:%s\n\n\n", pmm);
printf("Respiratory tract sympoms:%i\n\n\n", rts);
printf("Lesion Progression Breath//min%i\n\n\n", lp);
printf("Any Organ Failuer%s\n\n\n", aof);
printf("Diagnosed with ""case""1 \n\n\nNot Detected");
{
TakeCare();
}
}
else if (fev >= 99 && fev <= 100 && pmm == "No" && rts >= 21 || rts <= 22 && lp >=
0 || lp <= 10 && aof == "No")
{
printf("\nName:%s\n\n", name);
printf("\nAge:%i\n\n", age);
printf("\nGender:%s\n", gender);
printf("\nFever%f\n\n", fev);
printf("\nPneumonia Mainfestation%s\n\n", pmm);
printf("Respiratory tract sympoms:%i\n\n", rts);
printf("\nLesion Progression//min:%i\n\n", lp);
printf("%\nAny Organ Failuer%s\n\n", aof);
printf("\nDiagnosed with ""case""2\n\n\nMild Case of COVID-19");

{
Medication1();
}
}
else if (fev >= 100 && fev <= 101 || pmm == "Yes" && rts >= 22 || rts <= 29 && lp
>= 0 || lp <= 20 || aof == "No")
{
printf("\nName:%s\n\n", name);
printf("\nAge:%i\n\n", age);
printf("\nGender:%s\n\n", gender);
printf("\nFever%f\n\n", fev);
printf("\nPneumonia Mainfestation%s\n\n", pmm);
printf("Respiratory tract symptoms:%i\n\n", rts);
printf("\nLesion Progression Breath//min%i\n\n", lp);
printf("%\nAny Organ Failuer%s\n\n", aof);
printf("\nDiagnosed with ""case""3\n\n\nModerate Case of COVID-19");
{
Medication2();
}
}
else if (fev >= 101 && pmm == "Yes" || rts >= 30 && rts <= 49 && lp > 50 || aof ==
"No")
{
printf("\nName:%s\n\n", name);
printf("\nAge:%i\n\n", age);
printf("\nGender:%s\n\n", gender);
printf("\nFever%f\n\n", fev);
printf("\nPneumonia Mainfestation%s\n\n", pmm);
printf("Respiratory tract sympoms:%i\n\n", rts);
printf("\nLesion Progression Breath//min%i\n\n", lp);
printf("%\nAny Organ Failuer%s\n\n", aof);

printf("\nDiagnosed with ""case""4\n\n\nSevere Case of COVID-19");


{
Medication3();
}
}
else if (fev >= 101 && pmm == "Yes" || rts >= 50 || lp > 50 && aof == "Yes")
{
printf("\nName:%s\n\n", name);
printf("\nAge:%i\n\n", age);
printf("\nGender:%s\n\n", gender);
printf("\nFever%f\n\n", fev);
printf("\nPneumonia Mainfestation%s\n\n", pmm);
printf("Respiratory tract sympoms:%i\n\n", rts);
printf("\Lesion Progression Breath//min%i\n\n", lp);
printf("%\nAny Organ Failuer%s\n", aof);

printf("\nDiagnosed with ""case""5 \n\n\nCritical Case of COVID-19");


{
Medication4();
}
}
else
{
printf("\nName:%s\n\n", name);
printf("\nAge:%i\n\n", age);
printf("\nGender:%s\n\n", gender);
printf("\nFever%f\n\n", fev);
printf("\nPneumonia Mainfestation:%s\n\n", pmm);
printf("Respiratory tract sympoms:%i\n\n", rts);
printf("\nLession Progression Breath//min%i\n\n", lp);
printf("\nAny Organ Failuer%s\n\n", aof);
printf("\nDiagnosed with ""no case""\nNot Detected");
printf("\nNo Rule Found");
}
return 0;
}

int main()
{
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 1.\n");
printf("/*==================================================================\n");
int x;
int ans;
char again;
do {
printf("\nPlease Enter Patient Information\n\n\n");
printf("\nEnter Name PLease = ");
char name[30];
gets_s(name);
char pmm[8];
printf("\nEnter Pneumonia Manifestations PLease = ");
gets_s(pmm);
char aof[10];
printf("\nEnter Any Organ failure PLease = ");
gets_s(aof);
int age;
char gender[8];
printf("\nEnter Gender PLease = ");
gets_s(gender);
printf("\nEnter Age PLease = ");
scanf_s("%i", &age);
float fev;
printf("\nEnter Fever PLease = ");
scanf_s("%f", &fev);
int rts;
printf("\nEnter Respiratory tract sympoms PLease = ");
scanf_s("%i", &rts);
int lp;
printf("\nEnter Lesion Progression PLease = ");
scanf_s("%d", &lp);
ans = performTest(name, age, gender, fev, pmm, rts, lp, aof);
printf("do you want to conitnue or exit (Y/N)\n");
scanf_s("%c", &again);
again = getchar();
getchar();
} while (again == 'Y');
getchar();

scanf_s("%d", &x);
return 0;

Output:
Q#02
(a)
Code:
#include<stdio.h>
int rfunction(int a, int b);
void main(void) {
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 2(a)\n");
printf("/*==================================================================\n");

int x, y;
printf(" enter two integers: ");
scanf_s("%d %d", &x, &y);
printf("answer= %d\n", rfunction(x, y));
}
int rfunction(int a, int b) {
int x;
if (b == 1)
{
return a;
}
else {
return a + rfunction(a, b - 1);
}
scanf_s("%d", &x);
}

Output:
(b)

Code:
#include<stdio.h>
void use_local(void);
void use_static_local(void);
void use_global(void);
int x = 10;
void main(void)
{
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 2(b)\n");
printf("/*==================================================================\n");

int x = 5;
printf("local x in outer scope of main is %d\n", x);
{
int x = 7;
printf("local x in inner scope of main is %d\n", x);
}
printf("local x in outer scope of main is %d\n", x);
void use_local();
void use_static_local();
void use_global();
void use_local();
void use_static_local();
void use_global();
printf("\nlocal x in main is %d\n", x);
}
void use_local(void)
{
int x = 25;
printf("\nlocal x in use_local is %d after entering use_local\n", x);
x = x + 2;
printf("local x in use local is %d before exiting use_local\n", x);
}
void use_static_local(void)
{
int x = 100;
printf("\nlocal static x is %d on entering use_static_local\n", x);
x = x + 20;
printf("\nlocal static x is %d on exiting use_static_local\n", x);
}
void use_global(void)
{
int x = 100;
printf("\nglobal x is %d on entering use_global\n", x);
x = x + 20;
printf("\nglobal x is %d on exiting use_global\n", x);
}

Output:

(c)

Code:

#include<stdio.h>
void printonscreen(int x);
void main()
{
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 2(c)\n");
printf("/*==================================================================\n");

int i;
for (i = 10; i > 0; i--)
{
printonscreen(i);
}
}
void printonscreen(int x)
{
int j;
for (j = 0; j < x; j++)
printf("#");
printf("\n");
}

Output:
Q#03
Stars Pattern Of Diamond
Code:
#include <stdio.h>
int printupstar(int nLevel);
int printMiddleStar(int stars);
int printDownStar(int nLevel, int stars);
int main() {
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 3\n");
printf("/*==================================================================\n");

int x;
int nLevel;
int stars1;
int stars2;
printf("Enter the Level Size\n");
scanf_s("%d", &nLevel);
int stars = printupstar(nLevel);
stars1 = printMiddleStar(stars);
stars2 = printDownStar(nLevel, stars);
scanf_s("%d", &x);
return 0;
}

int printupstar(int nLevel) {


nLevel = nLevel >= 2 ? nLevel : 2;
int stars = 1;
int nSpace = nLevel - 1;
int i;
int stars5, stars6;
int printSpaces(int nSpace);
int printStars(int stars);

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


{
printf("\n");
stars5 = printSpaces(nSpace);
stars6 = printStars(stars);
stars += 2;
nSpace--;
}
return stars - 2;
}

int printMiddleStar(int stars) {


printf("\n");
stars = stars + 2;
while (stars > 0) {
printf("*");
stars--;
}
return 0;
}

int printDownStar(int nLevel, int stars) {


int nSpace = 1;
int printSpaces(int nSpace);
int printStars(int stars);
int i;
int stars3;
int stars4;
for (i = nLevel; i >= 1; i--) {
printf("\n");
stars3 = printSpaces(nSpace);
stars4 = printStars(stars);
stars -= 2;
nSpace++;
}
return 0;
}

int printStars(int nStar) {


while (nStar > 0) {
printf("*");
nStar--;
}
return 0;
}

int printSpaces(int nSpace) {


while (nSpace > 0) {
printf(" ");
nSpace--;
}
return 0;
}

Output:
Q#04

Stars Pattern Of Pyramid


Code:
#include <stdio.h>
int printupstar(int nLevel);
int printMiddleStar(int stars);
int main() {
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 4\n");
printf("/*==================================================================\n");

int x;
int nLevel;
int stars1;
int stars2;
printf("Enter the Level Size\n");
scanf_s("%d", &nLevel);
int stars = printupstar(nLevel);
stars1 = printMiddleStar(stars);
scanf_s("%d", &x);
return 0;
}

int printupstar(int nLevel) {


nLevel = nLevel >= 2 ? nLevel : 2;
int stars = 1;
int nSpace = nLevel - 1;
int i;
int stars5, stars6;
int printSpaces(int nSpace);
int printStars(int stars);

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


{
printf("\n");
stars5 = printSpaces(nSpace);
stars6 = printStars(stars);
stars += 2;
nSpace--;
}
return stars - 2;
}

int printMiddleStar(int stars) {


printf("\n");
stars = stars + 2;
while (stars > 0) {
printf("*");
stars--;
}
return 0;
}

int printStars(int nStar) {


while (nStar > 0) {
printf("*");
nStar--;
}
return 0;
}

int printSpaces(int nSpace) {


while (nSpace > 0) {
printf(" ");
nSpace--;
}
return 0;
}
Output:

Q#05

Stars Pattern Of Heart

(program will ask the user to enter input


So enter the values in sequence
2,17,9,17)

Code:
#include<stdio.h>
int heart(int row1, int column1);
int heart1(int row2, int column2);
int main()
{
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 5\n");
printf("/*==================================================================\n");

int stars;
int stars1;
int row2 = 0;
int column2 = 0;

int column1 = 0;
int row1 = 0;
printf("enter the rows and columns\n");
scanf_s("%d%d%d%d", &row1, &column1, &row2, &column2);
stars = heart(row1, column1);
stars1 = heart1(row2, column2);

}
int heart(int row1, int column1)
{

int i, j;
for (i = 0; i <= row1; i++) {
for (j = 1; j <= column1; j++)
{
if ((j >= 3 - i && j <= 6 + i) || (j >= 12 - i && j <= 15 + i))
printf("*");
else
printf(" ");
}printf("\n");
}
return 0;
}
int heart1(int row2, int column2)
{
int i, j;

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


{
for (j = 1; j <= column2; j++)
{
if (j >= i + 1 && j <= 17 - i)
printf("*");
else
printf(" ");
}printf("\n");
}
return 0;
}
Output:

Print heart of stars pattern


(User is not asked to enter values)

Code:
#include<stdio.h>
int heart(int nlevel);
int heart1(int star);
int main()
{
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 5\n");
printf("/*==================================================================\n");

int nlevel = 0;
int star = 0;
int ans;
int ans1;
ans = heart(nlevel);
ans1 = heart1(star);
}
int heart(int nlevel)
{
int row, col;
for (row = 0; row <= 2; row++)
{
for (col = 1; col <= 17; col++)
{

if ((col >= 3 - row && col <= 6 + row) || (col >= 12 - row && col <=
15 + row))
printf("*");
else
printf(" ");
}printf("\n");
}
return 0;
}
int heart1(int star)
{
int row, col;
for (row = 0; row < 9; row++)
{
for (col = 1; col <= 17; col++)
{
if (col >= row + 1 && col <= 17 - row)
printf("*");
else
printf(" ");
}printf("\n");
}
return 0;
}

Output:
Q#06
(a)
Area of circle
Code:
#include<stdio.h>
float area(int r);
int main()
{
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 6(a)\n");
printf("/*==================================================================\n");

float r;

printf("enter the radius of a circle\n");


scanf_s("%f", &r);
float ans;
ans = area(r);

printf("%r=%f\n", ans);
}
float area(int r)
{
float result;
result = 3.14*r*r;
return result;
}

Output:

(b)

Average of three number


Code:

#include<stdio.h>
float avg(float a, float b, float c);
void main()
{
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 6(b)\n");
printf("/*==================================================================\n");
float n1 = 1.5, n2 = 2.5, n3 = 3.5;
avg(n1, n2, n3);
}
float avg(float a, float b, float c)
{
float result;
result = (a + b + c) / 3.0;
printf("result=%f", result);
return result;
}

Output:

(c)
Conversion of Celsius to Fahrenheit

Code:
#include <stdio.h>
float Fahrenheit(float c);
void main()
{
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 6(c)\n");
printf("/*==================================================================\n");

float c;
printf("\nEnter the Temperature in Celsius : ");
scanf_s("%f", &c);
Fahrenheit(c);
}
float Fahrenheit(float c)
{
float result;
result = (9 * c) / 5 + 32;
printf("the temperature of fahrenheit is = %0.2f ", result, c, (9 * c) / 5 + 32);
return result;
}

Output:

(d)

Factorial of a number
Code:
#include<stdio.h>
#include<conio.h>
int factorial(int);
void main()
{
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 6(d)\n");
printf("/*==================================================================\n");
int n;
printf("enter the number\n");
scanf_s("%d", &n);
printf("the factorial of %d is:%d", n, factorial(n));

int factorial(int n)
{
int i, fact = 1;
for (i = 1; i <= n; i++)
{
fact = fact * i;
}
return fact;
}

Output:
(e)

GCD of two numbers

Code:
#include<stdio.h>
int function(int x, int y);
int main()
{
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 6(e)\n");
printf("/*==================================================================\n");

int x, y;
int ans;
printf("Enter the first number==");
scanf_s("%d", &x);
printf("Enter the secound number==");
scanf_s("%d", &y);
ans = function(x, y);

}
int function(int x, int y)
{
int result;
int i, gcd;
for (i = 1; i <= x && i <= y; ++i)

{
if (x%i == 0 && y%i == 0)
gcd = i;
}
result = gcd;
printf("gcd of %d and %d is: %d", x, y, gcd, result);

return result;
}
Output:

(f)
LCM of two numbers

Code:
#include <stdio.h>
int gcd(int a, int b);
int lcm(int a, int b);
int main()
{
printf("/*=================================================================\n");
printf("/* CSEE1122: Computer Programming\n");
printf("/* Student Name : Abdullah Abid\n");
printf("/* Registration No.: BEE193041\n");
printf("/* Section No.: 1\n");
printf("/* Assignment No.: 2\n");
printf("/* Question No.: 6(f)\n");
printf("/*==================================================================\n");

int a, b;
int ans;
int ans1;
printf("enter two numbers\n");
scanf_s("%d%d", &a, &b);
ans = lcm(a, b);
ans1 = gcd(a, b);

}
int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
int lcm(int a, int b)
{
int result;
result = (a*b) / gcd(a, b);
printf("lcm is = %d", result, a, b, gcd);
return result;
}

Output:

You might also like