Shopping Cart Project Using C Language - GeeksforGeeks
Shopping Cart Project Using C Language - GeeksforGeeks
C C Basics C Data Types C Operators C Input and Output C Control Flow C Functions C Arrays
1. Signup
2. Login
3. Search items
4. Bill
Signup Functionality
This is the main function for a signup, Here we will check whether
the account exists or not if not we will create a new account
Following are the functionalities: Inputs are username, age, email,
password, confirm the password, and mobile number.
Validate the inputs input data should be valid otherwise account
will not create. After successful signup, you will be directly
redirected to the login page
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 1/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
Login
Order by Shop
Cart
This function will show you the Total cost of your order
Login Page
The login page asks about the data before we can enter the main home
page where we can shop. The data to be inserted are Email and
Password. Both email and password should be matching with the data
entry or the process to log in will fail.
Main Program:
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 2/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
// C Program to implement
// Shopping Cart
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
void signup();
void account_validate();
int validate();
void login();
void cart();
void shop();
void items();
void item_order(int item);
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 3/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
void shop_initialize();
void Shop(int shop_choice);
// Driver code
int main()
{
// Loop while till which runs till break is called
while (1) {
// First Page
printf("\n\n\t******************Welcome to Shop "
"Cart*******************\n");
printf("\n\n1)SIGNUP");
printf("\n2)LOGIN");
printf("\n3)EXIT");
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 4/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
return 0;
}
default: {
printf("\n\n\t******************"
"Welcome to Signup "
"Page****************"
"*\n\n");
x = validate();
if (x == 1) {
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 5/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
// Signup process
int validate()
{
// Name Validation
for (i = 0; t_name[i] != '\0'; i++) {
if (!((t_name[i] >= 'a' && t_name[i] <= 'z')
|| (t_name[i] >= 'A' && t_name[i] <= 'Z'))) {
printf("\nPlease enter the valid Name!\n");
flag = 0;
break;
}
}
if (flag == 1) {
count = 0;
// Email ID Validation
for (i = 0; t_email[i] != '\0'; i++) {
if (t_email[i] == '@' || t_email[i] == '.')
count++;
}
if (count >= 2 && strlen(t_email) >= 5) {
// Password Validation
if (!strcmp(t_password1, t_password2)) {
if (strlen(t_password1) >= 8
&& strlen(t_password1) <= 12) {
caps = 0;
Small = 0;
numbers = 0;
special = 0;
for (i = 0; t_password1[i] != '\0';
i++) {
if (t_password1[i] >= 'A'
&& t_password1[i] <= 'Z')
caps++;
else if (t_password1[i] >= 'a'
&& t_password1[i] <= 'z')
Small++;
else if (t_password1[i] >= '0'
&& t_password1[i] <= '9')
numbers++;
else if (t_password1[i] == '@'
|| t_password1[i] == '&'
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 6/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
|| t_password1[i] == '#'
|| t_password1[i] == '*')
special++;
}
if (caps >= 1 && Small >= 1
&& numbers >= 1 && special >= 1) {
// Age Validation
if (t_age != 0 && t_age > 0) {
// Mobile Validation
if (strlen(t_mobile) == 10) {
for (i = 0; i < 10; i++) {
if (t_mobile[i] >= '0'
&& t_mobile[i]
<= '9') {
success = 1;
}
else {
printf(
"\n\nPlease");
printf(
"Enter Valid ");
printf(
"Mobile "
"Number\n\n");
return 0;
break;
}
}
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 7/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
// Account Validation
void account_validate()
{
for (i = 0; i < 100; i++) {
// Check account already exist
if (!(strcmp(t_email, s[i].email)
&& strcmp(t_password1, s[i].password))) {
printf("\n\nAccount Already Existed. Please "
"Login !\n\n");
login();
break;
}
}
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 8/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
// Login function
void login()
{
printf("\n\n\t******************"
"Welcome to Login "
"Page********************"
"****\n\n");
printf("\n\nLOGIN\n\n");
printf("\t Enter Your Email: ");
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 9/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
case 3: {
// main function called again
main();
break;
}
default: {
// Choice entered is wrong
printf("Please Enter the valid "
"choice!!!\n\n");
break;
}
}
break;
}
else {
// Password entered is wrong
printf("\n\nInvalid Password!!\n ");
printf("Please Enter the correct "
"password\n\n");
login();
break;
}
}
else {
// If details are incorrect
printf("\n\nAccount doesn't exist, Please "
"signup!!\n\n ");
main();
break;
}
}
}
strcpy(m[2].shop, "USA");
strcpy(m[2].item1, "US polo Tshirt");
strcpy(m[2].item2, "Shoes");
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 10/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
strcpy(m[2].item3, "shirt");
m[2].first = 999;
m[2].second = 2000;
m[2].third = 1499;
strcpy(m[3].shop, "WROGN");
strcpy(m[3].item1, "Mens Watch");
strcpy(m[3].item2, "mens solid jacket");
strcpy(m[3].item3, "casusal T-shirt");
m[3].first = 2000;
m[3].second = 2239;
m[3].third = 799;
}
while (1) {
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 11/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
else if (item_choice == 4) {
cart();
}
else if (item_choice == 5) {
shop();
}
else {
printf("Please Enter the");
printf("valid Choice\n\n");
}
}
}
void items()
{
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 12/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
total = 0;
// Initialize all the Shop and their items
shop_initialize();
while (1) {
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 13/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
main();
return;
}
else if (ch == 0) {
printf("To cancel Your Order = 1 \nTo Exit = 0 ");
printf("Select option : ");
scanf("%d", &confirm);
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 14/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
if (confirm == 1) {
//Failed
printf("\n\nOops! Your item is cancelled!! "
"Exiting..\n\n");
printf("Thank You visit again!\n");
main();
return;
}
else {
// Product is bought
printf("\n\n\t\t************Thank "
"You******************\n\n");
login();
}
}
else {
// Asking for choice
printf("\n\nPlease Enter the correct choice\n\n ");
cart();
}
}
Output:
Welcome Page:
First Page of C
Sign Up:
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 15/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
Sign Up Page in C
Login Page:
Login Page in C
Bill Generated:
Bill Generated
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 16/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
Similar Reads
Shopping Cart app using React
In this article, we will create an Interactive and Responsive Shopping Cart
Project Application using the famous JavaScript FrontEnd library ReactJS…
9 min read
2 min read
6 min read
12 min read
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 17/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
2 min read
3 min read
4 min read
2 min read
2 min read
5 min read
6 min read
8 min read
3 min read
1 min read
3 min read
5 min read
4 min read
5 min read
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 19/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
2 min read
4 min read
How to Make a Project Using Spring Boot, MySQL, Spring Data JPA,…
For the sample project, below mentioned tools got used Java 8Eclipse IDE
for developmentHibernate ORM, Spring framework with Spring Data…
4 min read
6 min read
Working with Microsoft Excel Using Apache POI and JExcel API with …
In the software industry, information needs to be portable and hence any
valid data is available in XLS and XLSX formats i.e. excel formats. In orde…
7 min read
5 min read
1 min read
3 min read
4 min read
5 min read
7 min read
5 min read
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 21/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
A-143, 7th Floor, Sovereign Corporate
Tower, Sector- 136, Noida, Uttar Pradesh
(201305)
Registered Address:
K 061, Tower K, Gulshan Vivante
Apartment, Sector 137, Noida, Gautam
Buddh Nagar, Uttar Pradesh, 201305
Advertise with us
Company Explore
About Us Job-A-Thon Hiring Challenge
Legal Hack-A-Thon
Privacy Policy GfG Weekly Contest
Careers Offline Classes (Delhi/NCR)
In Media DSA in JAVA/C++
Contact Us Master System Design
GFG Corporate Solution Master CP
Placement Training Program GeeksforGeeks Videos
Geeks Community
Languages DSA
Python Data Structures
Java Algorithms
C++ DSA for Beginners
PHP Basic DSA Problems
GoLang DSA Roadmap
SQL DSA Interview Questions
R Language Competitive Programming
Android Tutorial
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 23/24
2/24/25, 5:14 PM Shopping Cart Project Using C Language - GeeksforGeeks
DSA/Placements Development/Testing
DSA - Self Paced Course JavaScript Full Course
DSA in JavaScript - Self Paced Course React JS Course
DSA in Python - Self Paced React Native Course
C Programming Course Online - Learn C with Data Structures Django Web Development Course
Complete Interview Preparation Complete Bootstrap Course
Master Competitive Programming Full Stack Development - [LIVE]
Core CS Subject for Interview Preparation JAVA Backend Development - [LIVE]
Mastering System Design: LLD to HLD Complete Software Testing Course [LIVE]
Tech Interview 101 - From DSA to System Design [LIVE] Android Mastery with Kotlin [LIVE]
DSA to Development [HYBRID]
Placement Preparation Crash Course [LIVE]
Clouds/Devops GATE
DevOps Engineering GATE CS & IT Test Series - 2025
AWS Solutions Architect Certification GATE DA Test Series 2025
Salesforce Certified Administrator Course GATE CS & IT Course - 2025
GATE DA Course 2025
GATE Rank Predictor
https://www.geeksforgeeks.org/shopping-cart-project-using-c-language/ 24/24