wisdomatrix.com

Avatar

C program to Find the Areas of Geometrical Shapes

This program allows the user to choose between a rectangle, circle, and triangle. It then prompts the user for the required parameters (length and width for a rectangle, radius for a circle, and base and height for a triangle) and calculates and prints the area based on the chosen shape. The ‘switch’ statement is used to handle the different cases for each shape.

C program to Find the Areas of Geometrical Shapes Read More »

C Program to Convert Fahrenheit to Celsius and Vice-Versa

In this c program: You can run this program, enter a temperature in Fahrenheit, and it will display the equivalent temperature in Celsius. Fahrenheit to Celsius : #include<stdio.h>#include<conio.h>int main(){float f,c;printf(“Enter The Fahrenheit Value : “);scanf(“%f”,&f);c=(f-32)*5/9; printf(“Celsius Value : %0.3f”,c);} Output : To convert Celsius to Fahrenheit in a C program, you can use the formula: F=9/5×C + 32 Here’s an example C program that takes a temperature in Celsius as input and converts it to Fahrenheit Celsius to Fahrenheit : #include<stdio.h>#include<conio.h>int main(){float f,c;printf(“Enter The Celsius Value : “);scanf(“%f”,&c);f=(c*9/5)+32; printf(“Fahrenheit Value : %0.3f”,f);} Output :

C Program to Convert Fahrenheit to Celsius and Vice-Versa Read More »

C program to Employee Salary Calculation

Below is a simple example of a C program for employee salary calculation. This program takes basic salary as input and calculates the gross salary by adding allowances and deducting taxes. In this program: Note: This is a simple example, and in a real-world scenario, you might need to consider more factors such as other allowances, deductions, and applicable tax rules. Program : #include<stdio.h>#include<conio.h>int main(){float a,da,hra,ta,ma,gross,pf,sal;printf(“Enter Basic Pay : “);scanf(“%f”,&a);da=(a*18)/100;printf(“\nDearness Allowance(DA) is : %0.2f”,da);ta=(a*15)/100;printf(“\nTravel Allowance(TA) is : %0.2f”,ta);hra=(a*10)/100;printf(“\nHouse Rent Allowance(HRA) is : %0.2f”,hra);ma=(a*15)/100;printf(“\nMedical Allowance(MA) is : %0.2f”,ma);gross=a+da+ta+hra+ma;printf(“\nGross salary : %0.2f”,gross);pf=(gross*13)/100;printf(“\nProvident Fund(Pf) is : %0.2f”,pf);sal=gross-pf;printf(“\nNet Salary is : %0.2f”,sal);} Output :

C program to Employee Salary Calculation Read More »

C Program to Sum of First N natural Number

This c program prompts the user to enter the value of n, then it calculates the sum of the first N natural numbers using a for loop, and finally, it prints the result. You can run this program, enter a value for N, and it will display the sum of the first N natural numbers. Program : #include<stdio.h>#include<conio.h>main(){int n,sum,i;i=1;sum=0;printf(“Enter How many numbers do you want to add up to : “);scanf(“%d”,&n);while(i<=n){sum=sum+i;i=i+1;}printf(“%d is the Sum of first %d numbers.”,sum,n);} Output :

C Program to Sum of First N natural Number Read More »

C Program to find the Biggest of Five Numbers

