Posts

Showing posts from June, 2017

WAP to find all factor of a number

C program to find all factors of a number Write a C program to enter any number from user and print all factors of the given number using for loop. How to find factors of any number in C programming. Logic to find all factors of a given number in C program. Example Input Input number: Output Factors of 12: 1, 2, 3, 4, 6, 12 Required knowledge Basic C programming ,   If else ,   For loop , Basic Mathematics What is factor? Factor of any number is a whole number which exactly divides any number into a whole number without leaving any remainder. For example: 2 is a factor of 6 because 2 divides 6 exactly leaving no remainder. Logic to find factors of any number As per definition checking divisibility is the most important task we will be doing here. You will check whether numbers from 1 to   num   are divisible by   num   or not. If divisible then it is a factor otherwise not. Read more about checking divisibility. ·   ...

WAP to convert Binary to Hexadecimal number system

C Program to Convert Binary Number to Hexadecimal Number System ·                      Write a   C program to convert binary number to hexadecimal number system. ·                      Wap in C to convert a base 2 number to a base 16 number. Required Knowledge ·                      C printf and scanf functions ·                      While loop in C ·                      For loop in C Binary number system   is a base 2 number system using digits 0 and 1 whereas ...

WAP to convert decimal to binary number system

Decimal to binary conversion in c programming language. C source code for decimal to binary conversion: #include<stdio.h> int main(){     long int decimalNumber,remainder,quotient;     int binaryNumber[100],i=1,j;     printf("Enter any decimal number: ");     scanf("%ld",&decimalNumber);     quotient = decimalNumber;     while(quotient!=0){          binaryNumber[i++]= quotient % 2;          quotient = quotient / 2;     }     printf("Equivalent binary value of decimal number %d: ",decimalNumber);     for(j = i -1 ;j> 0;j--)          printf("%d",binaryNumber[j]);     return 0; ...

WAP to convert Decimal to Octal number System

C program to Convert Decimal to Octal This C Program Converts the given Decimal to Octal. Octal is a numbering system that uses eight digits, 0 to 7, arranged in a series of columns to represent all numerical quantities. Each column or place value has a weighted value of 1, 8, 64, 512, and so on ranging from right to left. Decimal is a term that describes the base-10 number system commonly used by lay people in the developed world. Here is source code of the C program to Convert Decimal to Octal. The C program is successfully compiled and run on a Linux system. The program output is also shown below. 1. /* 2.  * C program to Convert Decimal to Octal 3.  */ 4. #include <stdio.h> 5.   6. int main () 7. { 8.      long decimalnum , remainder , quotient ; 9.      int octalNumber [100], i = 1, j ; 10.   11.      printf("Enter the decimal number: "); 12. ...