SlideShare a Scribd company logo
1 of 19
C-programs with output
/*c-program to find largest among three nos.
using logical AND*/
#include<stdio.h>
#include<conio.h>
void main ()
{
int a,b,c;
printf("Enter values of a, b and c");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(a>c))
printf("%d is largest",a);
if((c>a)&&(c>b))
printf("%d is largest",c);
getch();
}
/*close of main()function*/
/*output */
Enter values of a, b and c1 2 3
3 is largest
Enter values of a, b and c7 8 9
9 is largest
Enter values of a, b and c11 15 23
23 is largest
Enter values of a, b and c1 6 9
9 is largest
/*c-program for finding the sum of series
of 1 to 1/(10!)*/
#include<stdio.h>
#include<conio.h>
void main()
{
float i,sum,fact;
for(i=1,sum=0,fact=1;i<=10;i++)
{
fact=fact*i;
sum=sum+(1/fact);
}
printf("sum=%f",sum);
getch();
}
/*output*/
sum=1.718282
/*c program to find sum of(1/1) to
(1/10)*/
#include<stdio.h>
#include<conio.h>
void main()
{
float i,sum;
for(i=1,sum=0;i<=10;i++)
{
sum=sum+(1/i);
}
printf("sum=%f",sum);
getch();
}
/*output*/
sum=2.928968
/*c program for addition of1-5 numbers
using while loop*/
#include<stdio.h>
#include<conio.h>
void main()
{
int sum=0,i=1;
while(i<=5)
{
sum=sum+i;
i++;
}
printf("addition=%d",sum);
getch();
}
/*output*/
addition=15
/* c-program to find table from 1 to 10*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
for(i=1;i<=10;i++)
{
for(j=1;j<=10;j++)
{
printf("%dt",i*j);
}
printf("n");
}
getch();
}
/*Output*/
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100
/*c program for goto in unconditional
branching or taking square of a no.*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
start:
printf("enter the value of a");
scanf("%d",&a);
b=a*a;
if(b>50)
{
goto start;
}
printf("b=%d",b);
getch();
}
/*Output*/
enter the value of a5
b=25
/*c-program of to find largest among 3 number using
if..else laddar or nested if..else*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("enter the values of a,b,c");
scanf("%d%d%d", &a,&b,&c);
if(a>c)
{
if(a>c)
printf("%d is largest",a);
else
printf("%d is largest",c);
}
else
{
if(b>c)
printf("%d is largest",b);
else
printf("%d is largest",c);
}
getch();
}
/*output*/
enter the values of a,b,c
1 4 0
4 is largest
enter the values of a,b,c
3 4 5
5 is largest
/*c-program for addition oftwo nos.*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("Enter the values of a&b");
scanf("%d%d",&a,&b);
c=a+b;
printf("Addition=%d",c);
getch();
}
/*output*/
Enter the values of a&b90 10
Addition=100
Enter the values of a&b56 75
Addition=131
/*c-program for Division oftwo nos.*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the values of a&b");
scanf("%d%d",&a,&b);
c=a/b;
printf("Division=%d",c);
getch();
}
/*output*/
Enter the values of a&b10 10
Division=1
Enter the values of a&b 70 10
Division=7
/*c-program for Subtraction of two
nos.*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the values of a&b");
scanf("%d%d",&a,&b);
c=a-b;
printf("Subtraction=%d",c);
getch();
}
/*output*/
Enter the values of a&b56 45
Subtraction=11
/*c-program for multiplication oftwo
nos.*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the values of a&b");
scanf("%d%d",&a,&b);
c=a*b;
printf("Multiplication=%d",c);
getch();
}
/*output*/
Enter the values of a&b10 10
Multiplication=100
Enter the values of a&b90 90
Multiplication=8100
/*c-program to find area of circle*/
#include<stdio.h>
#include<conio.h>
void main()
{
int r,pie=3.14,a;
clrscr();
printf("Enter the values of r");
scanf("%d",&r);
a=3.14*r*r;
printf("Area of circle=%d",a);
getch();
}
/*output*/
Enter the values of r10
Area of circle=314
/*c-program for conditional branching of
switch as well as to show break statment*/
#include<stdio.h>
#include<conio.h>
int main()
{
int n;
clrscr();
printf("enter no.=");
scanf("%d",&n);
switch(n);
{
case0:printf("zero");
break();
case1:printf("one");
break();
case2:printf("two");
break();
default:printf("Invalid Input");
break();
}
getch();
}
/*output*/
enter no.=1
one
enter no.=2
two
enter no.=0
zero
/*c-program to find whether the integer is odd
or even*/
#include<stdio.h>
#include<conio.h>
int main()
{
int n; //n is any integer
printf("Enter the value of n");
scanf("%d",&n);
//True if remainder is 0
if(n%2==0)
printf("%d is an even integer",n);
else
printf("%d is an odd integer",n);
getch();
}
/*output*/
Enter the value of n7
7 is an odd integer
Enter the value of n10
10 is an even integer
Enter the value of n1
1 is an odd integer
Enter the value of n0
0 is an even integer
/*c-program to find smallest among the three nos.
using nested if..else or if else laddar*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("Enter the values of a,b,c");
scanf("%d%d%d",&a,&b,&c);
if(a<b)
{
if(a<c)
printf("%d is smallest",a);
else
printf("%d is smallest",c);
}
else
{
if(b<c)
printf("%d is smallest",b);
else
printf("%d is smallest",c);
}
getch();
}
/*output*/
Enter the values of a,b,c1 4 7
1 is smallest
Enter the values of a,b,c 0 1 9
0 is smallest
Enter the values of a,b,c991 198 90
90 is smallest
/*C-program to write array elements in descending order.*/
#include<stdio.h>
#include<conio.h>
main()
{
int a[10],i,j,k;
printf("Enter the array elements:");
for(i=0;i<10;i++)
{
scanf("%dt",&a[i]);
}
for(i=0;i<9;i++) /*write array elements in
descending order*/
{
for(j=i+1;j<10;j++)
{
if(a[i]<a[j])
{
k=a[i];
a[i]=a[j];
a[j]=k;
}
}
}
printf("Array element is in descending order.");
for(i=0;i<10;i++)
{
printf("%dt",a[i]);
}
getch();
}
/*output*/
Enter the array elements:10 34 65 5 345 490 90 86 43 14
Array element is in descending order. 490 345 90 86 65
43 34 14 10 5
/*C-program to write array elements in ascending order.*/
#include<stdio.h>
#include<conio.h>
main()
{
int a[10],i,j,k;
clrscr();
printf("Enter the array elements:");
for(i=0;i<10;i++)
{
scanf("%dt",&a[i]);
}
for(i=0;i<9;i++) /*write array elements in ascending
order*/
{
for(j=i+1;j<10;j++)
{
if(a[i]>a[j])
{
k=a[i];
a[i]=a[j];
a[j]=k;
}
}
}
printf("Array element is in ascending order.");
for(i=0;i<10;i++)
{
printf("%dt",a[i]);
}
getch();
}
/*output*/
Enter the array elements:434 45 465 13 67 83 53 77 67 13
Array element is in ascending order. 13 13 45 53 67 67 77
83 434 465
/*c-program to check wether the entered no. is prime
or not*/
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,r;
printf("Enter a number:");
scanf("%d",&n);
i=2;
while(i<=n-1)
{
r=n%i;
if(r==0)
break;
i++;
}
if(i==n)
printf("The entered number is a prime no.");
else
printf("The entered number is not a prime no.");
getch();
}
/*output*/
Enter a number:5
The entered number is a prime no.
Enter a number:10
The entered number is not a prime no.
Enter a number:173
The entered number is a prime no.
Enter a number:237
The entered number is not a prime no.

