SlideShare une entreprise Scribd logo
1  sur  25
Shaheed Benazir Bhutto University Nawabshah
Name : Shamshad Jamali
Roll No : 22BS( IT ) 40
Subject : Programming .
. Fundamental
Submit To : Sir Umair Sheikh
Q:1 Ramesh’s basic salary is input through the keyboard. His dearness
allowance is 40% of basic salary, and house rent allowance is 20% of
basic salary. Write a program to calculate his gross salary.
Input:-
#include <stdio.h>
int main()
{
int salary=20000;
salary=20000;
int der=salary*0.4;
int rent=salary*0.2;
int total=salary+der+rent;
printf("Basic Salary Of Ramesh:t%d",salary);
printf("nDearness Allowance:t%d",der);
printf("nRentAllowance:tt%d",rent);
printf("nGross Salary:tt%d",total);
}
OutPut:-
Q:2 The distance between two Cities (in km) is input through the
keyboard. Write a program to convert and print this distance in
meters, inches and centimers.
Input:-
#include<stdio.h>
int main ()
{
float km,m,cm,f,in;
printf("Enter Ddistancebetween two cities:");
scanf("%f" ,&km);
m=km * 1000;
cm=km * 1000 *100;
f=km *4.425;
in=km *14;
printf("Thedistance in kilometers : %fn" ,km);
printf("Thedistance in feet : %fn" ,f);
printf("Thedistance in inches : %fn" ,in);
printf("Thedistance in meters : %fn" ,m);
printf("Thedistance in centimeters: %fn" ,cm);
return (0);
}
Output:-
Q:3 If the marks obtained by a student in five different Subjects are
input through the keyboard. Find out the aggregate marks and
percentage marks obtained by the student. Assume that the
maximum marks that can be obtained by a student in each subject is
100.
Input:-
#include<stdio.h>
#include<conio.h>
int main()
{
int Math, Science, English, Sindhi, Urdu,AggregrateMarks;
float percentageMarks;
printf("Enter the Marks of Math Subject= ");
scanf("%d",&Math);
printf("nEnter the Marks of Science Subject= ");
scanf("%d",&Science);
printf("nEnter the Marks of English Subject= ");
scanf("%d",&English);
printf("nEnter the Marks of Sindhi Subject = ");
scanf("%d",&Sindhi);
printf("nEnter the Marks of Urdu Subject= ");
scanf("%d",&Urdu);
/* Calculate AggregateMarks */
AggregrateMarks =Math + Science + English + Sindhi+ Urdu;
printf("nnnTheAggregate Marks of Five subjects are:%d",AggregrateMarks);
/* Calculate PercentageMarks */
percentageMarks = AggregrateMarks/5;
printf("nnnThePercentage Marks of a Student is : %f%",percentageMarks);
getch ();
}
Output:-
Q:4 Temperature of a city in Fahrenheit degrees is input through the
keyboard. Write a program to convert this temperature into
centigrade degrees.
Input:-
#include<stdio.h>
int main()
{
float f,c;
printf("Enter the temperature in fahrenheitt");
scanf("%f",&f);
c=(f-32)*5/9;
printf("temperaturein a centigrade degree:%2f",c);
}
Output:-
Q:5 The length & breadth of a rectangle and radius of a circle are
input through the keyboard. Write a program to calculate the area &
perimeter of the rectangle, and the area & circumference of the circle.
Input:-
#include<stdio.h>
int main()
{
float L, B, R, AR, PR, AC, CC;
printf("Enter the Length of a rectangle(L) = ");
scanf("%f",&L);
printf("nEnter the Breadth of a rectangle(B) = ");
scanf("%f",&B);
/*Calculate the Area of Rectangle*/
AR = L * B;
printf("nnTheArea of a Rectangle are = %f",AR);
/*Calculate the Perimeter of Rectangle*/
PR = 2 *(L + B);
printf("nnThePerimeter of a Rectangle are = %f",PR);
printf("nnnEnter the Radious of a Circle(R) = ");
scanf("%f",&R);
/*Calculate the Area of Circle*/
AC = 3.14 * R * R;
printf("nnTheArea of a Circle are = %f",AC);
/*Calculate the Circumferenceof Circle*/
CC = 2 * 3.14 * R;
printf("nnTheCircumferenceof a Circle are = %f",CC);
return 0;
}
Output:-
Q:6 Two numbers ae input through the keyboard into two locations C
and D. Write a program to interchange the contents of C and D.
Input:-
#include<stdio.h>
int main()
{
int C, D, f;
printf("Enter the value of C = ");
scanf("%d",&C);
printf("nEnter the value of D = ");
scanf("%d",&D);
/*Condition of InterchangeC & D value*/
f = C;
C = D;
D = f;
printf("nnAfter InterchangetheValue of C is : %d",C);
printf("nnAfter InterchangetheValue of D is : %d",D);
return 0;
}
Output:-
Q:7 If a five-digit number is input through the keyboard. Write a
program to calculate the sum of its digits.
Input:-
#include<stdio.h>
int main()
{
int num, a, n;
int sum = 0;
printf("Enter a FIVEdigit number: ");
scanf("%d",&num);
/*1st digit*/
a = n % 10;
sum= sum+ a;
/*2nd digit*/
a = n % 10;
n = n / 10;
sum= sum+ a;
/*3rd digit*/
a = n % 10;
n = n / 10;
sum= sum+ a;
/*4th digit*/
a = n % 10;
n = n / 10;
sum= sum+ a;
/*last digit extracted as reminder*/
a = num% 10;
n = num/10; /*remaining digits*/
sum= sum+ a; /*sumupdated with adding of extracted digit*/
a = n % 10;
sum= sum+ a;
printf("nnnTheSumof FIVEDigit Number %d is = %d",num,sum);
return 0;
}
Output:-
Q:8 If a five-digit number is input through the keyboard. Write a
program to reverse the number.
Input:-
#include<stdio.h>
int main()
{
int n, a, b;
long int revnum=0;
printf("Enter the FIVEdigit number = ");
scanf("%d",&n);
/*1st digit*/
a = n % 10;
n = n / 10;
revnum= revnum+ a * 10000L;
/*reversenumber updated with value of extracted digit*/
/*2nd digit*/
a = n % 10;
n = n / 10;
revnum= revnum+ a * 1000;
/*3rd digit*/
a = n % 10;
n = n / 10;
revnum= revnum+ a * 100;
/*4th digit*/
a = n % 10;
n = n / 10;
revnum= revnum+ a * 10;
/*last digit*/
a = n % 10;
revnum= revnum+ a;
printf("nTheReversenumber = %ld",revnum);
return 0;
}
Output:-
Q:9 If a four-digit number is input through the keyboard. Write a
program to obtain the sum of the first and last digit of this number.
Output:-
#include<stdio.h>
int main()
{
int n, a, sum=0;
printf("Enter a Four Digit Number = ");
scanf("%d",&n);
/*1st digit*/
a = n / 1000;
sum= sum+ a;
/*Last digit*/
a = n % 10;
sum= sum+ a;
printf("nnSumof Firstand Lastdigit of %d = %d",n,sum);
return 0;
}
Output:-
Q:10 In a town, the percentage of men is 52. The percentage of total
literacy is 48. If total percentage of literate men is 35 of the total
population. Write a program to find the total number of illiterate men
and women if the population of the town is 80,000.
Input:-
#include<stdio.h>
int main()
{
long int totpop = 80000;
long int totmen, totlit, litmen, ilitmen, totwomen, totlitwomen;
long int ilitwomen;
totmen = (52/100) *totpop;
printf("nTotalnumber of Mens in the Town is :tt %ld",&totmen);
totlit = (48/100) *totpop;
printf("nTotalnumber of Literate People in the Town is : %ld",&totlit);
litmen = (35/100) *totpop;
printf("nTotalnumber of Literate Mens in the Town is :t %ld",&litmen);
totlitwomen = totlit - litmen;
totwomen = totpop - totmen;
printf("nTotalnumber of Womens in the Town is :tt %ld",&totwomen);
ilitmen = totmen - litmen;
printf("nTotalnumber of Illiterate Mens in the Town is : %ld",&ilitmen);
ilitwomen = totwomen - totlitwomen;
printf("nTotalnumber of Illiterate Womens in the Town is :%ld",ilitwomen);
return 0;
}
Output:-
Q:11 A cashier has currency notes of denominations 10, 50 and 100. If
the amount to be withdrawn is input through the keyboard in
hundreds, Find the total number of currency notes of each
denomination the cashier will have to give to the withdrawer.
Input:-
#include<stdio.h>
int main()
{
int amount, A, B, C;
printf("Enter the Amount to be Withdrawn : ");
scanf("%d",&amount);
A = amount / 100;
printf("nNumber of Hundred Notes = %d",&A);
amount = amount % 100;
B = amount / 50;
printf("nNumber of Fifty Notes = %d",&B);
amount = amount % 50;
C = amount/ 10;
printf("nNumber of Ten Notes = %d",&C);
return 0;
}
Output:-
Q:12 If the total selling price of 15 items and the total profit earned on
them is input through the keyboard, write a program to find the cost
price of one item.
Input:-
#include<stdio.h>
int main()
{
float sp, cp, profit;
printf("Enterthe total Selling Price = ");
scanf("%f",&sp);
printf("nEnterthe total Profit = ");
scanf("%f",&profit);
cp = sp - profit;
/*Cost price per item*/
cp = cp / 15;
printf("nnnCost Price Per Item are = %f",cp);
return 0;
}
Output:-
Q:13 If a five-digit number is input through the keyboard, write a
program to print a new number by adding one to each of its digits. For
example if the number that is input is 12391 then the output should
be displayed as 23402.
Input:-
#include<stdio.h>
int main()
{
int num, a, n;
int newnum=0;
printf("Enter a FIVEDigit number = ");
scanf("%d",&num);
/*1st digit*/
a = num/ 10000 +1;
n = num % 10000;
newnum= newnum+ a * 10000L;
/*2nd digit*/
a = n / 1000 + 1;
n = n % 1000;
newnum= newnum+ a * 1000;
/*3rd digit*/
a = n / 100 + 1;
n = n % 100;
newnum= newnum+ a * 100;
/*4th digit*/
a = n / 10 + 1;
n = n % 10;
newnum= newnum+ a * 10;
/*5th digit*/
a = n + 1;
newnum= newnum+ a;
printf("nnnOld Number = %d, New Number = %ld",num,newnum);
return 0;
}
Output:-
Chapter 1 Programming Fundamentals Assignment.docx

