Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions 1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 1+3^3/3!+5^5/5!

#include <stdio.h>

int main(){
int num,i,factorial=1,power=1,j,n;
float sum=0;

printf("Enter a number of the sum: ");
scanf("%d",&num);

for(i=1;i<=2*num;i++){
//Since we have to get numeritor
//not affected by the previous calculation so pro =1
if(i %2 ==0){
continue;
}
else{
power=1;
factorial=1;
//incase of factorial is get affected since the
//facotial of number has not so facotial = 1 been used by previous calculation
for(j=1;j<=i;j++){
factorial =factorial*j;
power=power*i;
}
}

sum=sum+(power*1.0/factorial);
printf("%f\n",sum);
}

printf("the sum is: %f",sum);
return 0;
}
31 changes: 31 additions & 0 deletions 12.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


//1/1!+2^2/2!+3^3/3!.....nth term.


#include <stdio.h>

int main(){
int num,i,factorial=1,power=1,j;
float sum=0;

printf("Enter a number of the sum: ");
scanf("%d",&num);

for(i=1;i<=num;i++){
//Since we have to get numeritor
//not affected by the previous calculation so pro =1
power=1;
//incase of factorial it does not get affected since the
//facotial of number has been used by previous calculation
factorial =factorial*i;
for(j=1;j<=i;j++){
power=power*i;
}
sum=sum+(power*1.0/factorial);
printf("%f\n",sum);
}
printf("the sum is: %f",sum);
return 0;
}

23 changes: 23 additions & 0 deletions TOH.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//wAP for table of hanoi.

#include <stdio.h>

int TOH(int, int, int, int);

int main(){
int n,A=1,B=2,C=3;
printf("Enter a number of disc: ");

scanf("%d",&n);
TOH(n, A,B,C);
}

int TOH(int n,int A,int B,int C){

if(n > 0){
TOH (n-1,A,C,B);
printf("move a disk %d to %d\n",A,C);
TOH(n-1,B,A,C);
}
}

20 changes: 20 additions & 0 deletions Untitled1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <stdio.h>
#include <conio.h>

int main(){
int num1,num2;
do{
printf("Enter a first number: ");
scanf("%d",&num1);
printf("Enter a secound number: ");
scanf("%d",&num2);
}
while(num1 >num2);

for(num1;num1<=num2;num1++){
if(num1 % 5 == 0){
printf("%d is divisible by 5 \n",num1);
}
}
return 0;
}
25 changes: 25 additions & 0 deletions Untitled2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//1/1!+2^2/2!+3^3/3!.....nth term.


#include <stdio.h>

int main(){
int num,i,factorial=1,power=1,j;
float sum=0;

printf("Enter a number of the sum: ");
scanf("%d",&num);

for(i=1;i<=num;i++){
power=1;
for(j=1;j<=i;j++)
factorial =factorial*i;
power=power*i;

}
sum=sum+(power*1.0/factorial);
printf("%f\n",sum);
}
printf("the sum is: %f",sum);
return 0;
}
24 changes: 24 additions & 0 deletions Untitled3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>
#include <conio.h>

int main(){
int num,i,count=0;

printf("Enter a number: ");
scanf("%d",&num);

for(num;num>=1;num--){
count = 0;
for(i=1;i<=num;i++){
if(num % i == 0)
{
count++;
}
}
if(count == 2)
{
printf("\n %d is prime number",num);
}
}
return 0;
}
28 changes: 28 additions & 0 deletions fun10_SalaryRealated.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* WAP to input salary of a person and claculate travel allowence (10% of salary)
daily allowencce (12% of alsary) tax(15% of salary) also
calculate net salary of person */

#include <stdio.h>

int net_salary(int);

//Name: Sumit Ojha

int main() {
int salary;

printf("Enter the salary of the person: ");
scanf("%d",& salary);

printf("the net salary is : %d\n", net_salary(salary));
return 0;
}


int net_salary(int i){
int tra, dai, tax;
tra = 10.0/100*i;
dai = 12.0/100*i;
tax = 15.0/100*i;
return (dai+tra-tax);
}
22 changes: 22 additions & 0 deletions fun11_to_find_odd_n_even.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//WAP to find the odd and even number using conditions.

#include <stdio.h>