More Related Content

What's hot (20)

Presentation on calculus
Presentation on calculusPresentation on calculus
Presentation on calculus
 
Enums in c
Enums in cEnums in c
Enums in c
 
Mathematical Logic
Mathematical LogicMathematical Logic
Mathematical Logic
 
Permutation
PermutationPermutation
Permutation
 
Stack using Array
Stack using ArrayStack using Array
Stack using Array
 
C string
C stringC string
C string
 
SLIDE KE-4 DFA
SLIDE KE-4 DFASLIDE KE-4 DFA
SLIDE KE-4 DFA
 
Permutation
PermutationPermutation
Permutation
 
Areas and Definite Integrals.ppt
Areas and Definite Integrals.pptAreas and Definite Integrals.ppt
Areas and Definite Integrals.ppt
 
Mathematical foundations of computer science
Mathematical foundations of computer scienceMathematical foundations of computer science
Mathematical foundations of computer science
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Pointer in C
Pointer in CPointer in C
Pointer in C
 
Permutations and Combinations
Permutations and CombinationsPermutations and Combinations
Permutations and Combinations
 
Math (geometric mean)
Math (geometric mean)Math (geometric mean)
Math (geometric mean)
 
Data types in C language
Data types in C languageData types in C language
Data types in C language
 
Lar calc10 ch04_sec2
Lar calc10 ch04_sec2Lar calc10 ch04_sec2
Lar calc10 ch04_sec2
 
