SlideShare a Scribd company logo
1 of 14
MS. MANSI TYAGI
output
PROGRAMS
(1) /*write a program for addition of two number:*/
#include<stdio.h>
#include<conio.h>
intmain()
{
intnum1,num2,result;
printf("enterthe fristnumber:-");
scanf("%d",&num1);
printf("enterthe secondnumber:");
scanf("%d",&num2);
result=num1+num2;
printf("sum=%d+%d=%dn",num1,num2,result);
return0;
}
MS. MANSI TYAGI
output(2)/*write a program for multiplicationof twonumber:*/
#include<stdio.h>
#include<conio.h>
intmain()
{
intnum1,num2,result;
printf("enterthe fristnumber:-");
scanf("%d",&num1);
printf("enterthe secondnumber:");
scanf("%d",&num2);
result=num1*num2;
printf("multification=%d*%d=%dn",num1,num2,result);
return0;
}
(3) /*write a program for check negative and positive:*/
#include<stdio.h>
#include<conio.h>
intmain()
{
intnum;
printf("Enteranynumber:");
output
positive
MS. MANSI TYAGI
output
scanf("%d",&num);
if(num>=0)
printf("posativenumbern");
else
printf("negative numbern");
return0;
}
(4) /*write a program for check even and odd:*/
#include<stdio.h>
#include<conio.h>
intmain()
{
intnum;
printf("Enteranynumber:");
scanf("%d",&num);
if(num%2==0)
printf("even numbern");
else
printf("oddnumbern");
return0;
}
negativ
ee
even
odd
MS. MANSI TYAGI
(5) /*write a program for check maximum betweentwonumber:*/
#include<stdio.h>
#include<conio.h>
intmain()
{
intnum1,num2;
printf("Enterfristnumber:");
scanf("%d",&num1);
printf("entersecondnumber:");
scanf("%d",&num2);
if(num1>num2)
{
printf("number1isgreatern");
}
else
printf("number2isgreater");
return0;
}
output
MS. MANSI TYAGI
OUTPUT
6. Write a program to print max. number between three numbers.
#include<stdio.h>
#include<conio.h>
intmain()
{
inta,b,c;
printf("nenterthe fristnumber:");
scanf("%d",&a);
printf("nenterthe secondnumber:");
scanf("%d",&b);
printf("nenterthe thirdnumber:");
scanf("%d",&c);
if(a>b&&a>c)
{
printf("naisgreaternumber=%d",a);
}
else if(b>c)
{
printf("nbisgreaternumber=%d",b);
}
Else
{
printf("ncisgreaternumber=%d",c);
}
return(0);
}
MS. MANSI TYAGI
7. Write a program to print sum of given n number.
intn, i,sum = 0;
printf("Enterapositive integer:");
scanf("%d",&n);
for(i=1;i <= n; ++i)
{
sum += i;
}
printf("Sum=%d",sum);
return0;
}
MS. MANSI TYAGI
8. Write a program to print reverse number.
#include <stdio.h>
#include<conio.h>
intmain()
{
intn, reverse =0;
printf("Enteranumbertoreversen");
scanf("%d",&n);
while (n!=0)
{
reverse =reverse * 10;
reverse =reverse + n%10;
n = n/10;
}
printf("Reverseof enterednumberis=%dn",reverse);
return0;
}
MS. MANSI TYAGI
9. Write a program to print a table of given number.
#include<stdio.h>
#include<conio.h>
intmain()
{
intn, i;
printf("enteranynumber:");
scanf("%d",&n);
for(i=1;i<=10; ++i)
{
printf("%d*%d= %d n",n, i,n*i);
}
return(0);
}
10. Write a program to print for ab .
#include<stdio.h>
#include<conio.h>
intmain()
{
int x,y,i,r=1,t;
printf("Enteranumber:");
scanf("%d",&x);
printf("Enterthe power:");
scanf("%d",&y);
for(i=1;i<=y;i++)
{
t=x;
r=r*t;
}
MS. MANSI TYAGI
printf("Result:%d",r);
return(0);
}
11. Write a program to print factorial of given number.
#include <stdio.h>
#include<conio.h>
intmain()
{
int n,i;
unsignedlonglongfactorial =1;
printf("Enteraninteger:");
scanf("%d",&n);
if (n < 0)
printf("Error!Factorial of anegative numberdoesn'texist.");
else
{
for(i=1;i<=n; ++i)
{
factorial *= i; }
printf("Factorial of %d= %llu",n,factorial);
}
return0;
}
MS. MANSI TYAGI
12. Write a program to print Pascal tringle.
#include <stdio.h>
#include<conio.h>
intmain()
{
int rows,coef = 1, space,i,j;
printf("Enternumberof rows:");
scanf("%d",&rows);
for(i=0;i<rows;i++)
{
for(space=1;space <= rows-i;space++)
printf(" ");
for(j=0;j <= i;j++)
{
if (j==0 || i==0)
coef = 1;
else
coef = coef*(i-j+1)/j;
printf("%4d",coef);
}
printf("n");
}
return0;
}
MS. MANSI TYAGI
13. Write a program to check perfect number.
#include <stdio.h>
#include<conio.h>
intmain()
{
int number,rem,sum= 0, i;
printf("EnteraNumbern");
scanf("%d",&number);
for (i = 1; i <= (number- 1); i++)
{
rem= number%i;
if (rem== 0)
{
sum= sum+ i;
}
}
if (sum== number)
printf("EnteredNumberisperfectnumber");
else
printf("EnteredNumberisnotaperfect number");
return0;
}
MS. MANSI TYAGI
14. Write a program to find HCF of two number.
#include <stdio.h>
#include<conio.h>
intmain()
{
int n1, n2, i,gcd;
printf("Entertwointegers:");
scanf("%d%d",&n1,&n2);
for(i=1;i <= n1 && i <= n2; ++i)
{
if(n1%i==0&& n2%i==0)
gcd = i;
}
printf("G.C.Dof %dand %dis%d", n1, n2, gcd);
return0;
}
15. Write a program to swap two number using third variable.
#include <stdio.h>
#include<conio.h>
intmain()
{
intx, y,temp;
printf("Enterthe value of x andyn");
scanf("%d%d",&x,&y);
printf("Before Swappingnx =%dny=%dn",x,y);
MS. MANSI TYAGI
temp= x;
x = y;
y = temp;
printf("AfterSwappingnx =%dny= %dn",x,y);
return0;
}
16. Write a program to swap two number without using third variable.
#include<stdio.h>
#include<conio.h>
main()
{
inta, b;
printf("enterthe value of a=");
scanf("%d",&a);
printf("enterthe value of b=");
scanf("%d",&b);
printf("Before swapa=%db=%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("nAfterswapa=%db=%d",a,b);
getch();
}
MS. MANSI TYAGI
17. Write a program to check palindrome.
#include <stdio.h>
#include<comcat.h>
intmain()
{
int n,reversedInteger=0, remainder,originalInteger;
printf("Enteraninteger:");
scanf("%d",&n);
originalInteger=n;
while( n!=0)
{
remainder=n%10;
reversedInteger=reversedInteger*10+ remainder;
n /= 10;
}
if (originalInteger== reversedInteger)
printf("%disapalindrome.",originalInteger);
else
printf("%disnotapalindrome.",originalInteger);
return0;
}

More Related Content

What's hot

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
Β 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Dr. Loganathan R
Β 
C program to add two numbers
C program to add two numbers C program to add two numbers
C program to add two numbers mohdshanu
Β 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programsPrasadu Peddi
Β 
Ffffffffffff
FfffffffffffFfffffffffff
Ffffffffffffmohdshanu
Β 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using cArghodeepPaul
Β 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Dr. Loganathan R
Β 
Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Dr. Loganathan R
Β 
Program in β€˜C’ language to implement linear search using pointers
Program in β€˜C’ language to implement linear search using pointersProgram in β€˜C’ language to implement linear search using pointers
Program in β€˜C’ language to implement linear search using pointersDr. Loganathan R
Β 
Dti2143 lab sheet 9
Dti2143 lab sheet 9Dti2143 lab sheet 9
Dti2143 lab sheet 9alish sha
Β 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.Dr. Loganathan R
Β 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Dr. Loganathan R
Β 

What's hot (20)

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
Β 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
Β 
C program to add two numbers
C program to add two numbers C program to add two numbers
C program to add two numbers
Β 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
Β 
Ffffffffffff
FfffffffffffFfffffffffff
Ffffffffffff
Β 
88 c-programs
88 c-programs88 c-programs
88 c-programs
Β 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
Β 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
Β 
Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3
Β 
Program in β€˜C’ language to implement linear search using pointers
Program in β€˜C’ language to implement linear search using pointersProgram in β€˜C’ language to implement linear search using pointers
Program in β€˜C’ language to implement linear search using pointers
Β 
Dti2143 lab sheet 9
Dti2143 lab sheet 9Dti2143 lab sheet 9
Dti2143 lab sheet 9
Β 
Progr3
Progr3Progr3
Progr3
Β 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
Β 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
Β 
Progr2
Progr2Progr2
Progr2
Β 
Shan
ShanShan
Shan
Β 
week-1x
week-1xweek-1x
week-1x
Β 
comp1
comp1comp1
comp1
Β 
comp2
comp2comp2
comp2
Β 
Factorial
FactorialFactorial
Factorial
Β 

Similar to C Language Programs

Core programming in c
Core programming in cCore programming in c
Core programming in cRahul Pandit
Β 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using CBilal Mirza
Β 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)Ashishchinu
Β 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentalsZaibi Gondal
Β 
SaraPIC
SaraPICSaraPIC
SaraPICSara Sahu
Β 
Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7alish sha
Β 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solutionyogini sharma
Β 
C basics
C basicsC basics
C basicsMSc CST
Β 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-yearAMIT 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 .
Β 
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
Β 

