πŸš—πŸοΈ 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.

Start Your Journey with Motoshare

Basics of C Programming

Structure of a C Program

Definition:

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.

SizeExample
int4 bytesint num = 10;
float4 bytesfloat pi = 3.14;
double8 bytesdouble bigNum = 5.6789;
char1 bytechar grade = 'A';
void0 bytesUsed 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

OperatorDescriptionExample (a = 10, b = 5)
+Additiona + b β†’ 15
-Subtractiona - b β†’ 5
*Multiplicationa * b β†’ 50
/Divisiona / b β†’ 2
%Modulus (remainder)a % b β†’ 0

Relational Operators

OperatorDescriptionExample (a = 10, b = 5)
==Equal toa == b β†’ false
!=Not equal toa != b β†’ true
>Greater thana > b β†’ true
<Less thana < b β†’ false
>=Greater than or equal toa >= b β†’ true
<=Less than or equal toa <= b β†’ false

Logical Operators

OperatorDescriptionExample (x = 1, y = 0)
&&Logical AND(x && y) β†’ false
``Logical OR`(xy)β†’true`
!Logical NOT!x β†’ false

Bitwise Operators

OperatorDescriptionExample (a = 5, b = 3)
&ANDa & b β†’ 1
``OR`ab→7`
^XORa ^ b β†’ 6
~Complement~a β†’ -6
<<Left Shifta << 1 β†’ 10
>>Right Shifta >> 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

FunctionDescriptionExample
printf()Prints formatted outputprintf("Age: %d", age);
puts()Prints a string followed by a newlineputs("Hello World!");

Example:

#include <stdio.h>
int main() {
    printf("Hello, World!\n");
    puts("Welcome to C Programming.");
    return 0;
}

Input Functions

FunctionDescriptionExample
scanf()Reads formatted inputscanf("%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;
}
#include <stdio.h>
int main() {
    char name[30];
    printf("Enter your name: ");
    fgets(name, sizeof(name), stdin);  // Reads input safely
    printf("Hello, %s!", name);
    return 0;
}

Related Posts

Selenium in Hyderabad: Launch Your Automation Testing Career

Introduction Hyderabad, known as India’s tech capital, is a city filled with opportunities for software professionals. Companies here are always looking for skilled people who can test…

Master Automation Testing: Your Selenium Training Path in Chennai

Introduction So, you want to build a career in automation testing and you’ve heard Selenium is the key. You’re right! In today’s fast-moving software world, automating web…

Master Selenium Automation: Your Complete Guide to Top-Quality Training in Bangalore

Introduction Are you looking to boost your career in software testing and automation? In today’s fast-paced tech world, knowing how to automate web applications is not just…

Master Selenium Automation: Start Your Career with Mumbai’s Top Course

Introduction Hello and welcome! If you’re looking to build a strong career in software testing and automation, you’ve likely heard of Selenium. It’s the most popular tool…

Mastering Big Data: A Guide to Scala with Spark Training

Introduction In today’s data-driven world, the ability to process and analyze large amounts of information quickly is a superpower for businesses. Two technologies, Scala and Apache Spark,…

Master Big Data: Your Guide to Scala & Spark Training for a High-Growth Career

Introduction In today’s fast-moving world of technology, big data has become the backbone of modern business decisions. Companies everywhere are swimming in data, and they need powerful…

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x