move exercises and lectures into subfolders

This commit is contained in:
2023-10-15 15:34:53 +01:00
parent 775b4bd643
commit 74092a17aa
177 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
// Declare and initialise as required
int a = 1,b = 4;
float ans;
// Perform calculation
// This time a & b are treated as if they are floats
// the result of this float calculation is stored in ans
ans = (float)a / (float)b;
// Display answer
printf ("\nThe answer is %f",ans);
return 0;
}

View File

@@ -0,0 +1,20 @@
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
// Declare and initialise as required
int a = 1,b = 4;
float ans;
// Perform calculation
// a and b are integers so the answer will be the result of the integer division
ans = a / b;
// Display answer
printf ("\nThe answer is %f",ans);
return 0;
}

View File

@@ -0,0 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
// A variable to store a name (maximum 49 characters)
char Name[50];
// Declare multiple strings on the same line
char AddressLine1[100], AddressLine2[100], PostCode[10];
// all done
return 0;
}

View File

@@ -0,0 +1,4 @@
#include <stdio.h>
int main(void) { int revenue = 80; int cost = 50; int roi;
roi = (100 * (revenue - cost)) / cost; if (roi >= 0) {
printf ("%d\n", roi); } return 0; }

View File

@@ -0,0 +1,4 @@
#include <stdio.h>
/* My first program */
int main(void) { printf("Hello World"); return 0; }

View File

@@ -0,0 +1,19 @@
#include <stdio.h>
int main(void)
{
// Declare variables and give initial values
int revenue = 80;
int cost = 50;
int roi;
// Perform calculation
roi = (100 * (revenue - cost)) / cost;
// Make decision based on value of roi
if (roi >= 0)
{
printf ("%d\n", roi);
}
return 0; // Exit indicating success
}

View File

@@ -0,0 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int a = 6,b = 7,c; // Declare and initialiase as required
c = a + b; // Add the values and store in c
}

View File

@@ -0,0 +1,8 @@
#include <stdio.h>
/* My first program */
int main(void)
{
printf("Hello World");
return 0;
}