Graph Basic In Data structure
Graph Basic In Data structureGraph Basic In Data structure
Graph Basic In Data structure
 
introduction to_trees
introduction to_treesintroduction to_trees
introduction to_trees
 
permutation and combination
permutation and combinationpermutation and combination
permutation and combination
 
Matlab ch1 (4)
Matlab ch1 (4)Matlab ch1 (4)
Matlab ch1 (4)
 

Similar to some basic C programs with outputs

Similar to some basic C programs with outputs (20)

C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHFC BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
 
comp2
comp2comp2
comp2
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
 
C file
C fileC file
C file
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Simple C programs
Simple C programsSimple C programs
Simple C programs
 
Najmul
Najmul  Najmul
Najmul
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
C-programs
C-programsC-programs
C-programs
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structures
 
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
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures
 
program in c
program in cprogram in c
program in c
 
C lab
C labC lab
C lab
 
C
CC
C
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
Data struture lab
Data struture labData struture lab
Data struture lab
 
C basics
C basicsC basics
C basics
 
C lab programs
C lab programsC lab programs
C lab programs
 

More from KULDEEPSING PATIL

More from KULDEEPSING PATIL (6)

Bead mill
Bead millBead mill
Bead mill
 
Deforestation
DeforestationDeforestation
Deforestation
 
Website
WebsiteWebsite
Website
 
Art project
Art projectArt project
Art project
 
MATHS PROJECT
MATHS PROJECTMATHS PROJECT
MATHS PROJECT
 
INFORMATION ABOUT JAMMU AND KASHMIR DISASTER IN 2014Social science project
INFORMATION ABOUT JAMMU AND KASHMIR DISASTER IN 2014Social science projectINFORMATION ABOUT JAMMU AND KASHMIR DISASTER IN 2014Social science project
INFORMATION ABOUT JAMMU AND KASHMIR DISASTER IN 2014Social science project
 

Recently uploaded

Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 

Recently uploaded (20)

Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 

