SlideShare a Scribd company logo
1 of 4
Download to read offline
23P_0678 _Rashid Amin_QueNo 1
#include <stdio.h>
#define teteprotation_cost_per_use 1000
#define spaceship_cost_per_use 1500
#define spaceship_cost_per_distance 50
int teleportationCost(int portalCount) {
return portalCount * teteprotation_cost_per_use;
}
int calculateSpaceshipCost(int spaceshipCount, int distance) {
return spaceship_cost_per_use*spaceship_cost_per_distance* spaceshipCount;
}
int TotalCost(int portalCount,int spaceshipCount,int distance) {
int portalCost =teleportationCost(portalCount);
int spaceshipCost = calculateSpaceshipCost(spaceshipCount, distance);
int totalCost = portalCost + spaceshipCost;
printf("teleportation Portal Cost: $%dn", portalCost);
printf("Spaceship Cost: $%dn", spaceshipCost);
return totalCost;
}
int main() {
int portal_use, spaceship_use, distance;
printf ("transportation portal used: ");
scanf ("%d", &portal_use);
printf ("The value of spaceship used: ");
scanf ("%d", &spaceship_use);
printf ("The value of distance of spaceship travelled: ");
scanf ("%d", &distance);
int totalCost = TotalCost(portal_use, spaceship_use, distance);
printf("Total Transportation Cost: $%dn", totalCost);
return 0;
}
23P_0678 _Rashid Amin_QueNo 2
#include <stdio.h>
int formulaOne(int power, int speed) {
return power + speed;
}
int formulaTwo(int efficiency) {
return efficiency * efficiency;
}
int main() {
// Input for Car 1
int car1_power = 10,car1_speed = 20,car1_efficiency = 40;
// Input for Car 2
int car2_power = 30,car2_speed = 50 ,car2_efficiency = 60;
int car1_performance = formulaOne(car1_power, car1_speed) + formulaTwo(car1_efficiency);
//The overall performance for Car 2
int car2_performance = formulaOne(car2_power, car2_speed) + formulaTwo(car2_efficiency);
// The new car's overall performance
int new_car_performance = car1_performance + car2_performance;
printf("New car's overall performance: %dn", new_car_performance);
return 0;
}
23P_0678 _Rashid Amin_QueNo3
#include <stdio.h>
int main() {
int revenue, expenses, net_profit, profit_margin, roi;
const int scaling_factor = 100;
printf("The value of total revenue for the year: ");
if (scanf("%d", &revenue) != 1 || revenue < 0) {
printf("Invalid input for revenue. Please the value of on-negative integer.n");
return -1;
}
printf("Enter the total expenses for the year: ");
if (scanf("%d", &expenses) != 1 || expenses < 0) {
printf("Invalid input for expenses. Please the value of non-negative integer.n");
return -1;
}
net_profit = (revenue - expenses) * scaling_factor;
if (revenue == 0) {
printf("Error: Revenue is zero. Cannot define profit margin.n");
return 1;
}
if (expenses == 0) {
printf("Error: Expenses are zero. Cannot define ROI.n");
return 1;
}
profit_margin = (net_profit * scaling_factor) / revenue;
roi = (net_profit * scaling_factor) / expenses;
printf("Total Revenue: %dn", revenue);
printf("Total Expenses: %dn", expenses);
printf("Net Profit: %dn", net_profit / scaling_factor);
printf("Profit Margin: %d%%n", profit_margin / scaling_factor);
printf("Return on Investment (ROI): %d%%n", roi / scaling_factor);
return 0;
}
23P_0678 _Rashid Amin_QueNo4
#include <stdio.h>
int main() {
char Box1Color, Box2Color;
printf("Enter the color of the first box (R for red, B for blue, G for green): ");
scanf(" %c", &Box1Color);
printf("Enter the color of the second box (R for red, B for blue, G for green): ");
scanf(" %c", &Box2Color);
if (Box1Color == Box2Color) {
printf("Two boxes of the same color cannot be placed together.n");
} else {
printf("Boxes placed successfully.n");
}
return 0;
}

More Related Content

Similar to C Language code

Similar to C Language code (20)

C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Code optimization
Code optimization Code optimization
Code optimization
 
