Submission to Programming and Logic Building
Submission to Programming and Logic Building
Building
Batch: 2024-28
Sem: I
1. Hello World
INPUT:
#include <stdio.h>
int main() {
printf("Hello, This is my first c program World!\n");
return 0;
}
OUTPUT:
Hello, This is my first c program World!
--------------------------------
Process exited after 0.01401 seconds with return value 0
2.ADDITION PROGRAM
INPUT:
#include <stdio.h>
int main() {
int num1, num2, sum;
// Ask the user to input two numbers
printf("Enter first number: ");
scanf("%d", &num1);
return 0;
}
OUTPUT:
Enter first number: 5
Enter second number: 8
The sum of 5 and 8 is: 13
--------------------------------
Process exited after 11.83 seconds with return value 0
3.CALCULATOR PROGRAM
INPUT:
#include <stdio.h>
int main() {
float num1, num2, result;
char operator;
return 0;
}
OUTPUT:
Enter first number: 43
Enter operator (+, -, *, /): *
Enter second number: 8
Result: 344.00
--------------------------------
Process exited after 19.03 seconds with return value 0
int main() {
char name[100];
int prn, sub1, sub2, sub3, sub4;
float totalmarks, percentage;
char grade;
// Display grade
printf("Your grade is: %c\n", grade);
return 0;
}
OUTPUT:
Welcome to the program
Enter student name: ANSH JAIN
Enter your PRN: 24070121005
Enter marks for 4 subjects (out of 100):
70
80
90
85
Your total marks obtained is 325.00
Your percentage is 81.25%
Your grade is: B
--------------------------------
Process exited after 57.44 seconds with return value 0
int main() {
// Declare variables
float L, P1, P2, w; // Length of beam, point loads, and
UDL
float a, b; // Positions of point loads
float RA, RB; // Reaction forces at supports
float totalLoad, momentAboutA;
return 0;
}
OUTPUT:
Enter length of the beam (in meters): 8
Enter the first point load (P1) in Newtons: 4
Enter the distance of first point load from left support (a):
5
Enter the second point load (P2) in Newtons: 9
Enter the distance of second point load from left support
(b): 3
Enter the uniformly distributed load (w) in Newtons per
meter: 5
The reaction at support A (RA) is: 37.13 N
The reaction at support B (RB) is: 15.88 N
--------------------------------
Process exited after 65.04 seconds with return value 0
6. Multiplication Function
INPUT:
#include <stdio.h>
int main() {
float num1, num2, result;
return 0;
}
OUTPUT:
Enter first number: 8
Enter second number: 5
The product of 8.00 and 5.00 is: 40.00
--------------------------------
Process exited after 6.648 seconds with return value 0
// Function declarations
float add(float num1, float num2);
float subtract(float num1, float num2);
float multiply(float num1, float num2);
float divide(float num1, float num2);
int main() {
float num1, num2, result;
int choice;
// Display menu
printf("Simple Calculator\n");
printf("1. Addition\n");
printf("2. Subtraction\n");
printf("3. Multiplication\n");
printf("4. Division\n");
printf("Enter your choice (1-4): ");
scanf("%d", &choice);
return 0;
}
OUTPUT:
Simple Calculator
1. Addition
2. Subtraction
3. Multiplication
4. Division
Enter your choice (1-4): 4
Enter first number: 55
Enter second number: 90
The result of 55.00 / 90.00 is: 0.61
--------------------------------
Process exited after 19.28 seconds with return value 0
int main() {
double L; // Length of the beam
double P; // Magnitude of the load
double a; // Distance of the load from the left
support
double R1, R2; // Reactions at the left and right
supports
double M; // Moment about a point
// Validate input
if (a > L || a < 0) {
printf("Invalid load position! It should be between 0
and L.\n");
return 1;
}
return 0;
}
OUTPUT:
Enter the length of the beam (L): 10
Enter the magnitude of the load (P): 500
Enter the distance of the load from the left support (a): 4
--------------------------------
Process exited after 36.57 seconds with return value 0
return 0;
}
OUTPUT:
Enter the number of students: 2
--------------------------------
Process exited after 621.9 seconds with return value 0
int main() {
int n, i;
struct Book books[MAX_BOOKS];
printf("--------------------------------------------------------------------
----------\n");
for (i = 0; i < n; i++) {
printf("%-10d %-30s %-20s %-10.2f %-10d\n",
books[i].id, books[i].title, books[i].author,
books[i].price, books[i].quantity);
}
return 0;
}
OUTPUT:
Enter the number of books: 1
--------------------------------
Process exited after 39.72 seconds with return value 0