Posts

Operator in C

Operator in C  In C Programming language, operator are symbols that represent Operation to be perform on one or more operands. An operators specified an operation to be performed that yields a value. Here are some commonly used operator  in C : 1. Arithmetic Operators Arithmetic operators are used for numeric calculations. These  Operators are used to perform for mathematical/arithmetic operations on operands. They are of two types- a. Unary Arithmetic operators unary operators require only one operand. for example:     +x          -y here '-' changes the sign of the operand y. b. Binary Arithmetic operators Binary operators require two operands. There are five arithmetic operators- Operator Purpose + addition - subtraction * multiplication % Gives the remainder in integer division NOTE : %(modulus operator) cannot be applied w...

Input- Output in C

Input-Output in C There are three main functions of any program : it takes data as input,processes this data and gives output. The input operation involves movement of data from an input device(generally keyboard) to computer memory, while in output operation the data from computer memory to the output device (generally screen). The input output is performed through a set of library function that supplied with every C compiler. These functions are formally not a part of the language but they are considered standard for all input-output operation of C. There are several header files that are provide necessary information in support of the various library function. These header file are entered in the program using #include directive at the beginning of the program . #include <stdio.h> for standard input output. similarly there are other header files like math.h, string.h, stdlib.h that should be included when certain library function are used. In this article we discuss abou...

C++ file programs.

Write a function isprime() which takes a number and returns 1 if the number is prime and 0 otherwise.

Image
    What is a prime number in definition? A prime number is a whole number is greater than 1whose only factors are 1 and itself. A factors a whole number that can be  divided evenly into another number. The first few prime number are : 2, 3, 5, 7, 11, 13, 17, 19 and  23  etc.  The following program check the input number is prime or not. #include <stdio.h> int isprime( int ); int main() {     int num;     printf( "Enter the Number check it is prime or not :" );     scanf( "%d" ,&num);     if (isprime(num))     {         printf( "%d is prime number.\n" , num);     }     else     {         printf( "%d is not a prime number.           \n" ,num);     }     return 0 ; } int isprime( int n) {     int i = 2 ;     while (i<n)     { ...

Program of Palindrome number.

Image
  What is Palindrome number  ? A palindrome  number is a number  that remains same when digits are reversed. For example, the number 1551 is a palindrome number, but 1541 is not a palindrome number.  * note : Negative number can not be palindrome. Now here we understand the following program is palindrome or not. #include <stdio.h> int reverse( int ); int palindrome( int ); int main() {     int num;     printf( "Enter the number check it isPalindrome or not : " );     scanf( "%d" ,&num);     if (palindrome(num)) // 1 for true or 0 for false     {         printf( "%d is palindrome.\n" ,num);     }     else     {         printf( "%d is not palindrome." ,num);     }     return 0 ; } int palindrome( int n) {     if (n==reverse(n)) // if reverse and the number is equal then it isPalindrome...

program to convert a binary number to a decimal number.

Program to convert a binary to decimal number. #include <stdio.h> int main() {     int n, sn, i = 1 , dec = 0 , rem;     printf( "Enter a binary number:\t" );     scanf( "%d" , &n);     sn = n;     while (n > 0 ) /* work when number is greater than 0.*/     {         rem = n % 10 ; // reminder is 0 or 1 only         if (rem == 1 || rem == 0 ) //binary number         {             dec = dec + rem * i;             i *= 2 ; // power of 2's.             n = n / 10 ;         }     }     printf( "Decimal Equivalent of %d is %d " , sn, dec);     return 0 ; } Output : Enter a binary number: 1101 Decimal Equivalent of 1101 is 13 for this we extract binary digits from right and add them after multiplying power of ...

Write a program that accepts marks in five subjects and calculates the total percentage marks.

program find out the percentage of a student. In this program we have take marks of student out off  100 where marks in real form then be use float type variable declare 5 variable m1,m2,m3,m4,m5 float type. Now we find out the percentage of a student in five subjects. take a variable store the value of %age as float type. firstly, find sum of marks gain by the student, then after % = (sum/500)*100 we can also write sum/5 ; #include <stdio.h> int main() {     float m1,m2,m3,m4,m5,per,sum;     printf( "Marks in English:" );     scanf( "%f" ,&m1);     printf( "Marks in Hindi:" );     scanf( "%f" ,&m2);     printf( "Marks in Physics:" );     scanf( "%f" ,&m3);     printf( "Marks in Maths:" );     scanf( "%f" ,&m4);     printf( "Marks in Chemistry:" );     scanf( "%f" ,&m5);     sum=m1+m2+m3+m4+m5;     per=sum/ 5 ;     p...