Skip to content

Commit

Permalink
Initial programs
Browse files Browse the repository at this point in the history
Source code for initial c programs
  • Loading branch information
gouravthakur39 authored Sep 25, 2018
1 parent 3677ddc commit a666b34
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 0 deletions.
13 changes: 13 additions & 0 deletions AreaAndCircumference.c
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;
}
21 changes: 21 additions & 0 deletions BasicArithmatic.c
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;

}
12 changes: 12 additions & 0 deletions FahrenheitToCelciusConv.c
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);

}
15 changes: 15 additions & 0 deletions LowercaseToUppercase.c
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;


}
14 changes: 14 additions & 0 deletions SimpleInterestCalculator.c
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;

}
18 changes: 18 additions & 0 deletions StudentMarksPercentage.c
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;

}
15 changes: 15 additions & 0 deletions SwapValueUsingThirdVariable.c
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;
}
15 changes: 15 additions & 0 deletions SwapValueWithoutUsingThirdVariable.c
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;
}
14 changes: 14 additions & 0 deletions UppercaseToLowercase.c
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;

}

0 comments on commit a666b34

Please sign in to comment.