Check the given number is even or odd

January 04, 2019

EVEN or ODD

Image result for EVEN OR ODD NUMBER quotes

c language code to check the number is even or odd:

#include<stdio.h>
#include<conio.h>
int main()
{int a;
printf("\nEnter any number: ");
scanf("%d",&a);
if(a%2==0)
{printf("\n%d is Even Number",a);
}
else
{printf("\n%d is Odd Number",a);
}
return 0;
}
---------------------------------------------------------------------------------------------
Output:
Enter any number:45
45 is Odd Number

Enter any number:80
80 is Even Number


Check the given number is even or odd Check the given number is even or odd Reviewed by Amit Waghmare on January 04, 2019 Rating: 5

C language code for Armstrong Number

January 04, 2019


 ARMSTRONG NUMBER

Image result for Armstrong number

                                     

 An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371. Also in the above image, we can see the example of Armstrong number.

C language code for Armstrong no:-

#include<stdio.h>
#include<conio.h>
void main()
{
int a,n,b=0,t;
clrscr();
printf("Enter the number\n");
scanf("%d",&n);
t=n;
while(n>0)
{
a=n%10;
n=n/10;
b=b+a*a;
}
if(b==t)
printf("armstorng no");
else
printf("not an armstrong");
getch();
return 0;
}

------------------------------------------------------------------------------------------------------------------
Output:
Enter the number:153
Armstrong no

Enter the number:435
not an armstrong



Image result for armstrong no quote



C language code for Armstrong Number C language code for Armstrong Number Reviewed by Amit Waghmare on January 04, 2019 Rating: 5

Print the pyramid using c language

December 10, 2018
USING C LANGUAGE PRINT THE PYRAMID







C language code to display the pattern:

#include<stdio.h>
#include<conio.h>
void main()
{
int noofrows,rows,col1,col2,noofcols;
clrscr();
printf ("Enter the number: ");
scanf ("%d",&noofrows);
noofcols=noofrows-1;
for(rows=1;rows<=noofrows;rows++)
       {
for(col1=1;col1<=noofcols;col1++)
       {
printf(" ");
       }
noofcols--;
for(col2=1;col2<=rows;col2++)
       {
printf (" *");
       }
printf ("\n");
       }
getch ();
}

--------------------------------------------------------------------------------------------------------------
Output:

Enter the number:5
                      *
                    *  *
                  *  *  *
                *  *  * *
             *  *  *  *  *



Print the pyramid using c language Print the pyramid using c language Reviewed by Amit Waghmare on December 10, 2018 Rating: 5

c language code to print fibonacci series

December 09, 2018

C LANGUAGE CODE TO PRINT FIBONACCI SERIES


Introduction
                 

                              Fibonacci series means if we are giving input as 7 then the output is 0  1  1  2  3  5.
Means in output first digit is 0 then second is 1,addition of first and second digit is third digit i.e.0+1=1,next is 1+1=2,then 2+1=3,then 3+2=5.
                    The next digit is 5+3=8 but 8 is greater than 7(8>7) i.e.(8!<7) so the control is transfer to the
out of the loop.The actual code is as follows:

code:

#include<stdio.h>
#include<conio.h>
void main()
{
int no,a=0,b=1,c=0;
clrscr();
printf("Enter the number to print fibonacci series:");
scanf("%d",&no);
while(no>c)
{
printf("%d  ",c);
c=a+b;
b=a;
a=c;
}
getch();
return 0;
}
------------------------------------------------------------------------------------------------------------
Output:
           Enter the number to print fibonacci series:7
           0  1  1  2  3  5
     


c language code to print fibonacci series c language code to print fibonacci series Reviewed by Amit Waghmare on December 09, 2018 Rating: 5