Contenu connexe

Tendances

Core programming in c
Core programming in cCore programming in c
Core programming in cRahul Pandit
 
Instruction cycle
Instruction cycleInstruction cycle
Instruction cycleKumar
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithmsRajendran
 
Evaluation of postfix expression
Evaluation of postfix expressionEvaluation of postfix expression
Evaluation of postfix expressionAkhil Ahuja
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++ Bharat Kalia
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.CS_GDRCST
 
instruction cycle ppt
instruction cycle pptinstruction cycle ppt
instruction cycle pptsheetal singh
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithmRezwan Siam
 
Recursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresRecursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresPriyanka Rana
 
Polish Notation In Data Structure
Polish Notation In Data StructurePolish Notation In Data Structure
Polish Notation In Data StructureMeghaj Mallick
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexityAnaya Zafar
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)cs19club
 

Tendances (20)

Functions in C
Functions in CFunctions in C
Functions in C
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
Instruction cycle
Instruction cycleInstruction cycle
Instruction cycle
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Evaluation of postfix expression
Evaluation of postfix expressionEvaluation of postfix expression
Evaluation of postfix expression
 
Introduction to c++ ppt 1
Introduction to c++ ppt 1Introduction to c++ ppt 1
Introduction to c++ ppt 1
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.
 
