18 December 2023

C Program to Check Vowels Consonant Digits or Space

In this c program: You can run this program, enter a character, and it will tell you whether it’s a vowel, consonant, digit, or space. Program : #include<stdio.h> #include<conio.h> int main() { char str[100]; int i,vowels,consonants,digits,spaces; vowels=consonants=digits=spaces=0; printf(“Enter the String : “); fgets(str,99,stdin); for(i=0;str[i]!=’\0′;++i) { if(str[i] ==’a’ ||str[i]==’e’||str[i]==’i’||str[i]==’o’||str[i]==’u’||str[i]==’A’||str[i]==’E’||str[i]==’I’||str[i]==’O’||str[i]==’U’) {     printf(“\n %c is a Vowels.”,str[i]); vowels++; } else if((str[i]>=’a’&&str[i]<=’z’)||(str[i]>=’A’&&str[i]<=’Z’)) { printf(“\n %c is a Consonants.”,str[i]); consonants++; } else if(str[i]>=’0’&&str[i]<=’9′) { printf(“\n %c is a Digit.”,str[i]); digits++; } else if(str[i]==’ ‘||str[i]<=’\t’) { spaces++; } } printf(“\nNumber of Vowels : %d.”,vowels); printf(“\nNumber of Consonant : %d.”,consonants); printf(“\nNumber of Digits : %d.”,digits); printf(“\nNumber of White space & Tabs : %d.”,spaces); return 0; } Output :

C Program to Check Vowels Consonant Digits or Space Read More »

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 »

Shopping Basket
Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare
Verified by MonsterInsights
What do you like about this page?

0 / 400