Similar to C Language Programs (20)

Core programming in c
Core programming in cCore programming in c
Core programming in c
Β 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
Β 
C file
C fileC file
C file
Β 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
Β 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
Β 
SaraPIC
SaraPICSaraPIC
SaraPIC
Β 
C Programming
C ProgrammingC Programming
C Programming
Β 
C programs pbq final
C programs pbq finalC programs pbq final
C programs pbq final
Β 
Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7
Β 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
Β 
C basics
C basicsC basics
C basics
Β 
Cpds lab
Cpds labCpds lab
Cpds lab
Β 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
Β 
C lab programs
C lab programsC lab programs
C lab programs
Β 
C lab programs
C lab programsC lab programs
C lab programs
Β 
Hargun
HargunHargun
Hargun
Β 
C programs
C programsC programs
C programs
Β 
Programming egs
Programming egs Programming egs
Programming egs
Β 
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 ...
Β 
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
Β 

More from Mansi Tyagi

Unit 5 INTERNATIONAL THEORY
Unit 5 INTERNATIONAL THEORYUnit 5 INTERNATIONAL THEORY
Unit 5 INTERNATIONAL THEORYMansi Tyagi
Β 
Unit 2 foreign trade topic 2 3 4 5
Unit 2 foreign trade topic 2 3 4 5Unit 2 foreign trade topic 2 3 4 5
Unit 2 foreign trade topic 2 3 4 5Mansi Tyagi
Β 
Unit 2 Foreign trade
Unit 2 Foreign tradeUnit 2 Foreign trade
Unit 2 Foreign tradeMansi Tyagi
Β 
Unit 1 international trade
Unit 1 international tradeUnit 1 international trade
Unit 1 international tradeMansi Tyagi
Β 
Unit 1 international trade theory
Unit 1 international trade theoryUnit 1 international trade theory
Unit 1 international trade theoryMansi Tyagi
Β 
Unit 5 Sales Management
Unit 5 Sales ManagementUnit 5 Sales Management
Unit 5 Sales ManagementMansi Tyagi
Β 
Unit 4 Sales Management
Unit 4 Sales ManagementUnit 4 Sales Management
Unit 4 Sales ManagementMansi Tyagi
Β 
Unit 3 Sales Management
Unit 3 Sales ManagementUnit 3 Sales Management
Unit 3 Sales ManagementMansi Tyagi
Β 
Unit 2 Sales Management
Unit 2 Sales ManagementUnit 2 Sales Management
Unit 2 Sales ManagementMansi Tyagi
Β 
Unit 1 Sales Mgt
Unit  1 Sales Mgt Unit  1 Sales Mgt
Unit 1 Sales Mgt Mansi Tyagi
Β 
BONUS ACT (HRM)
BONUS ACT (HRM)BONUS ACT (HRM)
BONUS ACT (HRM)Mansi Tyagi
Β 
RESEARCH REPORT
RESEARCH REPORT RESEARCH REPORT
RESEARCH REPORT Mansi Tyagi
Β 
A study of employee motivation
A study of employee motivationA study of employee motivation
A study of employee motivationMansi Tyagi
Β 
PROJECT REPORT ON CONSUMER BUYING BEHAVIOUR IN INDIAN SHOPPING MALL)
PROJECT REPORT ON  CONSUMER BUYING BEHAVIOUR IN INDIAN SHOPPING MALL) PROJECT REPORT ON  CONSUMER BUYING BEHAVIOUR IN INDIAN SHOPPING MALL)
PROJECT REPORT ON CONSUMER BUYING BEHAVIOUR IN INDIAN SHOPPING MALL) Mansi Tyagi
Β 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEMMansi Tyagi
Β 
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM) FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)Mansi Tyagi
Β 
Problem solving UNIT - 4 [C PROGRAMMING] (BCA I SEM)
Problem solving UNIT - 4 [C PROGRAMMING] (BCA I SEM)Problem solving UNIT - 4 [C PROGRAMMING] (BCA I SEM)
Problem solving UNIT - 4 [C PROGRAMMING] (BCA I SEM)Mansi Tyagi
Β 
PROJECT ON ANDROID APPLICATION
PROJECT ON ANDROID APPLICATIONPROJECT ON ANDROID APPLICATION
PROJECT ON ANDROID APPLICATIONMansi Tyagi
Β 
Role of digital marketing
Role of digital marketingRole of digital marketing
Role of digital marketingMansi Tyagi
Β 
BUSINESS REPORT WRITING
BUSINESS REPORT WRITINGBUSINESS REPORT WRITING
BUSINESS REPORT WRITINGMansi Tyagi
Β 