some basic C programs with outputs

  • 2. /*c-program to find largest among three nos. using logical AND*/ #include<stdio.h> #include<conio.h> void main () { int a,b,c; printf("Enter values of a, b and c"); scanf("%d%d%d",&a,&b,&c); if((a>b)&&(a>c)) printf("%d is largest",a); if((c>a)&&(c>b)) printf("%d is largest",c); getch(); } /*close of main()function*/ /*output */ Enter values of a, b and c1 2 3 3 is largest Enter values of a, b and c7 8 9 9 is largest Enter values of a, b and c11 15 23 23 is largest Enter values of a, b and c1 6 9 9 is largest
  • 3. /*c-program for finding the sum of series of 1 to 1/(10!)*/ #include<stdio.h> #include<conio.h> void main() { float i,sum,fact; for(i=1,sum=0,fact=1;i<=10;i++) { fact=fact*i; sum=sum+(1/fact); } printf("sum=%f",sum); getch(); } /*output*/ sum=1.718282
  • 4. /*c program to find sum of(1/1) to (1/10)*/ #include<stdio.h> #include<conio.h> void main() { float i,sum; for(i=1,sum=0;i<=10;i++) { sum=sum+(1/i); } printf("sum=%f",sum); getch(); } /*output*/ sum=2.928968
  • 5. /*c program for addition of1-5 numbers using while loop*/ #include<stdio.h> #include<conio.h> void main() { int sum=0,i=1; while(i<=5) { sum=sum+i; i++; } printf("addition=%d",sum); getch(); } /*output*/ addition=15 /* c-program to find table from 1 to 10*/ #include<stdio.h>
  • 6. #include<conio.h> void main() { int i,j; for(i=1;i<=10;i++) { for(j=1;j<=10;j++) { printf("%dt",i*j); } printf("n"); } getch(); } /*Output*/ 1 2 3 4 5 6 7 8 9 10 2 4 6 8 10 12 14 16 18 20 3 6 9 12 15 18 21 24 27 30 4 8 12 16 20 24 28 32 36 40 5 10 15 20 25 30 35 40 45 50 6 12 18 24 30 36 42 48 54 60 7 14 21 28 35 42 49 56 63 70 8 16 24 32 40 48 56 64 72 80 9 18 27 36 45 54 63 72 81 90 10 20 30 40 50 60 70 80 90 100 /*c program for goto in unconditional branching or taking square of a no.*/
  • 7. #include<stdio.h> #include<conio.h> void main() { int a,b; clrscr(); start: printf("enter the value of a"); scanf("%d",&a); b=a*a; if(b>50) { goto start; } printf("b=%d",b); getch(); } /*Output*/ enter the value of a5 b=25 /*c-program of to find largest among 3 number using if..else laddar or nested if..else*/
  • 8. #include<stdio.h> #include<conio.h> void main() { int a,b,c; printf("enter the values of a,b,c"); scanf("%d%d%d", &a,&b,&c); if(a>c) { if(a>c) printf("%d is largest",a); else printf("%d is largest",c); } else { if(b>c) printf("%d is largest",b); else printf("%d is largest",c); } getch(); } /*output*/ enter the values of a,b,c 1 4 0 4 is largest enter the values of a,b,c 3 4 5 5 is largest
  • 9. /*c-program for addition oftwo nos.*/ #include<stdio.h> #include<conio.h> void main() { int a,b,c; printf("Enter the values of a&b"); scanf("%d%d",&a,&b); c=a+b; printf("Addition=%d",c); getch(); } /*output*/ Enter the values of a&b90 10 Addition=100 Enter the values of a&b56 75 Addition=131
  • 10. /*c-program for Division oftwo nos.*/ #include<stdio.h> #include<conio.h> void main() { int a,b,c; clrscr(); printf("Enter the values of a&b"); scanf("%d%d",&a,&b); c=a/b; printf("Division=%d",c); getch(); } /*output*/ Enter the values of a&b10 10 Division=1 Enter the values of a&b 70 10 Division=7
  • 11. /*c-program for Subtraction of two nos.*/ #include<stdio.h> #include<conio.h> void main() { int a,b,c; clrscr(); printf("Enter the values of a&b"); scanf("%d%d",&a,&b); c=a-b; printf("Subtraction=%d",c); getch(); } /*output*/ Enter the values of a&b56 45 Subtraction=11
  • 12. /*c-program for multiplication oftwo nos.*/ #include<stdio.h> #include<conio.h> void main() { int a,b,c; clrscr(); printf("Enter the values of a&b"); scanf("%d%d",&a,&b); c=a*b; printf("Multiplication=%d",c); getch(); } /*output*/ Enter the values of a&b10 10 Multiplication=100 Enter the values of a&b90 90 Multiplication=8100
  • 13. /*c-program to find area of circle*/ #include<stdio.h> #include<conio.h> void main() { int r,pie=3.14,a; clrscr(); printf("Enter the values of r"); scanf("%d",&r); a=3.14*r*r; printf("Area of circle=%d",a); getch(); } /*output*/ Enter the values of r10 Area of circle=314
  • 14. /*c-program for conditional branching of switch as well as to show break statment*/ #include<stdio.h> #include<conio.h> int main() { int n; clrscr(); printf("enter no.="); scanf("%d",&n); switch(n); { case0:printf("zero"); break(); case1:printf("one"); break(); case2:printf("two"); break(); default:printf("Invalid Input"); break(); } getch(); } /*output*/ enter no.=1 one enter no.=2 two enter no.=0 zero
  • 15. /*c-program to find whether the integer is odd or even*/ #include<stdio.h> #include<conio.h> int main() { int n; //n is any integer printf("Enter the value of n"); scanf("%d",&n); //True if remainder is 0 if(n%2==0) printf("%d is an even integer",n); else printf("%d is an odd integer",n); getch(); } /*output*/ Enter the value of n7 7 is an odd integer Enter the value of n10 10 is an even integer Enter the value of n1 1 is an odd integer Enter the value of n0 0 is an even integer
  • 16. /*c-program to find smallest among the three nos. using nested if..else or if else laddar*/ #include<stdio.h> #include<conio.h> void main() { int a,b,c; printf("Enter the values of a,b,c"); scanf("%d%d%d",&a,&b,&c); if(a<b) { if(a<c) printf("%d is smallest",a); else printf("%d is smallest",c); } else { if(b<c) printf("%d is smallest",b); else printf("%d is smallest",c); } getch(); } /*output*/ Enter the values of a,b,c1 4 7 1 is smallest Enter the values of a,b,c 0 1 9 0 is smallest Enter the values of a,b,c991 198 90 90 is smallest
  • 17. /*C-program to write array elements in descending order.*/ #include<stdio.h> #include<conio.h> main() { int a[10],i,j,k; printf("Enter the array elements:"); for(i=0;i<10;i++) { scanf("%dt",&a[i]); } for(i=0;i<9;i++) /*write array elements in descending order*/ { for(j=i+1;j<10;j++) { if(a[i]<a[j]) { k=a[i]; a[i]=a[j]; a[j]=k; } } } printf("Array element is in descending order."); for(i=0;i<10;i++) { printf("%dt",a[i]); } getch(); } /*output*/ Enter the array elements:10 34 65 5 345 490 90 86 43 14 Array element is in descending order. 490 345 90 86 65 43 34 14 10 5
  • 18. /*C-program to write array elements in ascending order.*/ #include<stdio.h> #include<conio.h> main() { int a[10],i,j,k; clrscr(); printf("Enter the array elements:"); for(i=0;i<10;i++) { scanf("%dt",&a[i]); } for(i=0;i<9;i++) /*write array elements in ascending order*/ { for(j=i+1;j<10;j++) { if(a[i]>a[j]) { k=a[i]; a[i]=a[j]; a[j]=k; } } } printf("Array element is in ascending order."); for(i=0;i<10;i++) { printf("%dt",a[i]); } getch(); } /*output*/ Enter the array elements:434 45 465 13 67 83 53 77 67 13 Array element is in ascending order. 13 13 45 53 67 67 77 83 434 465
  • 19. /*c-program to check wether the entered no. is prime or not*/ #include<stdio.h> #include<conio.h> main() { int n,i,r; printf("Enter a number:"); scanf("%d",&n); i=2; while(i<=n-1) { r=n%i; if(r==0) break; i++; } if(i==n) printf("The entered number is a prime no."); else printf("The entered number is not a prime no."); getch(); } /*output*/ Enter a number:5 The entered number is a prime no. Enter a number:10 The entered number is not a prime no. Enter a number:173 The entered number is a prime no. Enter a number:237 The entered number is not a prime no.