stack & queue
stack & queuestack & queue
stack & queue
 
5.1 greedy
5.1 greedy5.1 greedy
5.1 greedy
 
instruction cycle ppt
instruction cycle pptinstruction cycle ppt
instruction cycle ppt
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithm
 
Recursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresRecursion - Algorithms and Data Structures
Recursion - Algorithms and Data Structures
 
Polish Notation In Data Structure
Polish Notation In Data StructurePolish Notation In Data Structure
Polish Notation In Data Structure
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexity
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
 
Constructor and destructor
Constructor  and  destructor Constructor  and  destructor
Constructor and destructor
 

Similaire à Chapter 1 Programming Fundamentals Assignment.docx

Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solutionyogini sharma
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programsPrasadu Peddi
 
C Language Programming Introduction Lecture
C Language Programming Introduction LectureC Language Programming Introduction Lecture
C Language Programming Introduction Lecturemyinstalab
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxtristans3
 
LAB_MANUAL_cpl_21scheme-2.pdf
LAB_MANUAL_cpl_21scheme-2.pdfLAB_MANUAL_cpl_21scheme-2.pdf
LAB_MANUAL_cpl_21scheme-2.pdfRavinReddy3
 
PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfPCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfAshutoshprasad27
 
PCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxPCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxAshutoshprasad27
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given numberMainak Sasmal
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given numberMainak Sasmal
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...DR B.Surendiran .
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solutionKuntal Bhowmick
 
