Skip to content

Commit a666b34

Browse files
Initial programs
Source code for initial c programs
1 parent 3677ddc commit a666b34

9 files changed

+137
-0
lines changed

AreaAndCircumference.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// To calculate Area and Circumference of a circle
2+
3+
#include<stdio.h>
4+
int main()
5+
{
6+
float r, a ,c;
7+
printf("enter radius :\n");
8+
scanf("%f", &r);
9+
a = 3.14*r*r;
10+
c = 2*3.14*r;
11+
printf("Area = %f\n circumference = %f\n",a,c);
12+
return 0;
13+
}

BasicArithmatic.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// A simple arithmetic operation on two integers
2+
3+
#include<stdio.h>
4+
int main()
5+
{
6+
int n1,n2,a,s,m,d,md;
7+
printf("Enter two numbers :\n");
8+
scanf("%d%d",&n1,&n2);
9+
a = n1+n2;
10+
s = n1-n2;
11+
m = n1*n2;
12+
d = n1/n2;
13+
md = n1%n2;
14+
printf("Addition of n1 and n2 : %d\n",a);
15+
printf("Subtraction of n1 and n2 : %d\n",s);
16+
printf("Multiplication of n1 and n2 : %d\n",m);
17+
printf("Division of n1 and n2 : %d\n",d);
18+
printf("Modulo of n1 and n2 : %d\n",md);
19+
return 0;
20+
21+
}

FahrenheitToCelciusConv.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Fahrenheit to celcius temp converter
2+
3+
#include<stdio.h>
4+
int main()
5+
{
6+
float c, f;
7+
printf("Enter temp in fahrenheit :\n");
8+
scanf("%f", &f);
9+
c = (f-32)*5/9;
10+
printf("Temp in celcius is : %f",c);
11+
12+
}

LowercaseToUppercase.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Lowercase character to Uppercase conversion
2+
3+
#include<stdio.h>
4+
int main ()
5+
{
6+
char ch;
7+
int no;
8+
printf("Enter a lowercase character :\n");
9+
scanf("%c", &ch);
10+
no = ch-32;
11+
printf("Letter in capital : %c", no);
12+
return 0;
13+
14+
15+
}

SimpleInterestCalculator.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//Program to calculate simple interest
2+
3+
4+
#include<stdio.h>
5+
int main()
6+
{
7+
float PrincipleAmount,Rate,Time, SimpleInterest;
8+
printf("Enter Principal Amount, Rate of interest and Time Respectively\n");
9+
scanf("%f%f%f", &PrincipleAmount, &Rate, &Time);
10+
SimpleInterest = (PrincipleAmount * Rate * Time)/ 100;
11+
printf("Simple Interest is :%f",SimpleInterest);
12+
return 0;
13+
14+
}

StudentMarksPercentage.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Evaluate total, average and percentage of a student
2+
3+
#include<stdio.h>
4+
int main()
5+
{
6+
int a,b,c,d,e;
7+
float total,average,percentage;
8+
printf("Enter marks of 5 subjects : \n");
9+
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
10+
total = a+b+c+d+e;
11+
average = total/5;
12+
percentage = (total/500)*100;
13+
printf("Total marks = %f\n", total);
14+
printf("Average marks = %f\n",average );
15+
printf("Net percentage = %f\n",percentage);
16+
return 0;
17+
18+
}

SwapValueUsingThirdVariable.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Swap two integers using third variable
2+
3+
4+
#include<stdio.h>
5+
int main()
6+
{
7+
int a,b,c;
8+
printf("Enter two no :\n");
9+
scanf("%d%d",&a,&b);
10+
c=a;
11+
a=b;
12+
b=c;
13+
printf("After swapping value of a = %d\n b =%d",a,b);
14+
return 0;
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Swap two integers without using third variable
2+
3+
4+
#include<stdio.h>
5+
int main()
6+
{
7+
int a, b;
8+
printf("Enter two no :\n");
9+
scanf("%d%d",&a,&b);
10+
a = a+b;
11+
b = a-b;
12+
a= a-b;
13+
printf("After swapping value of a and b : %d,%d",a,b);
14+
return 0;
15+
}

UppercaseToLowercase.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Uppercase character to lowercase character
2+
3+
4+
#include<stdio.h>
5+
int main()
6+
{
7+
char a,u;
8+
printf("Enter Uppercase letter :\n");
9+
scanf("%c", &a);
10+
u = a + 32;
11+
printf("Lowercase is : %c", u);
12+
return 0;
13+
14+
}

0 commit comments

Comments
 (0)