0% found this document useful (0 votes)
14 views7 pages

W4LABB F6 Hannah Jeg320869

Uploaded by

Hannah mnq
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)
14 views7 pages

W4LABB F6 Hannah Jeg320869

Uploaded by

Hannah mnq
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/ 7

/*1.

Write a C program to print a block F using the hash (#), where the F has a height of seven characters
and width of five and six characters. And also print a very large 'C'.*/

#include<stdio.h>

int main ()

printf("######\n#\n#\n#####\n#\n#\n#\n\n\n");

printf(" ######\n## ##\n#\n#\n#\n#\n#\n## ##\n ######");

return 0;

}
/*2.Write a C program to compute the perimeter and area of a rectangle with a height of 7 inches and
width of 5 inches*/

#include<stdio.h>

int main ()

int h=7;

int w=5;

int p=2*(h+w);

int a=h*w;

printf("Perimeter of the rectangle is = %d inches.\n",p);

printf("Area of the rectangle = %d square inches.",a);

return 0;

/*3.Write a C program that accepts an employee's ID, total worked hours in a month and the amount he
received per hour. Print the ID and salary (with two decimal places) of the employee for a particular
month.*/

#include<stdio.h>

int main ()

char ID[10];

int wh;
int ah;

printf("Input the employees ID (max 10 chars.):");

scanf("%s",ID);

printf("\nInput the working hours:");

scanf("%d",&wh);

printf("\nSalary amount/hr:");

scanf("%d",&ah);

printf("Employees ID:%s\n",ID);

float s=wh*ah;

printf("Salary= U$ %.2f",s);

return 0;

/*4. Write a C program to read an amount (integer value) and break the amount into the

smallest possible number of bank notes.*/

#include<stdio.h>

int main()

int a;
printf("Enter the amount:");

scanf("%d",&a);

int n=a/100;

printf("\n There are: \n%d Note(s) of 100.00",n);

a=a-(n*100);

n=a/50;

printf("\n%d Note(s) of 50.00",n);

a=a-(n*50);

n=a/10;

printf("\n%d Note(s) of 10.00",n);

a=a-(n*10);

n=a/5;

printf("\n%d Note(s) of 5.00",n);

a=a-(n*5);

n=a/2;

printf("\n%d Note(s) of 2.00",n);

a=a-(n*2);

n=0;

printf("\n%d Note(s) of 1.00",n);

return 0;

}
/*5. Write a C program to convert a given integer (in days) to years, months and days,

assuming that all months have 30 days and all years have 365 days.*/

#include<stdio.h>

int main()

int d;

printf("Input the number of days: ");

scanf("%d",&d);

int y=d/365;

printf("\n%d Year(s).",y);

d=d-(y*365);

y=d/30;

printf("\n%d Month(s).",y);

d=d-(y*30);

printf("\n%d Day(s).",d);

return 0;

}
/*6. Write a C program to check if two numbers in a pair are in ascending order or descending

order.*/

#include<stdio.h>

int main()

int a,b;

printf("Input pair of numbers.\nInput first number of the pair: ");

scanf("%d",&a);

printf("Input second number of the pair: ");

scanf("%d",&b);

if (a<b)

printf("The numbers are in ascending order.");

else

printf("The numbers are in descending order.");

return 0;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy