SlideShare a Scribd company logo
1 of 12
More than 100 programs of c language are available withcompletetheory.Justloginto
www.eakanchha.com
More than 100 programs of c language are available withcompletetheory.Justloginto
www.eakanchha.com
Program 1: write a program to find simple interest by using formula: SI=(p*r*t)/100?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int p, t;
float si, r;
clrscr();
printf("enter principal amount, rate and timen");
scanf("%d %d %f", &p, &t, &r);
si=(p*r*t)/100;
printf("n simple interest=%f", si);
getch();
}
Output: (For example if principal amount=100000, rate=10 and time=4.)
enter principal amount, rate and time
100000
10
4
simple interest=40000
Program 2: write a program for conversion of C°
temperature to F°
temperature?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
float f, c;
clrscr();
printf("enter temperature in C°
n");
scanf("%f", &c);
f=((9*c)/5)+32;
printf("temperature in F°
=%f", f);
getch();
}
Output: (For example if temperature= 10 C°
.)
enter temperature in C°
10
temperature in F°
=50
Inputpart
Processingpart
outputpart
More than 100 programs of c language are available withcompletetheory.Justloginto
www.eakanchha.com
Program 3: write a program to find greater number between two numbers?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b;
clrscr();
printf("enter two numbersn");
scanf("%d %d", &a, &b);
if(a>b)
{
printf("a=%d is greater than b=%d", a,b);
}
else
{
printf("b=%d is greater than a=%d", b,a);
}
getch();
}
Output: (For example if a=17 and b=12.)
enter two numbers
17
12
a=17 is greater than b=12
Program 4: write a program to find greater number between three numbers?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c;
clrscr();
printf("enter three numbersn");
scanf("%d %d %d", &a, &b, &c);
if((a>b)&&(a>c))
{
printf("a=%d is greater", a);
}
else
{
if(b>c)
{
More than 100 programs of c language are available withcompletetheory.Justloginto
www.eakanchha.com
printf("b=%d is greater", b);
}
else
{
printf("c=%d is greater", c);
}
}
getch();
}
Output: (For example if a=17, b=12 and c=89.)
enter three numbers
17
12
89
c=89 is greater
Program 5: write a program to find out the division of the student from marks of five subjects?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c, d, e;
float avg;
clrscr();
printf("enter your marks in mathsn");
scanf("%d",&a);
printf("nenter your marks in sciencen");
scanf("%d",&b);
printf("nenter your marks in hindin");
scanf("%d",&c);
printf("nenter your marks in englishn");
scanf("%d",&d);
printf("nenter your marks in social studiesn");
scanf("%d",&e);
if((a<33)||(b<33)||(c<33)||(d<33)||(e<33))
{
printf("you are fail");
}
else
{
avg=(a+b+c+d+e)/5;
if(avg>=75)
{
printf("nfirst division");
}
else if((avg<75)&&(avg>=55))
More than 100 programs of c language are available withcompletetheory.Justloginto
www.eakanchha.com
{
printf("nsecond division");
}
else
{
printf("n third division");
}
}
getch();
}
Output: (for ex: marks In maths=92, science=85, hindi=88, english=82 and social studies=90.)
enter your marks in maths
92
enter your marks in science
85
enter your marks in hindi
88
enter your marks in english
82
enter your marks in social studies
90
first division
Program 6: write a program to calculate area and circumference of a circle as per user need?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int x,r;
float a, c, p=3.14;
clrscr();
printf("choose your option:n press 1 to calculate area of a circle n press 2 to calculate
circumference of a circlen");
scanf("%d", &x);
if(x==1)
{
printf("enter radiusn");
scanf("%d",&r);
a=p*r*r;
printf("n area=%f",a);
}
else
{
printf("enter radiusn");
scanf("%d",&r);
c=2*p*r;
More than 100 programs of c language are available withcompletetheory.Justloginto
www.eakanchha.com
printf("n circumference=%f",c);
}
getch();
}
Output: (for ex: user want to calculate area of a circle and radius=7.)
choose your option:
press 1 to calculate area of a circle
press 2 to calculate circumference of a circle
1
enter radius
7
area=153.86
Program 7: write a program to calculate gross salary, if dearness allowance is 40% and house
rent allowance is 20% of the basic salary?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
float da,hra,gs,bs;
clrscr();
printf("enter your basic salary");
scanf("%f",&bs);
da=(bs*40/100);
hra=(bs*20/100);
gs=bs-hra-da;
printf("n your gross salary is=%f", gs);
getch();
}
Or;
#include<stdio.h>
#include<conio.h>
void main()
{
float da,hra,gs;
int bs;
clrscr();
printf("n enter your basic salary");
scanf("%d",&bs);
da=(0.4*bs);
hra=(0.2*bs);
gs=bs-hra-da;
printf("n your gross salary is=%f", gs);
getch();
}
More than 100 programs of c language are available withcompletetheory.Justloginto
www.eakanchha.com
Or;
#include<stdio.h>
#include<conio.h>
void main()
{
float da,hra,gs;
int bs;
clrscr();
printf("enter your basic salaryn");
scanf("%d",&bs);
da=(40.0/100)*bs;
hra=(20.0/100)*bs;
gs=bs-hra-da;
printf("n your gross salary is=%f", gs);
getch();
}
As, we have discussed integer float conversion previously:
You know if an integer value is divided by another integer value and in case the answer is float
type then also, only integer part of the answer we will get as result.
That’s why I had showed you three ways of calculating da and hra.
In first way; as bs itself is float type therefore, when it will be multiplied by 40 the result will be
considered as float type so that after division by100, We will get da=0.40000 (same thing apply
for hra.)
In second approach, as bs is integer type that’s why we have directly multiplied it 0.4 and 0.2.
because here, (bs*40/100); will not work. As, 40 (is integer type) and 100(is also integer type),
therefore, integer/ integer= integer. Due to which, 40/100=0 and bs*0=0. (same thing applies
with hra. )
In third approach; as bs in integer type that’s why we have written equations like;
da=(40.0/100)*bs;
hra=(20.0/100)*bs;
as, 40.0 is real type divided by 100(integer type ) and real/integer=real value.
Therefore, it will work perfectly;
40.0/100=0.40000
0.40000*bs= (required float value according to bs value.)
Output: (for ex: basic salary=25000)
enter your basic salary
25000
your gross salary is=10000.00
More than 100 programs of c language are available withcompletetheory.Justloginto
www.eakanchha.com
Program 8: write a program to identify vowels and consonants?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
char x;
clrscr();
printf("enter any alphabet in small casen");
scanf("%c", &x);
if(x=='a'||x=='e'|| x=='i'|| x=='o'|| x=='u')
{
printf("you have entered a vowel");
}
else
{
printf("you have entered a consonant");
}
getch();
}
Output: (for ex: user has entered a)
enter any alphabet in small case
a
you have entered a vowel
Program 9: write a program to identify even and odd number?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,m;
clrscr();
printf("enter any integer type valuen");
scanf("%d", &n);
m=n%2;
if(m==0)
{
printf("number is even");
}
More than 100 programs of c language are available withcompletetheory.Justloginto
www.eakanchha.com
else
{
printf("number is odd");
}
getch();
}
Or;
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("enter any integer type value");
scanf("%d", &n);
if(n%2)
{
printf("number is odd");
}
else
{
printf("number is even");
}
getch();
}
In second approach we have used concept of 0 implies false and 1 implies true. Therefore;
when n%2=0, it will indicate false and control goes to else statement and in other cases if
statement will be executed.
Output: (for example user has entered 21)
enter any integer type value
21
number is odd
Explaination: (according to second approach)
as 21%2 is equal to 1 (moduls operator gives remainder). Therefore if statement will be
executed.
Program 10: write a program to swap two numbers without using third variable?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
More than 100 programs of c language are available withcompletetheory.Justloginto
www.eakanchha.com
clrscr();
printf("enter two numbers n");
scanf("%d%d",&a, &b);
printf("n before swap a=%d and b=%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("n after swap a=%d and b=%d",a,b);
getch();
}
Output: (for ex: a=25 and b=16)
enter two numbers
25
16
before swap a=25 and b=16
after swap a=16 and b=25
Program 11: write a program to swap two numbers using bitwise ex-or operator?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter two numbers n");
scanf("%d%d",&a, &b);
printf("n before swap a=%d and b=%d",a,b);
a=a^b;
b=a^b;
a=a^b;
printf("n after swap a=%d and b=%d",a,b);
getch();
}
Let us take an example to understand how this concept works:
Lets; a=5 and b=6, therefore;
a=a^b;
a= 0101
b= 0110
a^b=0011
Similarly; at second step:
b=a^b; and after first step a=3 and b=6
More than 100 programs of c language are available withcompletetheory.Justloginto
www.eakanchha.com
a= 0011
b= 0110
a^b=0101
now, a=3 and b=5
similarly, at third step:
a=a^b;
a= 0101
b= 0101
a^b=0110
now, a=6 and b=5. (This is our required answer.)
Output: (as: a=5 and b=6)
enter two numbers
5
6
before swap a=5 and b=6
after swap a=6 and b=5
More than 100 programs of c language are available withcompletetheory.Justloginto
www.eakanchha.com

More Related Content

What's hot

Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solutionAzhar Javed
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkarsandeep kumbhkar
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysisVishal Singh
 
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 .
 
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionHazrat Bilal
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomeshpraveensomesh
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in cSaranya saran
 
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.2020vrgokila
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string libraryMomenMostafa
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branchingSaranya saran
 
FLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONFLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONvikram mahendra
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4MKalpanaDevi
 

What's hot (20)

Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
 
C Programming
C ProgrammingC Programming
C Programming
 
C code examples
C code examplesC code examples
C code examples
 
C important questions
C important questionsC important questions
C important questions
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
 
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 ...
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
week-3x
week-3xweek-3x
week-3x
 
Revision1 C programming
Revision1 C programmingRevision1 C programming
Revision1 C programming
 
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solution
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
 
Input And Output
 Input And Output Input And Output
Input And Output
 
Revision1schema C programming
Revision1schema C programmingRevision1schema C programming
Revision1schema C programming
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
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
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string library
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
FLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONFLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHON
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 

Similar to programs of c www.eakanchha.com

Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solutionKuntal Bhowmick
 
Programming fundamental 02
Programming fundamental 02Programming fundamental 02
Programming fundamental 02Suhail Akraam
 
Understand more about C
Understand more about CUnderstand more about C
Understand more about CYi-Hsiu Hsu
 
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
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans incnayakq
 
