forked from gouravthakur39/beginners-C-program-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// To calculate Area and Circumference of a circle | ||
|
||
#include<stdio.h> | ||
int main() | ||
{ | ||
float r, a ,c; | ||
printf("enter radius :\n"); | ||
scanf("%f", &r); | ||
a = 3.14*r*r; | ||
c = 2*3.14*r; | ||
printf("Area = %f\n circumference = %f\n",a,c); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// A simple arithmetic operation on two integers | ||
|
||
#include<stdio.h> | ||
int main() | ||
{ | ||
int n1,n2,a,s,m,d,md; | ||
printf("Enter two numbers :\n"); | ||
scanf("%d%d",&n1,&n2); | ||
a = n1+n2; | ||
s = n1-n2; | ||
m = n1*n2; | ||
d = n1/n2; | ||
md = n1%n2; | ||
printf("Addition of n1 and n2 : %d\n",a); | ||
printf("Subtraction of n1 and n2 : %d\n",s); | ||
printf("Multiplication of n1 and n2 : %d\n",m); | ||
printf("Division of n1 and n2 : %d\n",d); | ||
printf("Modulo of n1 and n2 : %d\n",md); | ||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Fahrenheit to celcius temp converter | ||
|
||
#include<stdio.h> | ||
int main() | ||
{ | ||
float c, f; | ||
printf("Enter temp in fahrenheit :\n"); | ||
scanf("%f", &f); | ||
c = (f-32)*5/9; | ||
printf("Temp in celcius is : %f",c); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Lowercase character to Uppercase conversion | ||
|
||
#include<stdio.h> | ||
int main () | ||
{ | ||
char ch; | ||
int no; | ||
printf("Enter a lowercase character :\n"); | ||
scanf("%c", &ch); | ||
no = ch-32; | ||
printf("Letter in capital : %c", no); | ||
return 0; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//Program to calculate simple interest | ||
|
||
|
||
#include<stdio.h> | ||
int main() | ||
{ | ||
float PrincipleAmount,Rate,Time, SimpleInterest; | ||
printf("Enter Principal Amount, Rate of interest and Time Respectively\n"); | ||
scanf("%f%f%f", &PrincipleAmount, &Rate, &Time); | ||
SimpleInterest = (PrincipleAmount * Rate * Time)/ 100; | ||
printf("Simple Interest is :%f",SimpleInterest); | ||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Evaluate total, average and percentage of a student | ||
|
||
#include<stdio.h> | ||
int main() | ||
{ | ||
int a,b,c,d,e; | ||
float total,average,percentage; | ||
printf("Enter marks of 5 subjects : \n"); | ||
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e); | ||
total = a+b+c+d+e; | ||
average = total/5; | ||
percentage = (total/500)*100; | ||
printf("Total marks = %f\n", total); | ||
printf("Average marks = %f\n",average ); | ||
printf("Net percentage = %f\n",percentage); | ||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Swap two integers using third variable | ||
|
||
|
||
#include<stdio.h> | ||
int main() | ||
{ | ||
int a,b,c; | ||
printf("Enter two no :\n"); | ||
scanf("%d%d",&a,&b); | ||
c=a; | ||
a=b; | ||
b=c; | ||
printf("After swapping value of a = %d\n b =%d",a,b); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Swap two integers without using third variable | ||
|
||
|
||
#include<stdio.h> | ||
int main() | ||
{ | ||
int a, b; | ||
printf("Enter two no :\n"); | ||
scanf("%d%d",&a,&b); | ||
a = a+b; | ||
b = a-b; | ||
a= a-b; | ||
printf("After swapping value of a and b : %d,%d",a,b); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Uppercase character to lowercase character | ||
|
||
|
||
#include<stdio.h> | ||
int main() | ||
{ | ||
char a,u; | ||
printf("Enter Uppercase letter :\n"); | ||
scanf("%c", &a); | ||
u = a + 32; | ||
printf("Lowercase is : %c", u); | ||
return 0; | ||
|
||
} |