DO NOT MISS

Ads

Sunday 31 July 2016

Cell Styles in Ms-Excel


Conditional Formatting In Ms-Excel


Program 18 Using While Loop



The sum of the digits of the qubes is equal to the given number is known as a Armstrong number.


Example:- (153,371,407)


#include<stdio.h> 
#include<conio.h> 

void main() 

      { 

           int n,sum=0,r,t=0; 
           clrscr(); 

           printf("enter a number:"); 
           scanf("%d",&n); 

           t=n; 
           while(n!=0) 
                 { 
                      r=n%10; 
                      sum=sum+r*r*r; 
                      n=n/10; 
                 } 


           if(sum==t) 
           printf("the no is armstrang"); 
           else 
           printf("the no is not armstrang"); 

           getch(); 

      }


Output:-



Explanation:
______________________________________________________
______________________________________________________
______________________________________________________
_____________________________________________________



Program 17 Using While Loop


#include<stdio.h>
#include<conio.h>

void main()

     {

           int n,sum=0,r;
           clrscr();

           printf("enter a number:");
           scanf("%d",&n);

     
     while(n!=0)
                    {
                          r=n%10;
                          sum=sum+r;
                          n=n/10;
                     }

            printf("the sum of the digits of the given no. is:=%d",sum);

            getch();

       }

Output:-


Explanation:
enter the number:34=3 + 4 =7
enter the number:59=5 + 9=14

______________________________________________________
______________________________________________________
______________________________________________________
_____________________________________________________

Program 16 Using While loop


#include<stdio.h>
#include<conio.h>

void main()

       {

            int a,i,sum=0;
            clrscr();

            printf("enter a range:");
            scanf("%d",&a);

            i=1;
           
while(i<=a)
                     {
                          sum=sum+i*i*i;
                          i++;
                     }

            printf("the sum of the Qube natural no is:=%d\n",sum);

            getch();

      }

Output:-

Explanation:-
The Number is :3 (1 + 2 + 3 )
Qube of (1*1*1+2*2*2+3*3*3) = 1 + 8 + 27  =36.
______________________________________________________
______________________________________________________
______________________________________________________

_____________________________________________________



Program 15 Using While loop


#include<stdio.h>
#include<conio.h>

void main()

       {

             int a,i,sum=0;
             clrscr();

             printf("enter a range:");
             scanf("%d",&a);

             i=1;
           
 while(i<=a)
                         {
                                sum=sum+i*i;
                                i++;
                         }

             printf("the sum of the Squre natural no is:=%d\n",sum);

             getch();

        }

Output:-


Explanation:-
The Number is :4 (1 + 2 + 3 + 4)
 Square of (1*1+2*2+3*3+4*4) = 1 +++ 16 =30.
______________________________________________________
______________________________________________________
______________________________________________________
_____________________________________________________



Program 14 Using While loop


The positive numbers 1, 2, 3, 4... are known as natural numbers. The programs below takes a positive integer as an input from the user and calculates the sum up to n.

#include<stdio.h>
#include<conio.h>

void main()

       {

               int a,i,sum=0;
               clrscr();

               printf("enter a range:");
               scanf("%d",&a);

               i=1;
             
 while(i<=a)

                    {

                       sum=sum+i;
                       i++;

                    }

              printf("the sum of the natural no is:=%d\n",sum);

              getch();

       }


Output:-


Explanation:
enter the number:3=1+2+3 =6
enter the number:5=1+2+3+4+5=15
______________________________________________________
______________________________________________________
______________________________________________________
_____________________________________________________

Program 13 Using While loop



The sum of the factors of the given no. is equal to the twice of the given no. then the number is called Perfect no.

Ex:- 
Number 6 is Perfect Number
Number 6 Factors =1,2,3,6
1*6=6
2*3=6
3*2=6
6*1=6
1+2+3+6=12 (6+6)


#include<stdio.h> 
#include<conio.h> 

void main() 

       { 

              int n,i,sum=0; 
              clrscr(); 

              printf("enter a number:"); 
              scanf("%d",&n); 

              i=1; 
              while(i<=n)

                       { 

                            if(n%i==0) 
                            sum=sum+i; 
                            i++; 

                       } 

             if(sum==n*2) 
             printf("the number is perfect number\n"); 
             else 
             printf("the number is not perfect number"); 

             getch(); 

     }


Output:-

______________________________________________________
______________________________________________________
______________________________________________________
_____________________________________________________




Program 12 Using While loop



The number which has only two factors then the number is called as a Prime number.
(or)
A prime number is a whole number greater than 1, whose only two whole-number factors are 1 and itself. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29.

#include<stdio.h>
#include<conio.h>

void main()

       {

               int n,i,fc=0;
               clrscr();

               printf("enter a number:");
               scanf("%d",&n);

               i=1;
               
while(i<=n)
                      {
                           if(n%i==0)
                           fc++;
                           i++;
                      }

              if(fc==2)
              printf("the number is prime number:");
              else
              printf("the number is not prime number:");
              getch();

      }


Output:-


______________________________________________________
______________________________________________________
______________________________________________________
_____________________________________________________


Program 11 Using While loop


#include<stdio.h>
#include<conio.h>

void main()

       {

           int n,i,;
           clrscr();

           printf("enter a number:");
           scanf("%d",&n);

           i=1;
           printf(“Factors of the given no is:\n”);
               
while(i<=n)

                  {
                       if(n%i==0)
                       printf(“%d\n”,n);
                       i++;

                 }

           getch();

      }

Output:-
______________________________________________________
______________________________________________________
______________________________________________________
_____________________________________________________


Program 10 Using While loop


#include<stdio.h>
#include<conio.h>

void main()

      {

              int i,ec=0,oc=0,r1,r2;
              clrscr();

              printf("enter a r1 value:");
              scanf("%d",&r1);

              printf("enter a r2 value:");
              scanf("%d",&r2);

              i=r1;

             
while(i<=r2)

                   {

                           if(i%2==0)
                           ec++;
                           else
                           oc++;
                           i++;

                   }

              printf("the no. of even no's is:=%d\n",ec);
              printf("the no. of odd no's is:=%d",oc);

              getch();

      }

Output:-

______________________________________________________
______________________________________________________
______________________________________________________
_____________________________________________________

Program 9 Using While loop


#include<stdio.h> 
#include<conio.h> 

void main()

       {

            int a,b,i;
            clrscr();

            printf("enter starting year:");
            scanf("%d",&a); 

            printf("enter ending year:");
            scanf("%d",&b); 


            i=a;
                    while(i<=b)

                        {

                            if(i%4==0)
                            printf("%d\n",i); 
                            i++; 

                        }

            getch();

      }

Output:-
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________


Saturday 30 July 2016

Number Group Options in Ms-Excel


Count Formulas in Ms-Excel


Friday 29 July 2016

Program 8 Using While loop

#include<stdio.h>
#include<conio.h>

void main()

       {

             int a,b,i;
             clrscr();

             printf("enter starting range:");
             scanf("%d",&a);

             printf("enter ending range:");
             scanf("%d",&b);

             i=a;

             while(i<=b)

                     {

                            if(i%2==1)
                            printf("%d",i);
                            i++;

                     }

             getch();

       }

Output:-
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________


Greataims

 
Copyright © 2016 Computersadda. Designed by @ Computersadda Team - Published By Greataims