Control structure of c
Control structure of cControl structure of c
Control structure of cKomal Kotak
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solutionyogini sharma
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)yap_raiza
 
the refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptxthe refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptxAnkitaVerma776806
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02Wingston
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSKavyaSharma65
 

Similar to programs of c www.eakanchha.com (20)

Programming egs
Programming egs Programming egs
Programming egs
 
C faq pdf
C faq pdfC faq pdf
C faq pdf
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solution
 
Programming fundamental 02
Programming fundamental 02Programming fundamental 02
Programming fundamental 02
 
Progr3
Progr3Progr3
Progr3
 
Understand more about C
Understand more about CUnderstand more about C
Understand more about C
 
C file
C fileC file
C file
 
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
 
C Programming
C ProgrammingC Programming
C Programming
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
 
C lab
C labC lab
C lab
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
 
comp2
comp2comp2
comp2
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
 
the refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptxthe refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptx
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
C programs
C programsC programs
C programs
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERS
 

More from Akanchha Agrawal

Micro economics questions sets
Micro economics questions setsMicro economics questions sets
Micro economics questions setsAkanchha Agrawal
 
Number system with conversions www.eakanchha.com
Number system with conversions www.eakanchha.comNumber system with conversions www.eakanchha.com
Number system with conversions www.eakanchha.comAkanchha Agrawal
 
