Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0bda1c6
Create c structures book
Jona-boop Oct 22, 2024
37880da
Create program to find the area of a rectangle #include <stdio.h> in…
Jona-boop Oct 22, 2024
0eaa56e
Create students grading system
Jona-boop Oct 22, 2024
a4f2732
Create bank loan qualification
Jona-boop Oct 22, 2024
95e463a
Create area of arectangle
Jona-boop Oct 22, 2024
081098c
Create library program
Jona-boop Oct 29, 2024
953c3b3
Create c file program
Jona-boop Oct 29, 2024
7fdd5e8
Rename area of a rectangle/program to find the area of a rectangle #…
Jona-boop Oct 29, 2024
5fde5b0
Rename bank loan qualification to bank loan qualification.c
Jona-boop Oct 29, 2024
703c388
Rename c file program to c file program.c
Jona-boop Oct 29, 2024
b7ed5cf
Rename c structures book to c structures book.c
Jona-boop Oct 29, 2024
8de90e5
Rename library program to library program.c
Jona-boop Oct 29, 2024
14a52fa
Rename students grading system to students grading system.c
Jona-boop Oct 29, 2024
b9d2a8d
Create C program to check whether a number is even.c
Jona-boop Nov 5, 2024
e553682
Create Employee program.c
Jona-boop Nov 5, 2024
8f0e628
Create do while program.c
Jona-boop Nov 12, 2024
b645159
Create for loop.c
Jona-boop Nov 12, 2024
472b901
Create Appending c file.c
Jona-boop Nov 12, 2024
1391220
Create Prompt variables.c
Jona-boop Nov 12, 2024
cf28323
Create write to a file.c
Jona-boop Nov 12, 2024
f05c2ee
Create 5 student.c
Jona-boop Nov 12, 2024
37533e3
Rename area of arectangle to area of arectangle.c
Jona-boop Nov 12, 2024
2ea322c
Create n students.c
Jona-boop Nov 12, 2024
d47364b
Add GitHub Actions workflow for npm package publishing
Jona-boop Feb 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/npm-publish-github-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm test

publish-gpr:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
32 changes: 32 additions & 0 deletions 5 student.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//A C program that reads the names and marks of 5 students
#include <stdio.h>
#include <stdlib.h>

int main() {
FILE *fptr;
char name[50];
int marks, i;

// Open the file in write mode
fptr = fopen("C:\\Users\\clemoh\\OneDrive\\Desktop\\cfiles\\students.txt", "w");
if (fptr == NULL) {
printf("Error opening the file.\n");
exit(1);
}

// Loop to read name and marks of 5 students and store them in the file
for (i = 1; i <= 5; i++) {
printf("Enter name of student %d: ", i);
scanf("%s", name);
printf("Enter marks of student %d: ", i);
scanf("%d", &marks);

// Write the name and marks to the file
fprintf(fptr, "Student %d: Name = %s, Marks = %d\n", i, name, marks);
}

fclose(fptr);
printf("Data written successfully to students.txt.\n");
return 0;
}
}
29 changes: 29 additions & 0 deletions Appending c file.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//appending a sentence in a file
#include <stdio.h>
#include <stdlib.h>

void appendToFile() {
FILE *fptr;
char sentence[100];

// Open the file in append mode
fptr = fopen("C:\\Users\\clemoh\\OneDrive\\Desktop\\cfiles\\data.txt", "a");
if (fptr == NULL) {
printf("Error opening file for appending.\n");
exit(1);
}

// Get a second sentence from the user
printf("Enter another sentence to append (up to 100 characters): ");
fgets(sentence, sizeof(sentence), stdin);

// Append the sentence to the file
fprintf(fptr, "%s", sentence);
fclose(fptr);
printf("Sentence appended to file successfully.\n");
}

int main() {
appendToFile();
return 0;
}
13 changes: 13 additions & 0 deletions C program to check whether a number is even.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//C program to check whether a number is even
#include<stdio.h>
int main() {
int number;
printf("Enter the number");
scanf("%d", &number);
if(number % 2 == 0){
printf("The number is even\n");
}else {
printf("The number is odd\n");
}
return 0;
}
27 changes: 27 additions & 0 deletions Employee program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//C structure program
#include<stdio.h>