More from Mansi Tyagi (20)

Unit 5 INTERNATIONAL THEORY
Unit 5 INTERNATIONAL THEORYUnit 5 INTERNATIONAL THEORY
Unit 5 INTERNATIONAL THEORY
Β 
Unit 2 foreign trade topic 2 3 4 5
Unit 2 foreign trade topic 2 3 4 5Unit 2 foreign trade topic 2 3 4 5
Unit 2 foreign trade topic 2 3 4 5
Β 
Unit 2 Foreign trade
Unit 2 Foreign tradeUnit 2 Foreign trade
Unit 2 Foreign trade
Β 
Unit 1 international trade
Unit 1 international tradeUnit 1 international trade
Unit 1 international trade
Β 
Unit 1 international trade theory
Unit 1 international trade theoryUnit 1 international trade theory
Unit 1 international trade theory
Β 
Unit 5 Sales Management
Unit 5 Sales ManagementUnit 5 Sales Management
Unit 5 Sales Management
Β 
Unit 4 Sales Management
Unit 4 Sales ManagementUnit 4 Sales Management
Unit 4 Sales Management
Β 
Unit 3 Sales Management
Unit 3 Sales ManagementUnit 3 Sales Management
Unit 3 Sales Management
Β 
Unit 2 Sales Management
Unit 2 Sales ManagementUnit 2 Sales Management
Unit 2 Sales Management
Β 
Unit 1 Sales Mgt
Unit  1 Sales Mgt Unit  1 Sales Mgt
Unit 1 Sales Mgt
Β 
BONUS ACT (HRM)
BONUS ACT (HRM)BONUS ACT (HRM)
BONUS ACT (HRM)
Β 
RESEARCH REPORT
RESEARCH REPORT RESEARCH REPORT
RESEARCH REPORT
Β 
A study of employee motivation
A study of employee motivationA study of employee motivation
A study of employee motivation
Β 
PROJECT REPORT ON CONSUMER BUYING BEHAVIOUR IN INDIAN SHOPPING MALL)
PROJECT REPORT ON  CONSUMER BUYING BEHAVIOUR IN INDIAN SHOPPING MALL) PROJECT REPORT ON  CONSUMER BUYING BEHAVIOUR IN INDIAN SHOPPING MALL)
PROJECT REPORT ON CONSUMER BUYING BEHAVIOUR IN INDIAN SHOPPING MALL)
Β 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEM
Β 
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM) FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
Β 
Problem solving UNIT - 4 [C PROGRAMMING] (BCA I SEM)
Problem solving UNIT - 4 [C PROGRAMMING] (BCA I SEM)Problem solving UNIT - 4 [C PROGRAMMING] (BCA I SEM)
Problem solving UNIT - 4 [C PROGRAMMING] (BCA I SEM)
Β 
PROJECT ON ANDROID APPLICATION
PROJECT ON ANDROID APPLICATIONPROJECT ON ANDROID APPLICATION
PROJECT ON ANDROID APPLICATION
Β 
Role of digital marketing
Role of digital marketingRole of digital marketing
Role of digital marketing
Β 
BUSINESS REPORT WRITING
BUSINESS REPORT WRITINGBUSINESS REPORT WRITING
BUSINESS REPORT WRITING
Β 