Code optimization
Code optimization Code optimization
Code optimization
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
C basics
C basicsC basics
C basics
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
 
C programm.pptx
C programm.pptxC programm.pptx
C programm.pptx
 
C programs
C programsC programs
C programs
 
7 functions
7  functions7  functions
7 functions
 
Lab Question
Lab QuestionLab Question
Lab Question
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 

Recently uploaded

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Recently uploaded (20)

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

C Language code

  • 1. 23P_0678 _Rashid Amin_QueNo 1 #include <stdio.h> #define teteprotation_cost_per_use 1000 #define spaceship_cost_per_use 1500 #define spaceship_cost_per_distance 50 int teleportationCost(int portalCount) { return portalCount * teteprotation_cost_per_use; } int calculateSpaceshipCost(int spaceshipCount, int distance) { return spaceship_cost_per_use*spaceship_cost_per_distance* spaceshipCount; } int TotalCost(int portalCount,int spaceshipCount,int distance) { int portalCost =teleportationCost(portalCount); int spaceshipCost = calculateSpaceshipCost(spaceshipCount, distance); int totalCost = portalCost + spaceshipCost; printf("teleportation Portal Cost: $%dn", portalCost); printf("Spaceship Cost: $%dn", spaceshipCost); return totalCost; } int main() { int portal_use, spaceship_use, distance; printf ("transportation portal used: "); scanf ("%d", &portal_use); printf ("The value of spaceship used: "); scanf ("%d", &spaceship_use); printf ("The value of distance of spaceship travelled: "); scanf ("%d", &distance); int totalCost = TotalCost(portal_use, spaceship_use, distance); printf("Total Transportation Cost: $%dn", totalCost); return 0; }
  • 2. 23P_0678 _Rashid Amin_QueNo 2 #include <stdio.h> int formulaOne(int power, int speed) { return power + speed; } int formulaTwo(int efficiency) { return efficiency * efficiency; } int main() { // Input for Car 1 int car1_power = 10,car1_speed = 20,car1_efficiency = 40; // Input for Car 2 int car2_power = 30,car2_speed = 50 ,car2_efficiency = 60; int car1_performance = formulaOne(car1_power, car1_speed) + formulaTwo(car1_efficiency); //The overall performance for Car 2 int car2_performance = formulaOne(car2_power, car2_speed) + formulaTwo(car2_efficiency); // The new car's overall performance int new_car_performance = car1_performance + car2_performance; printf("New car's overall performance: %dn", new_car_performance); return 0; }
  • 3. 23P_0678 _Rashid Amin_QueNo3 #include <stdio.h> int main() { int revenue, expenses, net_profit, profit_margin, roi; const int scaling_factor = 100; printf("The value of total revenue for the year: "); if (scanf("%d", &revenue) != 1 || revenue < 0) { printf("Invalid input for revenue. Please the value of on-negative integer.n"); return -1; } printf("Enter the total expenses for the year: "); if (scanf("%d", &expenses) != 1 || expenses < 0) { printf("Invalid input for expenses. Please the value of non-negative integer.n"); return -1; } net_profit = (revenue - expenses) * scaling_factor; if (revenue == 0) { printf("Error: Revenue is zero. Cannot define profit margin.n"); return 1; } if (expenses == 0) { printf("Error: Expenses are zero. Cannot define ROI.n"); return 1; } profit_margin = (net_profit * scaling_factor) / revenue; roi = (net_profit * scaling_factor) / expenses; printf("Total Revenue: %dn", revenue); printf("Total Expenses: %dn", expenses); printf("Net Profit: %dn", net_profit / scaling_factor); printf("Profit Margin: %d%%n", profit_margin / scaling_factor); printf("Return on Investment (ROI): %d%%n", roi / scaling_factor); return 0; }
  • 4. 23P_0678 _Rashid Amin_QueNo4 #include <stdio.h> int main() { char Box1Color, Box2Color; printf("Enter the color of the first box (R for red, B for blue, G for green): "); scanf(" %c", &Box1Color); printf("Enter the color of the second box (R for red, B for blue, G for green): "); scanf(" %c", &Box2Color); if (Box1Color == Box2Color) { printf("Two boxes of the same color cannot be placed together.n"); } else { printf("Boxes placed successfully.n"); } return 0; }