C Programming

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 »

C Program to Check the ID and Password is Correct

Certainly! Below is a simple C program that checks whether a given ID and password are correct. In this example, the correct ID is “6789” and the correct password is “1234”. The program prompts the user to enter an ID and a password, compares them with the correct values, and then prints a message indicating whether the login is successful or not. Program : #include<stdio.h>#include<conio.h>main(){int id,pass;printf(“Enter ID : “);scanf(“%d”,&id);printf(“Enter Password : “);scanf(“%d”,&pass);//Here ID is 6789 & Password is 1234.switch(id){case 6789:switch(pass){case 1234:printf(“Login Success ! \n Correct ID & Password”);break;default: printf(“Wrong Password!”);}break;default:printf(“Wrong ID.”);}} Output :

C Program to Check the ID and Password is Correct Read More »

C Program to Check the Number is Prime Number or Not

To determine whether a number is prime or not in a C program, you can use a simple algorithm that checks for divisibility. A prime number is a natural number greater than 1 that is not a product of two smaller natural numbers other than 1 and itself. Here’s a basic C program to check if a given number is prime or not: Program : #include<stdio.h>#include<conio.h>main(){int i,p,c=0;printf(“Enter the Number : “);scanf(“%d”,&p);for(i=1;i<=p;i++){if(p%i==0){c++;}}if(c==2){printf(“%d is a Prime Number.”,p);}else{printf(“%d is not a Prime Number.”,p);}return 0;} Output :

C Program to Check the Number is Prime Number or Not Read More »

C Program to Check a number is Even or Odd

In C programming, you can determine whether a number is odd or even using the modulo operator (%). The modulo operator calculates the remainder when one number is divided by another. If the remainder is 0, the number is even; otherwise, it’s odd. Here’s a simple example of a C program that checks whether a given number is odd or even: I Program : #include<stdio.h>#include<conio.h>main(){int a;printf(“Enter the Number : “);scanf(“%d”,&a);if(a==0){printf(“You enter zero,enter different number.”);}else if((a%2)==0){printf(“%d is a Even Number.”,a);}else {printf(“%d is a Odd Number.”,a);}} Output :

C Program to Check a number is Even or Odd 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