We provide DevOps | SRE | DevSecOps | MLOps Freelancing
πποΈ Welcome to Motoshare!
Turning Idle Vehicles into Shared Rides & New Earnings.
Why let your bike or car sit idle when it can earn for you and move someone else forward?
From Idle to Income. From Parked to Purpose. Earn by Sharing, Ride by Renting. Where Owners Earn, Riders Move. Owners Earn. Riders Move. Motoshare Connects.
With Motoshare, every parked vehicle finds a purpose.
Partners earn. Renters ride. Everyone wins.
A C program follows a structured format, which includes essential components like preprocessor directives, the main function, and statements.
#include <stdio.h> // Preprocessor directive
// Main function: Entry point of every C program
int main() {
printf("Hello, World!"); // Output statement
return 0; // Indicates successful execution
}
Structure Breakdown:
#include <stdio.h>: Includes the standard input-output library.
int main(): The main function where execution begins.
printf("Hello, World!");: Prints output to the screen.
return 0;: Indicates successful execution.
Data Types in C
Definition:
Data types in C define the type of data a variable can store. They determine the memory size and the operations that can be performed on the variable.
Size
Example
int
4 bytes
int num = 10;
float
4 bytes
float pi = 3.14;
double
8 bytes
double bigNum = 5.6789;
char
1 byte
char grade = 'A';
void
0 bytes
Used for functions with no return value
Variables and Constants
Variables
A variable is a named memory location that stores data and can be modified during program execution.
Syntax:
data_type variable_name = value;
Example:
int age = 25;
float height = 5.9;
char grade = 'A';
Constants
Constants are values that do not change during program execution.
Using const Keyword:
const float PI = 3.14159;
Using #define Macro:
#define PI 3.14159
Operators in C
Operators are symbols that perform operations on variables and values. They are classified into different types based on their functionality.
Arithmetic Operators
Operator
Description
Example (a = 10, b = 5)
+
Addition
a + b β 15
-
Subtraction
a - b β 5
*
Multiplication
a * b β 50
/
Division
a / b β 2
%
Modulus (remainder)
a % b β 0
Relational Operators
Operator
Description
Example (a = 10, b = 5)
==
Equal to
a == b β false
!=
Not equal to
a != b β true
>
Greater than
a > b β true
<
Less than
a < b β false
>=
Greater than or equal to
a >= b β true
<=
Less than or equal to
a <= b β false
Logical Operators
Operator
Description
Example (x = 1, y = 0)
&&
Logical AND
(x && y) β false
`
`
Logical OR
`(x
y)βtrue`
!
Logical NOT
!x β false
Bitwise Operators
Operator
Description
Example (a = 5, b = 3)
&
AND
a & b β 1
`
`
OR
`a
bβ7`
^
XOR
a ^ b β 6
~
Complement
~a β -6
<<
Left Shift
a << 1 β 10
>>
Right Shift
a >> 1 β 2
5. Input and Output in C
Definition:
Input and output functions allow the program to interact with the user by receiving input and displaying output.
Output Functions
Function
Description
Example
printf()
Prints formatted output
printf("Age: %d", age);
puts()
Prints a string followed by a newline
puts("Hello World!");
Example:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
puts("Welcome to C Programming.");
return 0;
}
Input Functions
Function
Description
Example
scanf()
Reads formatted input
scanf("%d", &num);
gets()
Reads a string (deprecated)
gets(name);
Example (Using scanf()):
#include <stdio.h>
int main() {
int age;
printf("Enter your age: ");
scanf("%d", &age);
printf("You are %d years old.", age);
return 0;
}
In today’s fast-paced digital economy, the ability to deliver software rapidly, reliably, and efficiently is no longer a luxuryβit’s a business imperative. At the heart of this…
Introduction In todayβs rapidly evolving tech landscape, mastering enterprise-grade application development is no longer a luxuryβitβs a necessity. For professionals and aspiring developers in Pune, the Java…
Introduction In today’s rapidly evolving tech ecosystem, Java remains a cornerstone of enterprise application development, powering everything from financial systems to large-scale web applications. However, the landscape…
In todayβs fast-paced tech landscape, mastering a robust, modern framework is not just an advantageβitβs a necessity. For aspiring and experienced developers in Kolkata looking to build…
In today’s fast-paced digital landscape, robust backend development skills are not just an advantageβthey’re a necessity. As businesses across Pune, from thriving startups in Hinjewadi to established…
In the fast-paced world of enterprise software development, the demand for robust, scalable, and maintainable applications has never been higher. At the heart of this ecosystem lies…