SlideShare una empresa de Scribd logo
1 de 26
1. Program to Find Sum and Average of Three Real Numbers. 
#include <stdio.h> 
#include<conio.h> 
main() 
{ 
float a, b, c, sum, avg; 
printf("nEnter value of three numbers: "); 
scanf("%f %f %f", &a, &b, &c); 
sum = a + b + c; 
avg = sum / 3; 
printf("nSum = %f", sum); 
printf("nAverage = %f", avg); 
getch(); 
} 
Output: 
1
2. Program to Find Area of Square & Circumference of a Circle. 
#include <stdio.h> 
#include<conio.h> 
#define PI 3.142 
main() 
{ 
float len, r, area, circum; 
printf("nEnter length of a square: "); 
scanf("%f", &len); 
area = len * len; 
printf("nEnter radius of a circle: "); 
scanf("%f", &r); 
circum = 2 * PI * r; 
printf("nArea of square = %f", area); 
printf("nCircumference of circle = %f", circum); 
getch(); 
} 
Output: 
2
3. Program to Find Area of a Triangle using Hero’s Formula . 
#include <stdio.h> 
#include<conio.h> 
#include <math.h> 
main() 
{ 
float a, b, c, s, area; 
printf("nEnter three sides of a triangle: "); 
scanf("%f %f %f", &a, &b, &c); 
s = (a + b + c) / 2; 
area = sqrt(s * (s - a) * (s - b) * (s - c)); 
printf("nnArea of triangle: %f", area); 
getch(); 
} 
Output: 
3
4. Program to find Simple Interest and Compound Interest. 
SI = (p * r * t) / 100 
CI = p * pow((1 + r/100), t) - p 
#include <stdio.h> 
#include<conio.h> 
#include <math.h> 
main() 
{ 
float p, r, t, si, ci; 
printf("nEnter priciple, rate and time: "); 
scanf("%f %f %f", &p, &r, &t); 
si = (p * r * t) / 100; 
ci = p * pow((1 + r/100), t) - p; 
printf("nnSimple Interest: %f", si); 
printf("nnCompound Interest: %f", ci); 
getch(); 
} 
Output: 
4
5. Basic salary of an employee is input through the keyboard. The DA 
is 25% of the basic salary while the HRA is 15% of the basic 
salary. Provident Fund is deducted at the rate of 10% of the gross 
salary(BS+DA+HRA). 
Program to Calculate the Net Salary. 
#include <stdio.h> 
#include<conio.h> 
main() 
{ 
float basic_sal, da, hra, pf, gross_sal, net_sal; 
printf("nEnter basic salary of the employee: Rs. "); 
scanf("%f", &basic_sal); 
da = (basic_sal * 25)/100; 
hra = (basic_sal * 15)/100; 
gross_sal = basic_sal + da + hra; 
pf = (gross_sal * 10)/100; 
net_sal = gross_sal - pf; 
printf("nnNet Salary: Rs. %f", net_sal); 
getch(); 
} 
Output: 
5
6.Program to Swap Values of Two Variables Without using 3rd Variable 
#include <stdio.h> 
#include<conio.h> 
main() 
{ 
int a, b, temp; 
printf("nEnter any two numbers: "); 
scanf("%d %d", &a, &b); 
printf("nnBefore Swapping:n"); 
printf("na = %dn", a); 
printf("nb = %dn", b); 
a = a + b; 
b = a - b; 
a = a - b; 
printf("nnAfter Swapping:n"); 
printf("na = %dn", a); 
printf("nb = %dn", b); 
getch(); 
6 
} 
Output:
7. Program to Swap Values of Two Variables using Third Variable 
#include <stdio.h> 
#include<conio.h> 
main() 
{ 
int a, b, temp; 
printf("nEnter any two numbers: "); 
scanf("%d %d", &a, &b); 
printf("nnBefore Swapping:n"); 
printf("na = %dn", a); 
printf("nb = %dn", b); 
temp = a; 
a = b; 
b = temp; 
printf("nnAfter Swapping:n"); 
printf("na = %dn", a); 
printf("nb = %dn", b); 
getch(); 
7 
} 
Output:
8. Program to Find Largest of Three Numbers . 
#include <stdio.h> 
#include<conio.h> 
main() 
{ 
int a, b, c; 
printf("nEnter three numbers: "); 
scanf("%d %d %d", &a, &b, &c); 
if (a>b && a>c) 
printf("nn%d is greater", a); 
else if (b>a && b>c) 
printf("nn%d is greater", b); 
else 
printf("nn%d is greater", c); 
getch(); 
} 
Output: 
8
9. Program to Check Whether a Character is a Vowel or not by using 
switch Statement 
#include <stdio.h> 
#include<conio.h> 
main() 
{ 
char ch; 
printf("nEnter any character: "); 
scanf("%c", &ch); 
switch (ch) 
{ 
case 'a': 
case 'A': 
printf("nn%c is a vowel", ch); 
break; 
case 'e': 
case 'E': 
printf("nn%c is a vowel", ch); 
break; 
case 'i': 
case 'I': 
printf("nn%c is a vowel", ch); 
break; 
case 'o': 
case 'O': 
printf("nn%c is a vowel", ch); 
break; 
case 'u': 
case 'U': 
printf("nn%c is a vowel", ch); 
break; 
default: 
printf("nn%c is not a vowel", ch); 
} 
getch(); 
} 
9
Output: 
10
10. Program to Find the Sum of First 100 Positive Integers . 
#include <stdio.h> 
#include<conio.h> 
main() 
{ 
int i, sum=0; 
printf("ntSum of first 100 positive numbersn"); 
for(i=0; i<=100; i++) 
sum = sum + i; 
printf("nSum = %d", sum); 
getch(); 
} 
Output: 
11
11. Program to Find the Sum of Even and Odd Numbers from First 100 
Positive Integers 
#include <stdio.h> 
#include<conio.h> 
main() 
{ 
int i, sumEven=0, sumOdd=0; 
for (i=0; i<=100; i++) 
if (i%2 == 0) 
sumEven = sumEven + i; 
else 
sumOdd = sumOdd + i; 
printf("nSum of first even 100 numbers: %dn", sumEven); 
printf("nSum of first odd 100 numbers: %dn", sumOdd); 
getch(); 
} 
Output: 
12
12. Program to Print a Table of any Number . 
#include <stdio.h> 
#include<conio.h> 
main() 
{ 
int n, mul, i; 
printf("nEnter any no.: "); 
scanf("%d", &n); 
for(i=1; i<=10; i++) 
{ 
mul = n*i; 
printf("nn%dtxt%dt=t%d", n, i, mul); 
} 
getch(); 
} 
Output: 
13
13. Program to Print the Numbers, Which are Divisible by 3 and 5 from 
First 100 Natural Numbers 
#include <stdio.h> 
#include<conio.h> 
main() 
{ 
int i; 
printf("nFirst 100 numbers which are divisible by 3 and 
5nn"); 
for (i=1; i<=100; i++) 
if (i%3==0 && i%5==0) 
printf("t%d", i); 
getch(); 
14 
} 
Output:
14. Program to Find Factorial of a Number using Recursion 
#include <stdio.h> 
#include<conio.h> 
long fact(int); 
main() 
{ 
int n; 
long f; 
printf("nEnter number to find factorial: "); 
scanf("%d", &n); 
f = fact(n); 
printf("nFactorial: %ld", f); 
getch(); 
} 
long fact(int n) 
{ 
int m; 
if (n == 1) 
return n; 
else 
{ 
m = n * fact(n-1); 
return m; 
} 
} 
15
15.Program to Reverse a Given Number . 
#include <stdio.h> 
#include<conio.h> 
main() 
{ 
long n; 
int rev; 
printf("nEnter any number: "); 
scanf("%ld", &n); 
printf("nReverse no. is:nn"); 
while (n > 0) 
{ 
rev = n % 10; 
n = n / 10; 
printf("%d", rev); 
} 
getch(); 
} 
Output: 
16
16. Program to Find Vowels in a String. 
#include <stdio.h> 
#include <string.h> 
#include<conio.h> 
main() 
{ 
char str[20]; 
int count=0, i=0; 
printf("nEnter any string: "); 
gets(str); 
while (str[i] != '0') 
{ 
if (str[i]=='a' || str[i]=='e' || str[i]=='i' || 
str[i]=='o' || str[i]=='u') 
count++; 
i++; 
} 
printf("nNo. of vowels: %d", count); 
getch(); 
} 
Output: 
17
17. Program to add two matrices. 
#include <stdio.h> 
#include<conio.h> 
main() 
{ 
int a[10][10], b[10][10], c[10][10], i, j, row, col; 
printf("nEnter number of rows and columns: "); 
scanf("%d %d", &row, &col); 
printf("nEnter elements of Array A:n"); 
for (i=0; i<row; i++) 
for (j=0; j<col; j++) 
scanf("%d", &a[i][j]); 
printf("nEnter elements of Array B:n"); 
for (i=0; i<row; i++) 
for (j=0; j<col; j++) 
scanf("%d", &b[i][j]); 
printf("nElements of Matrix A:nn"); 
for (i=0; i<row; i++) 
{ 
for (j=0; j<col; j++) 
printf("t%d", a[i][j]); 
printf("nn"); 
} 
printf("nElements of Matrix B:nn"); 
for (i=0; i<row; i++) 
{ 
for (j=0; j<col; j++) 
printf("t%d", b[i][j]); 
printf("nn"); 
} 
for (i=0; i<row; i++) 
for (j=0; j<col; j++) 
c[i][j] = a[i][j] + b[i][j]; 
printf("nMatrix Addition is:nn"); 
for (i=0; i<row; i++) 
{ 
for (j=0; j<col; j++) 
printf("t%d", c[i][j]); 
printf("n"); 
} 
getch(); 
} 
18
Output: 
19
18. Program to Concatenate Two Strings using strcat (). 
#include <stdio.h> 
#include <string.h> 
#include<conio.h> 
main() 
{ 
char s1[20], s2[20]; 
printf("nEnter first string: "); 
gets(s1); 
printf("nEnter second string: "); 
gets(s2); 
strcat(s1, s2); 
printf("nThe concatenated string is: %s", s1); 
getch(); 
} 
Output: 
20
19. Program to Concatenate Two Strings without using strcat (). 
#include <stdio.h> 
#include <conio.h> 
#include <string.h> 
main() 
{ 
char string1[30], string2[20]; 
int i, length=0, temp; 
printf("Enter the Value of String1: n"); 
gets(string1); 
printf("nEnter the Value of String2: n"); 
gets(string2); 
for(i=0; string1[i]!='0'; i++) 
length++; 
temp = length; 
for(i=0; string2[i]!='0'; i++) 
{ 
string1[temp] = string2[i]; 
temp++; 
} 
string1[temp] = '0'; 
printf("nThe concatenated string is:n"); 
puts(string1); 
getch(); 
} 
Output: 
21
20. Program to Compare Two Strings using strcmp() . 
#include <stdio.h> 
#include<conio.h> 
#include <string.h> 
main() 
{ 
char s1[20], s2[20]; 
int result; 
printf("nEnter first string: "); 
gets(s1); 
printf("nEnter second string: "); 
gets(s2); 
result = strcmp(s1, s2); 
if (result == 0) 
printf("nBoth strings are equal"); 
else 
printf("nBoth strings are not equal"); 
getch(); 
} 
Output: 
22
21. Program to Compare Two Strings Without using strcmp() . 
#include<stdio.h> 
#include<conio.h> 
main() 
{ 
char string1[5],string2[5]; 
int i,temp = 0; 
printf("Enter the string1 value:n"); 
gets(string1); 
printf("nEnter the String2 value:n"); 
gets(string2); 
for(i=0; string1[i]!='0'; i++) 
{ 
if(string1[i] == string2[i]) 
temp = 1; 
else 
temp = 0; 
} 
if(temp == 1) 
printf("Both strings are same."); 
else 
printf("Both string not same."); 
getch(); 
} 
Output: 
23
22. Program to Copy String using strcpy() . 
#include <stdio.h> 
#include<conio.h> 
#include <string.h> 
main() 
{ 
char s1[20], s2[20]; 
printf("nEnter string into s1: "); 
gets(s1); 
strcpy(s2, s1); 
printf("ns2: %s", s2); 
getch(); 
} 
Output: 
24
23. Program to Find Length of a String using strlen(). 
#include <stdio.h> 
#include<conio.h> 
#include <string.h> 
main() 
{ 
char s1[20]; 
int len; 
printf("nEnter any string: "); 
gets(s1); 
len = strlen(s1); 
printf("nLength of string: %d", len); 
getch(); 
} 
Output: 
25
24. Program to Reverse a String without using strrev() . 
#include <stdio.h> 
#include <conio.h> 
#include <string.h> 
main() 
{ 
char string1[10], string2[10]; 
int i, length; 
printf("Enter any string:n"); 
gets(string1); 
length = strlen(string1)-1; 
for(i=0; string1[i]!='0'; i++) 
{ 
string2[length]=string1[i]; 
length--; 
} 
string2[length]='0'; 
printf("nThe Reverse of string is:n"); 
puts(string2); 
getch(); 
} 
Output: 
26

Más contenido relacionado

La actualidad más candente

C program to check leap year
C program to check leap year C program to check leap year
C program to check leap year mohdshanu
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robinAbdullah Al Naser
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using CBilal Mirza
 
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
 
Core programming in c
Core programming in cCore programming in c
Core programming in cRahul Pandit
 
some basic C programs with outputs
some basic C programs with outputssome basic C programs with outputs
some basic C programs with outputsKULDEEPSING PATIL
 
C programs
C programsC programs
C programsMinu S
 
Simple C programs
Simple C programsSimple C programs
Simple C programsab11cs001
 
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
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solutionyogini sharma
 
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 .
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysisVishal Singh
 

La actualidad más candente (20)

C program to check leap year
C program to check leap year C program to check leap year
C program to check leap year
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
C Programming
C ProgrammingC Programming
C Programming
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robin
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using 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
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
some basic C programs with outputs
some basic C programs with outputssome basic C programs with outputs
some basic C programs with outputs
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
C programs
C programsC programs
C programs
 
C programms
C programmsC programms
C programms
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Simple C programs
Simple C programsSimple C programs
Simple C programs
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
 
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 ...
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 

Destacado

Half term quiz
Half term quizHalf term quiz
Half term quizbfisher11
 
Dossier de présentation Gospel Air 2016 Lausanne
Dossier de présentation Gospel Air 2016 LausanneDossier de présentation Gospel Air 2016 Lausanne
Dossier de présentation Gospel Air 2016 Lausanneapaschou
 
Music Magazine Analysis
Music Magazine AnalysisMusic Magazine Analysis
Music Magazine AnalysisCloee Lang
 
Картофель: мягкой посадки. Глава 5
Картофель: мягкой посадки. Глава 5Картофель: мягкой посадки. Глава 5
Картофель: мягкой посадки. Глава 5grisiuck
 
Departments and its functions
Departments and its functionsDepartments and its functions
Departments and its functionsAshutosh Bhalerao
 
Diapo ingles
Diapo inglesDiapo ingles
Diapo inglesjemsen
 
Photoshop project tutorial
Photoshop project tutorialPhotoshop project tutorial
Photoshop project tutorialmeyrni-ahmed
 
Handling inputs via io..continue
Handling inputs via io..continueHandling inputs via io..continue
Handling inputs via io..continuesimarsimmygrewal
 

Destacado (17)

Half term quiz
Half term quizHalf term quiz
Half term quiz
 
Lighting
LightingLighting
Lighting
 
Belk IT
Belk IT Belk IT
Belk IT
 
Dossier de présentation Gospel Air 2016 Lausanne
Dossier de présentation Gospel Air 2016 LausanneDossier de présentation Gospel Air 2016 Lausanne
Dossier de présentation Gospel Air 2016 Lausanne
 
Music Magazine Analysis
Music Magazine AnalysisMusic Magazine Analysis
Music Magazine Analysis
 
Картофель: мягкой посадки. Глава 5
Картофель: мягкой посадки. Глава 5Картофель: мягкой посадки. Глава 5
Картофель: мягкой посадки. Глава 5
 
Departments and its functions
Departments and its functionsDepartments and its functions
Departments and its functions
 
Diapo ingles
Diapo inglesDiapo ingles
Diapo ingles
 
Photoshop project tutorial
Photoshop project tutorialPhotoshop project tutorial
Photoshop project tutorial
 
Handling inputs via io..continue
Handling inputs via io..continueHandling inputs via io..continue
Handling inputs via io..continue
 
Applied statistics manufacturing (1)
Applied statistics manufacturing (1)Applied statistics manufacturing (1)
Applied statistics manufacturing (1)
 
Conventional representation
Conventional representationConventional representation
Conventional representation
 
Step 1
Step 1Step 1
Step 1
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled Presentation
 
Java file
Java fileJava file
Java file
 
Evaluation
EvaluationEvaluation
Evaluation
 
Doe process-development-validation
Doe process-development-validationDoe process-development-validation
Doe process-development-validation
 

Similar a C file

Similar a C file (19)

PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfPCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdf
 
PCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxPCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docx
 
C lab
C labC lab
C lab
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
C
CC
C
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Progr3
Progr3Progr3
Progr3
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
C basics
C basicsC basics
C basics
 
Basic C Programming Lab Practice
Basic C Programming Lab PracticeBasic C Programming Lab Practice
Basic C Programming Lab Practice
 
C programming
C programmingC programming
C programming
 
C faq pdf
C faq pdfC faq pdf
C faq pdf
 
Hargun
HargunHargun
Hargun
 
C programs
C programsC programs
C programs
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solution
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
C Programming Lab.pdf
C Programming Lab.pdfC Programming Lab.pdf
C Programming Lab.pdf
 

Más de simarsimmygrewal (7)

Java file
Java fileJava file
Java file
 
C file
C fileC file
C file
 
C++ file
C++ fileC++ file
C++ file
 
Handling inputs via scanner class
Handling inputs via scanner classHandling inputs via scanner class
Handling inputs via scanner class
 
Excception handling
Excception handlingExcception handling
Excception handling
 
Type casting
Type castingType casting
Type casting
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 

Último

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
 
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
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 

Último (20)

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
 
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
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 

C file

  • 1. 1. Program to Find Sum and Average of Three Real Numbers. #include <stdio.h> #include<conio.h> main() { float a, b, c, sum, avg; printf("nEnter value of three numbers: "); scanf("%f %f %f", &a, &b, &c); sum = a + b + c; avg = sum / 3; printf("nSum = %f", sum); printf("nAverage = %f", avg); getch(); } Output: 1
  • 2. 2. Program to Find Area of Square & Circumference of a Circle. #include <stdio.h> #include<conio.h> #define PI 3.142 main() { float len, r, area, circum; printf("nEnter length of a square: "); scanf("%f", &len); area = len * len; printf("nEnter radius of a circle: "); scanf("%f", &r); circum = 2 * PI * r; printf("nArea of square = %f", area); printf("nCircumference of circle = %f", circum); getch(); } Output: 2
  • 3. 3. Program to Find Area of a Triangle using Hero’s Formula . #include <stdio.h> #include<conio.h> #include <math.h> main() { float a, b, c, s, area; printf("nEnter three sides of a triangle: "); scanf("%f %f %f", &a, &b, &c); s = (a + b + c) / 2; area = sqrt(s * (s - a) * (s - b) * (s - c)); printf("nnArea of triangle: %f", area); getch(); } Output: 3
  • 4. 4. Program to find Simple Interest and Compound Interest. SI = (p * r * t) / 100 CI = p * pow((1 + r/100), t) - p #include <stdio.h> #include<conio.h> #include <math.h> main() { float p, r, t, si, ci; printf("nEnter priciple, rate and time: "); scanf("%f %f %f", &p, &r, &t); si = (p * r * t) / 100; ci = p * pow((1 + r/100), t) - p; printf("nnSimple Interest: %f", si); printf("nnCompound Interest: %f", ci); getch(); } Output: 4
  • 5. 5. Basic salary of an employee is input through the keyboard. The DA is 25% of the basic salary while the HRA is 15% of the basic salary. Provident Fund is deducted at the rate of 10% of the gross salary(BS+DA+HRA). Program to Calculate the Net Salary. #include <stdio.h> #include<conio.h> main() { float basic_sal, da, hra, pf, gross_sal, net_sal; printf("nEnter basic salary of the employee: Rs. "); scanf("%f", &basic_sal); da = (basic_sal * 25)/100; hra = (basic_sal * 15)/100; gross_sal = basic_sal + da + hra; pf = (gross_sal * 10)/100; net_sal = gross_sal - pf; printf("nnNet Salary: Rs. %f", net_sal); getch(); } Output: 5
  • 6. 6.Program to Swap Values of Two Variables Without using 3rd Variable #include <stdio.h> #include<conio.h> main() { int a, b, temp; printf("nEnter any two numbers: "); scanf("%d %d", &a, &b); printf("nnBefore Swapping:n"); printf("na = %dn", a); printf("nb = %dn", b); a = a + b; b = a - b; a = a - b; printf("nnAfter Swapping:n"); printf("na = %dn", a); printf("nb = %dn", b); getch(); 6 } Output:
  • 7. 7. Program to Swap Values of Two Variables using Third Variable #include <stdio.h> #include<conio.h> main() { int a, b, temp; printf("nEnter any two numbers: "); scanf("%d %d", &a, &b); printf("nnBefore Swapping:n"); printf("na = %dn", a); printf("nb = %dn", b); temp = a; a = b; b = temp; printf("nnAfter Swapping:n"); printf("na = %dn", a); printf("nb = %dn", b); getch(); 7 } Output:
  • 8. 8. Program to Find Largest of Three Numbers . #include <stdio.h> #include<conio.h> main() { int a, b, c; printf("nEnter three numbers: "); scanf("%d %d %d", &a, &b, &c); if (a>b && a>c) printf("nn%d is greater", a); else if (b>a && b>c) printf("nn%d is greater", b); else printf("nn%d is greater", c); getch(); } Output: 8
  • 9. 9. Program to Check Whether a Character is a Vowel or not by using switch Statement #include <stdio.h> #include<conio.h> main() { char ch; printf("nEnter any character: "); scanf("%c", &ch); switch (ch) { case 'a': case 'A': printf("nn%c is a vowel", ch); break; case 'e': case 'E': printf("nn%c is a vowel", ch); break; case 'i': case 'I': printf("nn%c is a vowel", ch); break; case 'o': case 'O': printf("nn%c is a vowel", ch); break; case 'u': case 'U': printf("nn%c is a vowel", ch); break; default: printf("nn%c is not a vowel", ch); } getch(); } 9
  • 11. 10. Program to Find the Sum of First 100 Positive Integers . #include <stdio.h> #include<conio.h> main() { int i, sum=0; printf("ntSum of first 100 positive numbersn"); for(i=0; i<=100; i++) sum = sum + i; printf("nSum = %d", sum); getch(); } Output: 11
  • 12. 11. Program to Find the Sum of Even and Odd Numbers from First 100 Positive Integers #include <stdio.h> #include<conio.h> main() { int i, sumEven=0, sumOdd=0; for (i=0; i<=100; i++) if (i%2 == 0) sumEven = sumEven + i; else sumOdd = sumOdd + i; printf("nSum of first even 100 numbers: %dn", sumEven); printf("nSum of first odd 100 numbers: %dn", sumOdd); getch(); } Output: 12
  • 13. 12. Program to Print a Table of any Number . #include <stdio.h> #include<conio.h> main() { int n, mul, i; printf("nEnter any no.: "); scanf("%d", &n); for(i=1; i<=10; i++) { mul = n*i; printf("nn%dtxt%dt=t%d", n, i, mul); } getch(); } Output: 13
  • 14. 13. Program to Print the Numbers, Which are Divisible by 3 and 5 from First 100 Natural Numbers #include <stdio.h> #include<conio.h> main() { int i; printf("nFirst 100 numbers which are divisible by 3 and 5nn"); for (i=1; i<=100; i++) if (i%3==0 && i%5==0) printf("t%d", i); getch(); 14 } Output:
  • 15. 14. Program to Find Factorial of a Number using Recursion #include <stdio.h> #include<conio.h> long fact(int); main() { int n; long f; printf("nEnter number to find factorial: "); scanf("%d", &n); f = fact(n); printf("nFactorial: %ld", f); getch(); } long fact(int n) { int m; if (n == 1) return n; else { m = n * fact(n-1); return m; } } 15
  • 16. 15.Program to Reverse a Given Number . #include <stdio.h> #include<conio.h> main() { long n; int rev; printf("nEnter any number: "); scanf("%ld", &n); printf("nReverse no. is:nn"); while (n > 0) { rev = n % 10; n = n / 10; printf("%d", rev); } getch(); } Output: 16
  • 17. 16. Program to Find Vowels in a String. #include <stdio.h> #include <string.h> #include<conio.h> main() { char str[20]; int count=0, i=0; printf("nEnter any string: "); gets(str); while (str[i] != '0') { if (str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u') count++; i++; } printf("nNo. of vowels: %d", count); getch(); } Output: 17
  • 18. 17. Program to add two matrices. #include <stdio.h> #include<conio.h> main() { int a[10][10], b[10][10], c[10][10], i, j, row, col; printf("nEnter number of rows and columns: "); scanf("%d %d", &row, &col); printf("nEnter elements of Array A:n"); for (i=0; i<row; i++) for (j=0; j<col; j++) scanf("%d", &a[i][j]); printf("nEnter elements of Array B:n"); for (i=0; i<row; i++) for (j=0; j<col; j++) scanf("%d", &b[i][j]); printf("nElements of Matrix A:nn"); for (i=0; i<row; i++) { for (j=0; j<col; j++) printf("t%d", a[i][j]); printf("nn"); } printf("nElements of Matrix B:nn"); for (i=0; i<row; i++) { for (j=0; j<col; j++) printf("t%d", b[i][j]); printf("nn"); } for (i=0; i<row; i++) for (j=0; j<col; j++) c[i][j] = a[i][j] + b[i][j]; printf("nMatrix Addition is:nn"); for (i=0; i<row; i++) { for (j=0; j<col; j++) printf("t%d", c[i][j]); printf("n"); } getch(); } 18
  • 20. 18. Program to Concatenate Two Strings using strcat (). #include <stdio.h> #include <string.h> #include<conio.h> main() { char s1[20], s2[20]; printf("nEnter first string: "); gets(s1); printf("nEnter second string: "); gets(s2); strcat(s1, s2); printf("nThe concatenated string is: %s", s1); getch(); } Output: 20
  • 21. 19. Program to Concatenate Two Strings without using strcat (). #include <stdio.h> #include <conio.h> #include <string.h> main() { char string1[30], string2[20]; int i, length=0, temp; printf("Enter the Value of String1: n"); gets(string1); printf("nEnter the Value of String2: n"); gets(string2); for(i=0; string1[i]!='0'; i++) length++; temp = length; for(i=0; string2[i]!='0'; i++) { string1[temp] = string2[i]; temp++; } string1[temp] = '0'; printf("nThe concatenated string is:n"); puts(string1); getch(); } Output: 21
  • 22. 20. Program to Compare Two Strings using strcmp() . #include <stdio.h> #include<conio.h> #include <string.h> main() { char s1[20], s2[20]; int result; printf("nEnter first string: "); gets(s1); printf("nEnter second string: "); gets(s2); result = strcmp(s1, s2); if (result == 0) printf("nBoth strings are equal"); else printf("nBoth strings are not equal"); getch(); } Output: 22
  • 23. 21. Program to Compare Two Strings Without using strcmp() . #include<stdio.h> #include<conio.h> main() { char string1[5],string2[5]; int i,temp = 0; printf("Enter the string1 value:n"); gets(string1); printf("nEnter the String2 value:n"); gets(string2); for(i=0; string1[i]!='0'; i++) { if(string1[i] == string2[i]) temp = 1; else temp = 0; } if(temp == 1) printf("Both strings are same."); else printf("Both string not same."); getch(); } Output: 23
  • 24. 22. Program to Copy String using strcpy() . #include <stdio.h> #include<conio.h> #include <string.h> main() { char s1[20], s2[20]; printf("nEnter string into s1: "); gets(s1); strcpy(s2, s1); printf("ns2: %s", s2); getch(); } Output: 24
  • 25. 23. Program to Find Length of a String using strlen(). #include <stdio.h> #include<conio.h> #include <string.h> main() { char s1[20]; int len; printf("nEnter any string: "); gets(s1); len = strlen(s1); printf("nLength of string: %d", len); getch(); } Output: 25
  • 26. 24. Program to Reverse a String without using strrev() . #include <stdio.h> #include <conio.h> #include <string.h> main() { char string1[10], string2[10]; int i, length; printf("Enter any string:n"); gets(string1); length = strlen(string1)-1; for(i=0; string1[i]!='0'; i++) { string2[length]=string1[i]; length--; } string2[length]='0'; printf("nThe Reverse of string is:n"); puts(string2); getch(); } Output: 26