Below is an example of a C program that finds the largest among five numbers. The program compares each number with the current maximum and updates the maximum whenever a larger number is encountered. Method 1 : #include<stdio.h>#include<conio.h>main(){int a,b,c,d,e;printf(“Enter First the Number : “);scanf(“%d”,&a);printf(“Enter Second the Number : “);scanf(“%d”,&b);printf(“Enter Third the Number : “);scanf(“%d”,&c);printf(“Enter Foruth the Number : “);scanf(“%d”,&d);printf(“Enter Fifth the Number : “);scanf(“%d”,&e);if((a>b)&&(a>c)&&(a>d)&&(a>e)){printf(“%d is the Biggest Number.”,a);}else if((b>a)&&(b>c)&&(b>d)&&(b>e)){printf(“%d is the Biggest Number.”,b);}else if((c>a)&&(c>b)&&(c>d)&&(c>e)){printf(“%d is the Biggest Number.”,c);}else if((d>a)&&(d>b)&&(d>c)&&(d>e)){printf(“%d is the Biggest Number.”,d);}else{printf(“%d is the Biggest Number.”,e);}} Output : Method 2 : #include<stdio.h>#include<conio.h>main(){int a,b,c,d,e,max;printf(“Enter First the Number : “);scanf(“%d”,&a);printf(“Enter Second the Number : “);scanf(“%d”,&b);printf(“Enter Third the Number : “);scanf(“%d”,&c);printf(“Enter Fourth the Number : “);scanf(“%d”,&d);printf(“Enter Fifth the Number : “);scanf(“%d”,&e);if(a>b)max=a;elsemax=b;if(c>max)max=c;if(d>max)max=d;if(e>max)max=e;printf(“Biggest Number is : %d”,max);} Output :

C Program to find the Biggest of Five Numbers Read More »

C Program to find the Biggest of Three Numbers

This c program prompts the user to enter three numbers, reads them using scanf, and then uses a series of if and else if statements to determine and print the largest number among the three. Program : #include<stdio.h>#include<conio.h>main(){int a,b,c;printf(“Enter First the Number : “);scanf(“%d”,&a);printf(“Enter Second the Number : “);scanf(“%d”,&b);printf(“Enter Third the Number : “);scanf(“%d”,&c);if((a>b)&&(a>c)){printf(“%d is the Biggest Number.”,a);}else if((b>a)&&(b>c)){printf(“%d is the Biggest Number.”,b);}else{printf(“%d is the Biggest Number.”,c);}} Output :

C Program to find the Biggest of Three Numbers Read More »

C Program to Swap Two Numbers without Third Variable

In C programming, you can swap the values of two variables without using a third variable by using arithmetic operations. The key idea is to use addition and subtraction (or multiplication and division) to perform the swap. Here’s an example: Program : #include<stdio.h>#include<conio.h>main(){int a,b;printf(“Enter the First Number : “);scanf(“%d”,&a);printf(“Enter the Second Number : “);scanf(“%d”,&b);a=a+b;b=a-b;a=a-b;printf(“\nAfter Swapping…\nFirst Number : %d”,a);printf(“\nSecond Number : %d”,b);} Output :

C Program to Swap Two Numbers without Third Variable Read More »

Write a Program in C to Cycle Swapping

Sure, swapping three numbers involves exchanging the values of three variables. The basic idea is to use a temporary variable to hold the value of one of the variables while you perform the swaps. Here’s a simple C program that demonstrates swapping between three numbers: Program : #include<stdio.h>#include<conio.h>main(){int a,b,c,temp;printf(“Enter the First Number : “);scanf(“%d”,&a);printf(“Enter the Second Number : “);scanf(“%d”,&b);printf(“Enter the Third Number : “);scanf(“%d”,&c);temp=a;a=b;b=c;c=temp;printf(“nAfter Swapping…nFirst Number : %d”,a);printf(“nSecond Number : %d”,b);printf(“nTrird Number : %d”,c);} Output :

Write a Program in C to Cycle Swapping Read More »

C Program to Swapping Between Three Numbers

Sure, swapping three numbers involves exchanging the values of three variables. The basic idea is to use a temporary variable to hold the value of one of the variables while you perform the swaps. Here’s a simple C program that demonstrates swapping between three numbers: Program : #include<stdio.h>#include<conio.h>main(){int a,b,c,temp;printf(“Enter the First Number : “);scanf(“%d”,&a);printf(“Enter the Second Number : “);scanf(“%d”,&b);printf(“Enter the Third Number : “);scanf(“%d”,&c);temp=a;a=b;b=c;c=temp;printf(“\nAfter Swapping…\nFirst Number : %d”,a);printf(“\nSecond Number : %d”,b);printf(“\nTrird Number : %d”,c);} Output :

C Program to Swapping Between Three Numbers Read More »

Shopping Basket
Verified by MonsterInsights