int num (int);
int main() {
int n;
printf("Enter a num: ");
scanf("%d",&n);
num(n);
return 0;
}

int num (int i){
if (i % 2 == 0){
printf("its even: %d", i);
}
else{
printf("its odd: %d", i);
}
return num;
}
26 changes: 26 additions & 0 deletions fun12_incrementdecrement.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//WAP to display the value of a and b or each Line
//a = ++ + ++a
//b = a-- - --a

#include <stdio.h>

// Name: Sumit Ojha

int first(int);
int second(int,int);

int main() {
int a = 10 , b = 5;

printf("++ + ++a = %d\n", first(a));
printf("a-- - --b = %d\n", second(a,b));
return 0;
}

int first (int i){
return (i = + i + ++i);
}

int second(int i, int j) {
return (j = i-- - --j);
}
39 changes: 39 additions & 0 deletions fun13_conv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*WAP to input height in feet and inch, weight in kg,
convert height into inches and again convert into meters, now divide your weight by
square of your height in meters and finally assign o/p to variable constant factors
*/

#include <stdio.h>

float inches (float, float);
float meter (float, float);
float ratio (float, float, float);

int main() {
float feet1, inches1, weight1, meter1, ratio1;

printf("Enter the height in feet, inches and weight: ");
scanf("%f %f %f",&feet1, &inches1,&weight1);

inches1 = inches (inches1, feet1);
printf("the height in inches is: %f \n", inches1);

meter1=meter(meter1, inches1);
printf("the inches in meter is: %f \n", meter1);

ratio1=ratio(ratio1, weight1, meter1);
printf("the value of div of your weight sqr of height: %f \n", ratio1);
return 0;
}

float inches (float i, float j){
return (i = i+(j*12));
}

float meter(float i, float j){
return (i = 0.254*j);
}

float ratio (float i ,float j , float k){
return (i = j/(k*k));
}
30 changes: 30 additions & 0 deletions fun14_temp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*WAP to read the tempr in farenheight and disply the message as follows nice day: temp >60 and and temp <80 , cold day: temp <=60 and hot day: tempr>=80. */

#include <stdio.h>

int tep(int);

//Name: Sumit Ojha.

int main(){
float temp;

printf("Enter temp: ");
scanf("%f",&temp);
tep(temp);

return 0;
}

int tep(int i){
if (i > 60 && i < 80){
printf("it's a nice day.");
}
else if(i <= 60){
printf("it's a cold day.");
}
else if (i >=80){
printf("it's a hot day.");
}
return tep;
}
54 changes: 54 additions & 0 deletions fun15_raterealted.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*An organization is dealing in two items say a and b provide the comission on the scale of there according to the following polocy.
commission rate for is 6% up to scale is 2000 if the scale of these according to following policy*/

#include <stdio.h>

float product(float, float);

// Name: Sumit Ojnd

int main(){
int a,b;
product(a,b);
return 0;
}

float product(float i, float j){
char product;
float com_i_1, com_j_1, com_i_2, com_j_2;

printf("Enter the product name: ");
scanf("%c",&product);

if (product=='a'){
printf ("enter the price of a: ");
scanf("%f",&i);

if (i <= 2000){
com_i_1 = 6.0/100*i;
printf("the comission on a is: %.2f",com_i_1);
}

else if (i > 2000){
com_i_2 =(2000*6.0/100)+(i-2000)*7.0/100;
printf("the comission on a is: %.2f \n", com_i_2);
}
}

else if (product=='b'){
printf ("enter the price of b: ");
scanf("%f",&j);

if (j <= 4000)
{
com_j_1 = 10.0/100*j;
printf("the comission on b is: %.2f",com_j_1);
}
else if(j < 4000)
{
com_j_2 = (4000*10.0/100)+(j-2000)*12.0/100;
printf("the comission on b is: %.2f \n", com_j_2);
}
}
return product;
}
25 changes: 25 additions & 0 deletions fun16_factorial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//WAP to do the factorail of the given number:


#include <stdio.h>
int factorial(int);

int main(){
int n;

printf("Enter a number: ");
scanf("%d",&n);

printf("the facorial of nis : %d", factorial(n));
return 0;
}

int factorial(int a){
int fact;

if(a==1){
return a;
}
fact = a*factorial(a-1);
return fact;
}
Loading