A10presentationofbiologyandpshyology.pptx
A10presentationofbiologyandpshyology.pptxA10presentationofbiologyandpshyology.pptx
A10presentationofbiologyandpshyology.pptxranjangamer007
 

Similaire à Chapter 1 Programming Fundamentals Assignment.docx (20)

Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
C Language Programming Introduction Lecture
C Language Programming Introduction LectureC Language Programming Introduction Lecture
C Language Programming Introduction Lecture
 
9.C Programming
9.C Programming9.C Programming
9.C Programming
 
C file
C fileC file
C file
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
 
Programming egs
Programming egs Programming egs
Programming egs
 
LAB_MANUAL_cpl_21scheme-2.pdf
LAB_MANUAL_cpl_21scheme-2.pdfLAB_MANUAL_cpl_21scheme-2.pdf
LAB_MANUAL_cpl_21scheme-2.pdf
 
C lab
C labC lab
C lab
 
PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfPCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdf
 
PCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxPCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docx
 
C programs
C programsC programs
C programs
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solution
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
cpract.docx
cpract.docxcpract.docx
cpract.docx
 
A10presentationofbiologyandpshyology.pptx
A10presentationofbiologyandpshyology.pptxA10presentationofbiologyandpshyology.pptx
A10presentationofbiologyandpshyology.pptx
 

Dernier

VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 

Dernier (20)

VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 