struct Employee{
char name[25];
char email[50];
char department[20];
float salary;
int ID;
}employee;
int main(){
struct Employee employee={
"john Doe",
"john.doe@company.com",
"Human Resources",
55000.50,
12345,

};

printf("name:%s\n",&employee.name);
printf("email:%s\n",&employee.email);
printf("department:%s\n",&employee.department);
printf("salary:%f\n",&employee.salary);
printf("ID:%d\n",&employee.ID);

return 0;
38 changes: 38 additions & 0 deletions Prompt variables.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//c variables and data types
//pre-processor directive
#include <stdio.h> scanf(), printf()
int main(){
//declaration and intialization
char a;
char name[]={};
int age;
float area;
double salary;

printf("enter character: ");
scanf("%s",&a);
printf("the character is %c \n",a);

printf("enter name: ");
scanf("%s",&name);
printf("the string is %s \n",name);

printf("enter age: ");
scanf("%d",&age);
printf("the integer is %d years \n",age);


printf("enter area: ");
scanf("%f",&area);
printf("the float is %.3f meters squared \n",area);


printf("enter salary: ");
scanf("%lf",&salary);
printf("the double is Ksh,%.2lf \n",salary);


printf("<complete...>");

return 0;
}
12 changes: 12 additions & 0 deletions area of a rectangle.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//program to find the area of a rectangle
#include <stdio.h>
int main() {
int length, width, area;
printf("length: ");
scanf("%d", &length);
printf("width: ");
scanf("%d", &width);
area = length * width;
printf("area %.d\n", area);
return 0;
}
12 changes: 12 additions & 0 deletions area of arectangle.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//program to find the area of a rectangle
#include <stdio.h>
int main() {
int length, width, area;
printf("length: ");
scanf("%d", &length);
printf("width: ");
scanf("%d", &width);
area = length * width;
printf("area %.d\n", area);
return 0;
}
16 changes: 16 additions & 0 deletions bank loan qualification.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//bank loan
#include<stdio.h>
int main(){
int age,income;
printf("enter your age:");
scanf ("%d",&age);
printf ("enter income:");
scanf("%d",&income);
if(age>=21&& income>21000){
printf("congratulations you qualify for the loan\n");
}
else{
printf("you don't qualify for the loan\n");
}
return 0;
}
22 changes: 22 additions & 0 deletions c file program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//C file handling :writing to a file
#include<stdio.h> //scanf(),printf(),fprintf(),fscanf(),fclose()
#include<stdlib.h> //exit()

int main () {
int number;
FILE *fptr; //declare pointer

fptr = fopen("C:\\users\\JonaN\\Desktop\\C program\\file.txt","w");
if (fptr==NULL){
printf("Error opening the file");
exit(1);
}
printf("Enter a random number:");
scanf("%d", &number);

fprintf(fptr, "The number entered is %d",number);
fclose(fptr);
printf("Number written succesfully");

return 0; //execution successfully
}
32 changes: 32 additions & 0 deletions c structures book.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// c structures
#include <stdio.h>
#include <string> //strcpy
stuct book {
char title[30]
char name[30]
char ISBN[13]
int publication_year;
float price;
}
int main() {
//initializing variable (operators)
strcpy(book1.title,"introducction to c structure");
strcpy(book1.name,"john smith");
strcpy(book1.ISBN,"701_354603975");
Book1.publication_year=2022;
book1.price=49.99;

printf("Title;%s\n",book1.introduction to c programming);
printf("Author %s\n",book1.john smith);
printf("publication_year %s\n",book1.2022);
printf("ISBN %s \n",book1.701_35460395);
printf("price %s\n",book1.49.99)

//printf("enter name ")
//scanf("%s",&introduction to c structure);

return 0;




18 changes: 18 additions & 0 deletions do while program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//Do while program
#include <stdio.h>

int main() {
int i = 1, n;

// Prompt user for input
printf("Enter the number of terms: ");
scanf("%d", &n);

// Do..while loop to calculate and print the cube of each number
do {
printf("Number is : %d and cube of %d is : %d\n", i, i, i * i * i);
i++;
} while (i <= n);

return 0;
}
17 changes: 17 additions & 0 deletions for loop.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//For loop program
#include <stdio.h>

int main() {
int i, n;

// Prompt user for input
printf("Enter the number of terms: ");
scanf("%d", &n);

// For loop to calculate and print the cube of each number
for (i = 1; i <= n; i++) {
printf("Number is : %d and cube of %d is : %d\n", i, i, i * i * i);
}

return 0;
}
30 changes: 30 additions & 0 deletions library program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include<stdio.h>
int main(){
int bookid;
double duedate,returndate;
double finerate,fineamount,daysoverdue;
printf("enter the bookid:");
scanf("%d",&bookid);
printf("enter the duedate:");
scanf("%lf",&duedate);
printf("enter the returndate:");
scanf("%lf",&returndate);
daysoverdue=returndate-duedate;
if(daysoverdue<=7){
finerate=20;
}
else if(daysoverdue<=14){
finerate=50;
}
else {
finerate=100;
}
fineamount=finerate*daysoverdue;
printf("bookid:%d\n",bookid);
printf("duedate:%lf\n",duedate);
printf("returndate:%lf\n",returndate);
printf("daysoverdue:%lf\n",daysoverdue);
printf("finerate:%lf\n",finerate);
printf("fineamount:%lf\n",fineamount);
return 0;
}
35 changes: 35 additions & 0 deletions n students.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//A C program that reads the names and marks of an n number of students
#include <stdio.h>
#include <stdlib.h>

int main() {
FILE *fptr;
char name[50];
int marks, i, n;

// Open the file in append mode
fptr = fopen("C:\\Users\\clemoh\\OneDrive\\Desktop\\cfiles\\students.txt", "a");
if (fptr == NULL) {
printf("Error opening the file.\n");
exit(1);
}

// Prompt user for number of students
printf("Enter the number of students: ");
scanf("%d", &n);

// Loop to read name and marks of n students and append them to the file
for (i = 1; i <= n; i++) {
printf("Enter name of student %d: ", i);
scanf("%s", name);
printf("Enter marks of student %d: ", i);
scanf("%d", &marks);

// Append the name and marks to the file
fprintf(fptr, "Student %d: Name = %s, Marks = %d\n", i, name, marks);
}

fclose(fptr);
printf("Data written successfully to students.txt.\n");
return 0;
}
Loading