-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"Updated variable naming conventions in multiple files, including C a…
…nd JavaScript code, and modified MongoDB schema definitions in Express.js models."
- Loading branch information
1 parent
1ce34b3
commit 3af1189
Showing
19 changed files
with
984 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"files.associations": { | ||
"*.ejs": "html", | ||
"stdio.h": "c" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <stdio.h> | ||
|
||
int main() { | ||
// Defining variables of different types | ||
int age = 30; // Integer variable | ||
float height = 5.9; // Floating-point variable | ||
char initial = 'A'; // Character variable | ||
char name[] = "Alice"; // String variable | ||
|
||
// Displaying an integer value | ||
printf("Age: %d\n", age); // %d format specifier displays an integer | ||
|
||
// Displaying a floating-point value with one decimal place | ||
printf("Height: %.1f meters\n", height); // %.1f format specifier displays a float with one decimal place | ||
|
||
// Displaying a single character | ||
printf("Initial: %c\n", initial); // %c format specifier displays a single character | ||
|
||
// Displaying a string | ||
printf("Name: %s\n", name); // %s format specifier displays a string | ||
|
||
// Demonstrating unsigned integer | ||
unsigned int score = 150; // Unsigned integer variable | ||
printf("Score: %u\n", score); // %u format specifier displays an unsigned integer | ||
|
||
// Demonstrating hexadecimal format | ||
int hexValue = 255; // Integer variable | ||
printf("Hexadecimal: %x\n", hexValue); // %x format specifier displays an integer in hexadecimal format | ||
|
||
// Demonstrating scientific notation for floating-point numbers | ||
float largeNumber = 123456.789; // Floating-point variable | ||
printf("Large Number: %e\n", largeNumber); // %e format specifier displays a float in scientific notation | ||
|
||
// Demonstrating pointer format | ||
int *ptr = &age; // Pointer to integer | ||
printf("Address of age: %p\n", (void*)ptr); // %p format specifier displays the memory address of the pointer | ||
|
||
// Demonstrating width and precision | ||
float preciseValue = 3.14159; // Floating-point variable | ||
printf("Precise Value: %.3f\n", preciseValue); // %.3f format specifier displays a float with three decimal places | ||
|
||
// Demonstrating width with padding | ||
int number = 42; // Integer variable | ||
printf("Number with width: %5d\n", number); // %5d format specifier displays an integer with a minimum width of 5, padded with spaces | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# C Format Specifiers | ||
|
||
In many programming languages (like Python, Java, and C++), you use print functions to display the value of a variable. However, in C, things are a bit different. | ||
|
||
In C programming, format specifiers are used in functions like `printf` and `scanf` to control the format of input and output. These specifiers tell the function how to interpret or display the data. They are crucial because C does not have higher-level features for formatted input and output like some other languages do. | ||
|
||
|
||
|
||
**C programming mein, format specifiers `printf` aur `scanf` jese functions mein use kiye jaate hain taaki input aur output ka format control kiya ja sake. Ye specifiers batate hain ki data ko kaise samjha ya dikhaya jayega. Ye zaroori hote hain kyunki C mein formatted input aur output ke liye high-level features nahi hote jaise kuch dusri programming languages mein hote hain.** | ||
|
||
|
||
|
||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Format Specifier</th> | ||
<th>Description</th> | ||
<th>Example Syntax</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td><strong>%c</strong></td> | ||
<td>For character type</td> | ||
<td><code>printf("%c", 'A');</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%d</strong></td> | ||
<td>For signed integer type</td> | ||
<td><code>printf("%d", -123);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%e</strong> or <strong>%E</strong></td> | ||
<td>For scientific notation of floats</td> | ||
<td><code>printf("%e", 123.456);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%f</strong></td> | ||
<td>For float type</td> | ||
<td><code>printf("%f", 3.14);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%g</strong> or <strong>%G</strong></td> | ||
<td>For float type with the current precision</td> | ||
<td><code>printf("%g", 0.000123);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%i</strong></td> | ||
<td>For signed integer type (same as <strong>%d</strong>)</td> | ||
<td><code>printf("%i", -123);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%ld</strong> or <strong>%li</strong></td> | ||
<td>For long integer type</td> | ||
<td><code>printf("%ld", 1234567890L);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%lf</strong></td> | ||
<td>For double type</td> | ||
<td><code>printf("%lf", 3.1415926535);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%Lf</strong></td> | ||
<td>For long double type</td> | ||
<td><code>printf("%Lf", 3.14159265358979L);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%lu</strong></td> | ||
<td>For unsigned int or unsigned long</td> | ||
<td><code>printf("%lu", 123456789UL);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%lli</strong> or <strong>%lld</strong></td> | ||
<td>For long long integer type</td> | ||
<td><code>printf("%lld", 123456789012345LL);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%llu</strong></td> | ||
<td>For unsigned long long</td> | ||
<td><code>printf("%llu", 123456789012345ULL);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%o</strong></td> | ||
<td>For octal representation</td> | ||
<td><code>printf("%o", 255);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%p</strong></td> | ||
<td>For pointer type</td> | ||
<td><code>printf("%p", (void *)&num);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%s</strong></td> | ||
<td>For string type</td> | ||
<td><code>printf("%s", "Hello, world!");</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%u</strong></td> | ||
<td>For unsigned int</td> | ||
<td><code>printf("%u", 123456);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%x</strong> or <strong>%X</strong></td> | ||
<td>For hexadecimal representation</td> | ||
<td><code>printf("%x", 255);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%n</strong></td> | ||
<td>Prints nothing but stores the number of characters printed so far into an integer variable</td> | ||
<td><code>printf("Count: %n", &count);</code></td> | ||
</tr> | ||
<tr> | ||
<td><strong>%%</strong></td> | ||
<td>Prints the % character</td> | ||
<td><code>printf("Percentage: %%");</code></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include<stdio.h> | ||
|
||
|
||
int main(){ | ||
/** | ||
* Declares and initialise an integer variable. | ||
*/ | ||
|
||
int a = 12; | ||
|
||
/** | ||
* use %d if you want to print a number | ||
*/ | ||
|
||
float out; | ||
printf("%d" , a); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import mongoose, { Schema, model } from "mongoose"; | ||
|
||
const orderItemSchema = new Schema({ | ||
productId: { | ||
type: mongoose.Schema.ObjectId, | ||
ref: "product", | ||
}, | ||
quantity: { | ||
type: Number, | ||
require: true, | ||
}, | ||
}); | ||
|
||
let OrderModel = new Schema( | ||
{ | ||
oPrice: { | ||
type: Number, | ||
require: true, | ||
}, | ||
|
||
oItems: { | ||
type: [orderItemSchema], | ||
}, | ||
address:{ | ||
type:String, | ||
require:true, | ||
}, | ||
|
||
status:{ | ||
type: String, | ||
enum: ['Pending' , 'Cancelled' , 'Delivered'], | ||
default: 'Pending', | ||
|
||
}, | ||
|
||
customer: { | ||
type: mongoose.Schema.ObjectId, | ||
ref: "user", | ||
}, | ||
}, | ||
{ timestamps: true } | ||
); | ||
|
||
export const Category = model("Category", OrderModel); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.