Basic of c programming www.eakanchha.com
Basic of c programming www.eakanchha.comBasic of c programming www.eakanchha.com
Basic of c programming www.eakanchha.comAkanchha Agrawal
 
Lvp law of variable proportions www.eakanchha.com
Lvp law of variable proportions www.eakanchha.comLvp law of variable proportions www.eakanchha.com
Lvp law of variable proportions www.eakanchha.comAkanchha Agrawal
 
cost missing value question www.eakanchha.com
 cost missing value question www.eakanchha.com cost missing value question www.eakanchha.com
cost missing value question www.eakanchha.comAkanchha Agrawal
 
cost missing value question www.eakanchha.com
 cost missing value question www.eakanchha.com cost missing value question www.eakanchha.com
cost missing value question www.eakanchha.comAkanchha Agrawal
 
cost micro economics www.eakanchha.com
cost micro economics www.eakanchha.comcost micro economics www.eakanchha.com
cost micro economics www.eakanchha.comAkanchha Agrawal
 

More from Akanchha Agrawal (7)

Micro economics questions sets
Micro economics questions setsMicro economics questions sets
Micro economics questions sets
 
Number system with conversions www.eakanchha.com
Number system with conversions www.eakanchha.comNumber system with conversions www.eakanchha.com
Number system with conversions www.eakanchha.com
 
Basic of c programming www.eakanchha.com
Basic of c programming www.eakanchha.comBasic of c programming www.eakanchha.com
Basic of c programming www.eakanchha.com
 
Lvp law of variable proportions www.eakanchha.com
Lvp law of variable proportions www.eakanchha.comLvp law of variable proportions www.eakanchha.com
Lvp law of variable proportions www.eakanchha.com
 
cost missing value question www.eakanchha.com
 cost missing value question www.eakanchha.com cost missing value question www.eakanchha.com
cost missing value question www.eakanchha.com
 
cost missing value question www.eakanchha.com
 cost missing value question www.eakanchha.com cost missing value question www.eakanchha.com
cost missing value question www.eakanchha.com
 
cost micro economics www.eakanchha.com
cost micro economics www.eakanchha.comcost micro economics www.eakanchha.com
cost micro economics www.eakanchha.com
 

Recently uploaded

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 

Recently uploaded (20)

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 

