Skip to main content

Posts

Showing posts from June, 2021

C Program to find out the biggest of three numbers using Nested if Statement.

 C Program to find out the biggest of three numbers using Nested if Statement. In this example we will learn how to find the biggest of three numbers using Nested if statement. LOGIC OF THE BIGGEST OF THREE NUMBERS: At first we have declared three variables a,b and c and we have stored the numbers inputted by the user in this three variables. Then we have to check if the value of a greater than b then it will check if a greater than c if it is greater then it will print the value of a is the biggest of the three numbers and if it is not greater than it will print c is the biggest of three numbers. If the value of a not greater than b then it will not execute the above statements  Then it will move to the second statement that is else if and will check if b greater than a if it is true then it will check if b greater than c if it is true it will print the value of b is the biggest of the three numbers if not then it will print the value of c is the biggest of three numbers.    PROGRAM:

C Program to Check whether a given number is Perfect or Not

 C Program to Check whether a given number is Perfect or Not. In this exmaple we will learn to check a given number is a Perfect Number or not.  LOGIC OF PERFECT SQUARE NUMBER: At first we have declared variables i , num , sum=0 (value is initialized to zero).  Then we have inputted the number from the user and stored in num. After that we have to to add a loop i=1 till num/2 and to increment the iteration by 1. You all must be thinking why we have to run the loop till n um/2 because a number does not have any positive integer greater than the half of the number that is num/2 . Then we have to check whether the remainder of num%i is equal to zero or not. If it is equal then the value of i is a proper divisor of the number entered by the user and it is added to sum. Now we have to check if the sum of the proper divisors of the number equal to the original number. If it is equal then the number entered by the user is a perfect number otherwise it is not a perfect number. PROGRAM O

C program to display ASCII value of a character

 C program to display ASCII value of a character         In this example we will learn how to display the ASCII value of any character entered  by the user through keyboard. To solve this program we must have knowledge about ASCII . PROGRAM #include <stdio.h> int   main () {      char  c;      printf ( "Enter a character : " );      scanf ( "%c" ,&c);      printf ( "ASCII value of %c =%d" ,c,c);      return   0 ; } OUTPUT: ASCII:          ASCII Stands for American Standard Code for Information Interchange. It is widely used in computers of all types. It is used to create a standard for character-sets used in electronic components. ASCII codes are of two types - ASCII-7 and ASCII-8.  ASCII-7: It is a 7 bit standard ASCII code. In ASCII-7 the first 3 bits are zone bits and the next 4 bits are for the digits. ASCII-7 represents 128 unique symbols. ASCII-8: It is an extended version of ASCII-7. ASCII-8 is an 8 bit code having 4 bits for zone and 4

C program to convert a given temperature value from Fahrenheit to Centigrade and vice versa?

  Write a C program to convert a given temperature value from Fahrenheit to Centigrade and vice versa?          In this example we will learn how to convert a given temperature in Fahrenheit to Centigrade and to convert given  temperature value from Centigrade to Fahrenheit depending on the choice of the user.                To solve this program we should have basic knowledge in c and most importantly a clear concept on : Switch Statement             And we must know the formula of conversion from Fahrenheit to Centigrade(Celsius) and Centigrade(Celsius) to Fahrenheit. Fahrenheit To Centigrade Centigrade To Fahrenheit PROGRAM       #include <stdio.h> #include <conio.h> void   main () {      float   f , c ;      int   ch ;      printf ( "CONVERT" );      printf ( " \n 1. Fahrenheit to Celsius." );      printf ( " \n 2. Celsius to Fahrenheit \n " );      printf ( " \n Enter your choice (1|2):" );      sca