Chapter 1 Programming Fundamentals Assignment.docx

  • 1. Shaheed Benazir Bhutto University Nawabshah Name : Shamshad Jamali Roll No : 22BS( IT ) 40 Subject : Programming . . Fundamental Submit To : Sir Umair Sheikh
  • 2. Q:1 Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary. Input:- #include <stdio.h> int main() { int salary=20000; salary=20000; int der=salary*0.4; int rent=salary*0.2; int total=salary+der+rent; printf("Basic Salary Of Ramesh:t%d",salary); printf("nDearness Allowance:t%d",der); printf("nRentAllowance:tt%d",rent); printf("nGross Salary:tt%d",total); }
  • 3. OutPut:- Q:2 The distance between two Cities (in km) is input through the keyboard. Write a program to convert and print this distance in meters, inches and centimers. Input:- #include<stdio.h> int main () { float km,m,cm,f,in; printf("Enter Ddistancebetween two cities:"); scanf("%f" ,&km); m=km * 1000; cm=km * 1000 *100;
  • 4. f=km *4.425; in=km *14; printf("Thedistance in kilometers : %fn" ,km); printf("Thedistance in feet : %fn" ,f); printf("Thedistance in inches : %fn" ,in); printf("Thedistance in meters : %fn" ,m); printf("Thedistance in centimeters: %fn" ,cm); return (0); } Output:-
  • 5. Q:3 If the marks obtained by a student in five different Subjects are input through the keyboard. Find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100. Input:- #include<stdio.h> #include<conio.h> int main() { int Math, Science, English, Sindhi, Urdu,AggregrateMarks; float percentageMarks; printf("Enter the Marks of Math Subject= "); scanf("%d",&Math); printf("nEnter the Marks of Science Subject= "); scanf("%d",&Science); printf("nEnter the Marks of English Subject= "); scanf("%d",&English); printf("nEnter the Marks of Sindhi Subject = "); scanf("%d",&Sindhi); printf("nEnter the Marks of Urdu Subject= ");
  • 6. scanf("%d",&Urdu); /* Calculate AggregateMarks */ AggregrateMarks =Math + Science + English + Sindhi+ Urdu; printf("nnnTheAggregate Marks of Five subjects are:%d",AggregrateMarks); /* Calculate PercentageMarks */ percentageMarks = AggregrateMarks/5; printf("nnnThePercentage Marks of a Student is : %f%",percentageMarks); getch (); } Output:-
  • 7. Q:4 Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to convert this temperature into centigrade degrees. Input:- #include<stdio.h> int main() { float f,c; printf("Enter the temperature in fahrenheitt"); scanf("%f",&f); c=(f-32)*5/9; printf("temperaturein a centigrade degree:%2f",c); }
  • 8. Output:- Q:5 The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle. Input:- #include<stdio.h> int main() { float L, B, R, AR, PR, AC, CC; printf("Enter the Length of a rectangle(L) = "); scanf("%f",&L); printf("nEnter the Breadth of a rectangle(B) = ");
  • 9. scanf("%f",&B); /*Calculate the Area of Rectangle*/ AR = L * B; printf("nnTheArea of a Rectangle are = %f",AR); /*Calculate the Perimeter of Rectangle*/ PR = 2 *(L + B); printf("nnThePerimeter of a Rectangle are = %f",PR); printf("nnnEnter the Radious of a Circle(R) = "); scanf("%f",&R); /*Calculate the Area of Circle*/ AC = 3.14 * R * R; printf("nnTheArea of a Circle are = %f",AC); /*Calculate the Circumferenceof Circle*/ CC = 2 * 3.14 * R; printf("nnTheCircumferenceof a Circle are = %f",CC); return 0; }
  • 10. Output:- Q:6 Two numbers ae input through the keyboard into two locations C and D. Write a program to interchange the contents of C and D. Input:- #include<stdio.h> int main() { int C, D, f; printf("Enter the value of C = ");
  • 11. scanf("%d",&C); printf("nEnter the value of D = "); scanf("%d",&D); /*Condition of InterchangeC & D value*/ f = C; C = D; D = f; printf("nnAfter InterchangetheValue of C is : %d",C); printf("nnAfter InterchangetheValue of D is : %d",D); return 0; } Output:-
  • 12. Q:7 If a five-digit number is input through the keyboard. Write a program to calculate the sum of its digits. Input:- #include<stdio.h> int main() { int num, a, n; int sum = 0; printf("Enter a FIVEdigit number: "); scanf("%d",&num); /*1st digit*/ a = n % 10; sum= sum+ a; /*2nd digit*/ a = n % 10; n = n / 10; sum= sum+ a; /*3rd digit*/ a = n % 10; n = n / 10;
  • 13. sum= sum+ a; /*4th digit*/ a = n % 10; n = n / 10; sum= sum+ a; /*last digit extracted as reminder*/ a = num% 10; n = num/10; /*remaining digits*/ sum= sum+ a; /*sumupdated with adding of extracted digit*/ a = n % 10; sum= sum+ a; printf("nnnTheSumof FIVEDigit Number %d is = %d",num,sum); return 0; } Output:-
  • 14. Q:8 If a five-digit number is input through the keyboard. Write a program to reverse the number. Input:- #include<stdio.h> int main() { int n, a, b; long int revnum=0; printf("Enter the FIVEdigit number = "); scanf("%d",&n); /*1st digit*/ a = n % 10; n = n / 10; revnum= revnum+ a * 10000L; /*reversenumber updated with value of extracted digit*/ /*2nd digit*/ a = n % 10; n = n / 10; revnum= revnum+ a * 1000; /*3rd digit*/ a = n % 10;
  • 15. n = n / 10; revnum= revnum+ a * 100; /*4th digit*/ a = n % 10; n = n / 10; revnum= revnum+ a * 10; /*last digit*/ a = n % 10; revnum= revnum+ a; printf("nTheReversenumber = %ld",revnum); return 0; } Output:-
  • 16. Q:9 If a four-digit number is input through the keyboard. Write a program to obtain the sum of the first and last digit of this number. Output:- #include<stdio.h> int main() { int n, a, sum=0; printf("Enter a Four Digit Number = "); scanf("%d",&n); /*1st digit*/ a = n / 1000;
  • 17. sum= sum+ a; /*Last digit*/ a = n % 10; sum= sum+ a; printf("nnSumof Firstand Lastdigit of %d = %d",n,sum); return 0; } Output:- Q:10 In a town, the percentage of men is 52. The percentage of total literacy is 48. If total percentage of literate men is 35 of the total
  • 18. population. Write a program to find the total number of illiterate men and women if the population of the town is 80,000. Input:- #include<stdio.h> int main() { long int totpop = 80000; long int totmen, totlit, litmen, ilitmen, totwomen, totlitwomen; long int ilitwomen; totmen = (52/100) *totpop; printf("nTotalnumber of Mens in the Town is :tt %ld",&totmen); totlit = (48/100) *totpop; printf("nTotalnumber of Literate People in the Town is : %ld",&totlit); litmen = (35/100) *totpop; printf("nTotalnumber of Literate Mens in the Town is :t %ld",&litmen); totlitwomen = totlit - litmen; totwomen = totpop - totmen; printf("nTotalnumber of Womens in the Town is :tt %ld",&totwomen); ilitmen = totmen - litmen; printf("nTotalnumber of Illiterate Mens in the Town is : %ld",&ilitmen); ilitwomen = totwomen - totlitwomen;
  • 19. printf("nTotalnumber of Illiterate Womens in the Town is :%ld",ilitwomen); return 0; } Output:- Q:11 A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn is input through the keyboard in
  • 20. hundreds, Find the total number of currency notes of each denomination the cashier will have to give to the withdrawer. Input:- #include<stdio.h> int main() { int amount, A, B, C; printf("Enter the Amount to be Withdrawn : "); scanf("%d",&amount); A = amount / 100; printf("nNumber of Hundred Notes = %d",&A); amount = amount % 100; B = amount / 50; printf("nNumber of Fifty Notes = %d",&B); amount = amount % 50; C = amount/ 10; printf("nNumber of Ten Notes = %d",&C); return 0; } Output:-
  • 21. Q:12 If the total selling price of 15 items and the total profit earned on them is input through the keyboard, write a program to find the cost price of one item. Input:- #include<stdio.h> int main() { float sp, cp, profit; printf("Enterthe total Selling Price = "); scanf("%f",&sp);
  • 22. printf("nEnterthe total Profit = "); scanf("%f",&profit); cp = sp - profit; /*Cost price per item*/ cp = cp / 15; printf("nnnCost Price Per Item are = %f",cp); return 0; } Output:-
  • 23. Q:13 If a five-digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits. For example if the number that is input is 12391 then the output should be displayed as 23402. Input:- #include<stdio.h> int main() { int num, a, n; int newnum=0; printf("Enter a FIVEDigit number = "); scanf("%d",&num); /*1st digit*/ a = num/ 10000 +1; n = num % 10000; newnum= newnum+ a * 10000L; /*2nd digit*/ a = n / 1000 + 1; n = n % 1000; newnum= newnum+ a * 1000; /*3rd digit*/ a = n / 100 + 1;
  • 24. n = n % 100; newnum= newnum+ a * 100; /*4th digit*/ a = n / 10 + 1; n = n % 10; newnum= newnum+ a * 10; /*5th digit*/ a = n + 1; newnum= newnum+ a; printf("nnnOld Number = %d, New Number = %ld",num,newnum); return 0; } Output:-