Recently uploaded

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
Β 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
Β 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
Β 
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
Β 
β€œ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
Β 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
Β 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
Β 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
Β 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
Β 
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
Β 
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
Β 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
Β 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
Β 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
Β 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
Β 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
Β 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
Β 

Recently uploaded (20)

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
Β 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
Β 
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πŸ”
Β 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
Β 
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
Β 
β€œ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...
Β 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Β 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
Β 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
Β 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
Β 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
Β 
Model Call Girl in Tilak Nagar Delhi reach out to us at πŸ”9953056974πŸ”
Model Call Girl in Tilak Nagar Delhi reach out to us at πŸ”9953056974πŸ”Model Call Girl in Tilak Nagar Delhi reach out to us at πŸ”9953056974πŸ”
Model Call Girl in Tilak Nagar Delhi reach out to us at πŸ”9953056974πŸ”
Β 
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
Β 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
Β 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
Β 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
Β 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
Β 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
Β 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
Β 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
Β 

C Language Programs

  • 1. MS. MANSI TYAGI output PROGRAMS (1) /*write a program for addition of two number:*/ #include<stdio.h> #include<conio.h> intmain() { intnum1,num2,result; printf("enterthe fristnumber:-"); scanf("%d",&num1); printf("enterthe secondnumber:"); scanf("%d",&num2); result=num1+num2; printf("sum=%d+%d=%dn",num1,num2,result); return0; }
  • 2. MS. MANSI TYAGI output(2)/*write a program for multiplicationof twonumber:*/ #include<stdio.h> #include<conio.h> intmain() { intnum1,num2,result; printf("enterthe fristnumber:-"); scanf("%d",&num1); printf("enterthe secondnumber:"); scanf("%d",&num2); result=num1*num2; printf("multification=%d*%d=%dn",num1,num2,result); return0; } (3) /*write a program for check negative and positive:*/ #include<stdio.h> #include<conio.h> intmain() { intnum; printf("Enteranynumber:"); output positive
  • 3. MS. MANSI TYAGI output scanf("%d",&num); if(num>=0) printf("posativenumbern"); else printf("negative numbern"); return0; } (4) /*write a program for check even and odd:*/ #include<stdio.h> #include<conio.h> intmain() { intnum; printf("Enteranynumber:"); scanf("%d",&num); if(num%2==0) printf("even numbern"); else printf("oddnumbern"); return0; } negativ ee even odd
  • 4. MS. MANSI TYAGI (5) /*write a program for check maximum betweentwonumber:*/ #include<stdio.h> #include<conio.h> intmain() { intnum1,num2; printf("Enterfristnumber:"); scanf("%d",&num1); printf("entersecondnumber:"); scanf("%d",&num2); if(num1>num2) { printf("number1isgreatern"); } else printf("number2isgreater"); return0; } output
  • 5. MS. MANSI TYAGI OUTPUT 6. Write a program to print max. number between three numbers. #include<stdio.h> #include<conio.h> intmain() { inta,b,c; printf("nenterthe fristnumber:"); scanf("%d",&a); printf("nenterthe secondnumber:"); scanf("%d",&b); printf("nenterthe thirdnumber:"); scanf("%d",&c); if(a>b&&a>c) { printf("naisgreaternumber=%d",a); } else if(b>c) { printf("nbisgreaternumber=%d",b); } Else { printf("ncisgreaternumber=%d",c); } return(0); }
  • 6. MS. MANSI TYAGI 7. Write a program to print sum of given n number. intn, i,sum = 0; printf("Enterapositive integer:"); scanf("%d",&n); for(i=1;i <= n; ++i) { sum += i; } printf("Sum=%d",sum); return0; }
  • 7. MS. MANSI TYAGI 8. Write a program to print reverse number. #include <stdio.h> #include<conio.h> intmain() { intn, reverse =0; printf("Enteranumbertoreversen"); scanf("%d",&n); while (n!=0) { reverse =reverse * 10; reverse =reverse + n%10; n = n/10; } printf("Reverseof enterednumberis=%dn",reverse); return0; }
  • 8. MS. MANSI TYAGI 9. Write a program to print a table of given number. #include<stdio.h> #include<conio.h> intmain() { intn, i; printf("enteranynumber:"); scanf("%d",&n); for(i=1;i<=10; ++i) { printf("%d*%d= %d n",n, i,n*i); } return(0); } 10. Write a program to print for ab . #include<stdio.h> #include<conio.h> intmain() { int x,y,i,r=1,t; printf("Enteranumber:"); scanf("%d",&x); printf("Enterthe power:"); scanf("%d",&y); for(i=1;i<=y;i++) { t=x; r=r*t; }
  • 9. MS. MANSI TYAGI printf("Result:%d",r); return(0); } 11. Write a program to print factorial of given number. #include <stdio.h> #include<conio.h> intmain() { int n,i; unsignedlonglongfactorial =1; printf("Enteraninteger:"); scanf("%d",&n); if (n < 0) printf("Error!Factorial of anegative numberdoesn'texist."); else { for(i=1;i<=n; ++i) { factorial *= i; } printf("Factorial of %d= %llu",n,factorial); } return0; }
  • 10. MS. MANSI TYAGI 12. Write a program to print Pascal tringle. #include <stdio.h> #include<conio.h> intmain() { int rows,coef = 1, space,i,j; printf("Enternumberof rows:"); scanf("%d",&rows); for(i=0;i<rows;i++) { for(space=1;space <= rows-i;space++) printf(" "); for(j=0;j <= i;j++) { if (j==0 || i==0) coef = 1; else coef = coef*(i-j+1)/j; printf("%4d",coef); } printf("n"); } return0; }
  • 11. MS. MANSI TYAGI 13. Write a program to check perfect number. #include <stdio.h> #include<conio.h> intmain() { int number,rem,sum= 0, i; printf("EnteraNumbern"); scanf("%d",&number); for (i = 1; i <= (number- 1); i++) { rem= number%i; if (rem== 0) { sum= sum+ i; } } if (sum== number) printf("EnteredNumberisperfectnumber"); else printf("EnteredNumberisnotaperfect number"); return0; }
  • 12. MS. MANSI TYAGI 14. Write a program to find HCF of two number. #include <stdio.h> #include<conio.h> intmain() { int n1, n2, i,gcd; printf("Entertwointegers:"); scanf("%d%d",&n1,&n2); for(i=1;i <= n1 && i <= n2; ++i) { if(n1%i==0&& n2%i==0) gcd = i; } printf("G.C.Dof %dand %dis%d", n1, n2, gcd); return0; } 15. Write a program to swap two number using third variable. #include <stdio.h> #include<conio.h> intmain() { intx, y,temp; printf("Enterthe value of x andyn"); scanf("%d%d",&x,&y); printf("Before Swappingnx =%dny=%dn",x,y);
  • 13. MS. MANSI TYAGI temp= x; x = y; y = temp; printf("AfterSwappingnx =%dny= %dn",x,y); return0; } 16. Write a program to swap two number without using third variable. #include<stdio.h> #include<conio.h> main() { inta, b; printf("enterthe value of a="); scanf("%d",&a); printf("enterthe value of b="); scanf("%d",&b); printf("Before swapa=%db=%d",a,b); a=a+b; b=a-b; a=a-b; printf("nAfterswapa=%db=%d",a,b); getch(); }
  • 14. MS. MANSI TYAGI 17. Write a program to check palindrome. #include <stdio.h> #include<comcat.h> intmain() { int n,reversedInteger=0, remainder,originalInteger; printf("Enteraninteger:"); scanf("%d",&n); originalInteger=n; while( n!=0) { remainder=n%10; reversedInteger=reversedInteger*10+ remainder; n /= 10; } if (originalInteger== reversedInteger) printf("%disapalindrome.",originalInteger); else printf("%disnotapalindrome.",originalInteger); return0; }