programs of c www.eakanchha.com

  • 1. More than 100 programs of c language are available withcompletetheory.Justloginto www.eakanchha.com
  • 2. More than 100 programs of c language are available withcompletetheory.Justloginto www.eakanchha.com Program 1: write a program to find simple interest by using formula: SI=(p*r*t)/100? Solution: #include<stdio.h> #include<conio.h> void main() { int p, t; float si, r; clrscr(); printf("enter principal amount, rate and timen"); scanf("%d %d %f", &p, &t, &r); si=(p*r*t)/100; printf("n simple interest=%f", si); getch(); } Output: (For example if principal amount=100000, rate=10 and time=4.) enter principal amount, rate and time 100000 10 4 simple interest=40000 Program 2: write a program for conversion of C° temperature to F° temperature? Solution: #include<stdio.h> #include<conio.h> void main() { float f, c; clrscr(); printf("enter temperature in C° n"); scanf("%f", &c); f=((9*c)/5)+32; printf("temperature in F° =%f", f); getch(); } Output: (For example if temperature= 10 C° .) enter temperature in C° 10 temperature in F° =50 Inputpart Processingpart outputpart
  • 3. More than 100 programs of c language are available withcompletetheory.Justloginto www.eakanchha.com Program 3: write a program to find greater number between two numbers? Solution: #include<stdio.h> #include<conio.h> void main() { int a, b; clrscr(); printf("enter two numbersn"); scanf("%d %d", &a, &b); if(a>b) { printf("a=%d is greater than b=%d", a,b); } else { printf("b=%d is greater than a=%d", b,a); } getch(); } Output: (For example if a=17 and b=12.) enter two numbers 17 12 a=17 is greater than b=12 Program 4: write a program to find greater number between three numbers? Solution: #include<stdio.h> #include<conio.h> void main() { int a, b, c; clrscr(); printf("enter three numbersn"); scanf("%d %d %d", &a, &b, &c); if((a>b)&&(a>c)) { printf("a=%d is greater", a); } else { if(b>c) {
  • 4. More than 100 programs of c language are available withcompletetheory.Justloginto www.eakanchha.com printf("b=%d is greater", b); } else { printf("c=%d is greater", c); } } getch(); } Output: (For example if a=17, b=12 and c=89.) enter three numbers 17 12 89 c=89 is greater Program 5: write a program to find out the division of the student from marks of five subjects? Solution: #include<stdio.h> #include<conio.h> void main() { int a, b, c, d, e; float avg; clrscr(); printf("enter your marks in mathsn"); scanf("%d",&a); printf("nenter your marks in sciencen"); scanf("%d",&b); printf("nenter your marks in hindin"); scanf("%d",&c); printf("nenter your marks in englishn"); scanf("%d",&d); printf("nenter your marks in social studiesn"); scanf("%d",&e); if((a<33)||(b<33)||(c<33)||(d<33)||(e<33)) { printf("you are fail"); } else { avg=(a+b+c+d+e)/5; if(avg>=75) { printf("nfirst division"); } else if((avg<75)&&(avg>=55))
  • 5. More than 100 programs of c language are available withcompletetheory.Justloginto www.eakanchha.com { printf("nsecond division"); } else { printf("n third division"); } } getch(); } Output: (for ex: marks In maths=92, science=85, hindi=88, english=82 and social studies=90.) enter your marks in maths 92 enter your marks in science 85 enter your marks in hindi 88 enter your marks in english 82 enter your marks in social studies 90 first division Program 6: write a program to calculate area and circumference of a circle as per user need? Solution: #include<stdio.h> #include<conio.h> void main() { int x,r; float a, c, p=3.14; clrscr(); printf("choose your option:n press 1 to calculate area of a circle n press 2 to calculate circumference of a circlen"); scanf("%d", &x); if(x==1) { printf("enter radiusn"); scanf("%d",&r); a=p*r*r; printf("n area=%f",a); } else { printf("enter radiusn"); scanf("%d",&r); c=2*p*r;
  • 6. More than 100 programs of c language are available withcompletetheory.Justloginto www.eakanchha.com printf("n circumference=%f",c); } getch(); } Output: (for ex: user want to calculate area of a circle and radius=7.) choose your option: press 1 to calculate area of a circle press 2 to calculate circumference of a circle 1 enter radius 7 area=153.86 Program 7: write a program to calculate gross salary, if dearness allowance is 40% and house rent allowance is 20% of the basic salary? Solution: #include<stdio.h> #include<conio.h> void main() { float da,hra,gs,bs; clrscr(); printf("enter your basic salary"); scanf("%f",&bs); da=(bs*40/100); hra=(bs*20/100); gs=bs-hra-da; printf("n your gross salary is=%f", gs); getch(); } Or; #include<stdio.h> #include<conio.h> void main() { float da,hra,gs; int bs; clrscr(); printf("n enter your basic salary"); scanf("%d",&bs); da=(0.4*bs); hra=(0.2*bs); gs=bs-hra-da; printf("n your gross salary is=%f", gs); getch(); }
  • 7. More than 100 programs of c language are available withcompletetheory.Justloginto www.eakanchha.com Or; #include<stdio.h> #include<conio.h> void main() { float da,hra,gs; int bs; clrscr(); printf("enter your basic salaryn"); scanf("%d",&bs); da=(40.0/100)*bs; hra=(20.0/100)*bs; gs=bs-hra-da; printf("n your gross salary is=%f", gs); getch(); } As, we have discussed integer float conversion previously: You know if an integer value is divided by another integer value and in case the answer is float type then also, only integer part of the answer we will get as result. That’s why I had showed you three ways of calculating da and hra. In first way; as bs itself is float type therefore, when it will be multiplied by 40 the result will be considered as float type so that after division by100, We will get da=0.40000 (same thing apply for hra.) In second approach, as bs is integer type that’s why we have directly multiplied it 0.4 and 0.2. because here, (bs*40/100); will not work. As, 40 (is integer type) and 100(is also integer type), therefore, integer/ integer= integer. Due to which, 40/100=0 and bs*0=0. (same thing applies with hra. ) In third approach; as bs in integer type that’s why we have written equations like; da=(40.0/100)*bs; hra=(20.0/100)*bs; as, 40.0 is real type divided by 100(integer type ) and real/integer=real value. Therefore, it will work perfectly; 40.0/100=0.40000 0.40000*bs= (required float value according to bs value.) Output: (for ex: basic salary=25000) enter your basic salary 25000 your gross salary is=10000.00
  • 8. More than 100 programs of c language are available withcompletetheory.Justloginto www.eakanchha.com Program 8: write a program to identify vowels and consonants? Solution: #include<stdio.h> #include<conio.h> void main() { char x; clrscr(); printf("enter any alphabet in small casen"); scanf("%c", &x); if(x=='a'||x=='e'|| x=='i'|| x=='o'|| x=='u') { printf("you have entered a vowel"); } else { printf("you have entered a consonant"); } getch(); } Output: (for ex: user has entered a) enter any alphabet in small case a you have entered a vowel Program 9: write a program to identify even and odd number? Solution: #include<stdio.h> #include<conio.h> void main() { int n,m; clrscr(); printf("enter any integer type valuen"); scanf("%d", &n); m=n%2; if(m==0) { printf("number is even"); }
  • 9. More than 100 programs of c language are available withcompletetheory.Justloginto www.eakanchha.com else { printf("number is odd"); } getch(); } Or; #include<stdio.h> #include<conio.h> void main() { int n; clrscr(); printf("enter any integer type value"); scanf("%d", &n); if(n%2) { printf("number is odd"); } else { printf("number is even"); } getch(); } In second approach we have used concept of 0 implies false and 1 implies true. Therefore; when n%2=0, it will indicate false and control goes to else statement and in other cases if statement will be executed. Output: (for example user has entered 21) enter any integer type value 21 number is odd Explaination: (according to second approach) as 21%2 is equal to 1 (moduls operator gives remainder). Therefore if statement will be executed. Program 10: write a program to swap two numbers without using third variable? Solution: #include<stdio.h> #include<conio.h> void main() { int a,b;
  • 10. More than 100 programs of c language are available withcompletetheory.Justloginto www.eakanchha.com clrscr(); printf("enter two numbers n"); scanf("%d%d",&a, &b); printf("n before swap a=%d and b=%d",a,b); a=a+b; b=a-b; a=a-b; printf("n after swap a=%d and b=%d",a,b); getch(); } Output: (for ex: a=25 and b=16) enter two numbers 25 16 before swap a=25 and b=16 after swap a=16 and b=25 Program 11: write a program to swap two numbers using bitwise ex-or operator? Solution: #include<stdio.h> #include<conio.h> void main() { int a,b; clrscr(); printf("enter two numbers n"); scanf("%d%d",&a, &b); printf("n before swap a=%d and b=%d",a,b); a=a^b; b=a^b; a=a^b; printf("n after swap a=%d and b=%d",a,b); getch(); } Let us take an example to understand how this concept works: Lets; a=5 and b=6, therefore; a=a^b; a= 0101 b= 0110 a^b=0011 Similarly; at second step: b=a^b; and after first step a=3 and b=6
  • 11. More than 100 programs of c language are available withcompletetheory.Justloginto www.eakanchha.com a= 0011 b= 0110 a^b=0101 now, a=3 and b=5 similarly, at third step: a=a^b; a= 0101 b= 0101 a^b=0110 now, a=6 and b=5. (This is our required answer.) Output: (as: a=5 and b=6) enter two numbers 5 6 before swap a=5 and b=6 after swap a=6 and b=5
  • 12. More than 100 programs of c language are available withcompletetheory.Justloginto www.eakanchha.com