Some Questions of Language C :- Level - 3

Ask, post, publish your queries, articles, problems etc related with any software, script, language.
Forum rules
Read : Boardwide Rules and Regulation. Note: All views/post within are the opinions/work of the respective posters only.

Some Questions of Language C :- Level - 3

Postby Ashish » November 5th, 2008, 5:46 pm

Dear friends,
Here i am with more questions Of language C which will check your knowledge. Try to solve theses problems with the help of loops.


Question-1:- Write a program to print out all Armstrong numbers between 1 and 999. If sum of cubes of each digit of the number is equal to the number itself, then the number is called an Armstrong number. For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 )


Question-2:- Write a program to find the factorial value of any number entered through the keyboard.


Question-3:- Write a program to print the following series and find its value if "n" is entered through keyboard.
1 + 2 + 3 + 4 + .......... + n.


Question-4:- Write a program to check whether the entered number is PRIME or not.


Question-5:- Write a program to reverse the entered digits and print it on the screen.




Solutions will be provided in the next post after 2 or 3 days. ;)

So check your knowledge first and then refer to the solution.
Follow The Rules. Be Yourself. Trust Yourself. :D
User avatar
Ashish
Site Founder
Site Founder
 
Posts: 105
Joined: December 22nd, 2007, 11:55 pm
Location: Noida, India
Online: 6d 15h 18m 8s

Your Ad Here

Re: Some Questions of Language C :- Level - 3

Postby technology » November 28th, 2008, 3:19 pm

Answer - 1.

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

    void main()

    {
      int a,b,c,d,e=1;
      clrscr();
      printf("Armstrong Numbers\n");
      printf("=================");
      while (e<=999)
      {
        a=e/100;
        a=a*a*a;

        b=e%100;

        c=b/10;
        c=c*c*c;

        d=b%10;
        d=d*d*d;

        if (e==a+c+d)
        {
          printf("\n\t%d",e);
        }
        e++;
      }
      getch();
    }
User avatar
technology
Rook
Rook
 
Posts: 11
Joined: January 2nd, 2008, 1:12 pm
Online: 19m 40s

Re: Some Questions of Language C :- Level - 3

Postby technology » November 28th, 2008, 3:33 pm

Answer - 2.

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

    void main()

    {
      int a,b,c=1;
      clrscr();
      printf("Enter The Number :-\n");
      scanf("%d",&a);
      b=a;
      while (b>=1)
      {
        c=c*b;
        b--;
      }
      printf("Factorial :- %d",c);
      getch();
    }
User avatar
technology
Rook
Rook
 
Posts: 11
Joined: January 2nd, 2008, 1:12 pm
Online: 19m 40s

Re: Some Questions of Language C :- Level - 3

Postby technology » November 28th, 2008, 3:38 pm

Answer - 3.

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

    void main()

    {
      int a,b,sum=0;
      clrscr();
      printf("Enter the value of n \n");
      scanf("%d",&a);
      printf("Numbers :-\n\n ");
      for (b=1;b<=a;b++)
      {
        printf("%3d",b);
        sum+=b;
      }
      printf("\n\n Sum of the numbers from 1 to %d : %d",a,sum);
      getch();
    }
User avatar
technology
Rook
Rook
 
Posts: 11
Joined: January 2nd, 2008, 1:12 pm
Online: 19m 40s

Re: Some Questions of Language C :- Level - 3

Postby technology » November 28th, 2008, 3:43 pm

Answer - 4.

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

    void main()

    {

      int a,b=2;
      clrscr();
      printf("\n Enter the Number you want to check: \n");
      scanf("%d",&a);
      while(b<=a-1)
      {
        if(a%b==0)
        {
          printf("\n %d is not Prime number\n",a );
          break;
        }
        b=b+1;
      }
      if(a==b)
      {
        printf("\n %d is a prime Number\n",a);
      }
      getch();

    }
User avatar
technology
Rook
Rook
 
Posts: 11
Joined: January 2nd, 2008, 1:12 pm
Online: 19m 40s

Re: Some Questions of Language C :- Level - 3

Postby technology » November 28th, 2008, 3:46 pm

Answer - 5.

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

    void main()

    {
      long a,b;
      clrscr();
      printf("Enter the number\n\n");
      scanf("%ld",&a);
      printf("\n\n");
      for (;a>0;)
      {
        b=a%10;
        a=a/10;
        printf("%ld",b);
      }
      getch();
    }
User avatar
technology
Rook
Rook
 
Posts: 11
Joined: January 2nd, 2008, 1:12 pm
Online: 19m 40s


Return to Softwares, Programming & Tutorials

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: Exabot [Bot] and 1 guest

cron