Some Questions Of Language C :- Level - 1

Ask, publish your queries, articles, problems etc related with any programming, scripting, 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 - 1

Postby Admin » October 5th, 2008, 8:06 pm



Dear friends,
Here i am presenting some basic questions Of language C which will refresh your knowledge of language C. Since it is starting level questions thus we should not use "loop" or other things to solve these problem.



Question-1:- Write a program to convert Fahrenheit degrees into Centigrade degrees.


Question-2:- If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the modulus operator ‘%’)


Question-3:- If a five-digit number is input through the keyboard, write a program to reverse the number.




Solutions will be provided in the next post. ;)

So check your knowledge first and then refer to the solution.
Follow The Rules. Be Yourself. Trust Yourself. :D
User avatar
Admin
Gyan Pitara Founder
Gyan Pitara Founder
 
Posts: 181
Joined: December 22nd, 2007, 11:55 pm
Location: Gurgaon, India
Online: 10d 20h 44m 45s
Operating System: Windows XP
Browser: Google Chrome
Gender: Male
MCA: Alumni

Re: Some Questions Of Language C :- Level - 1

Postby Admin » October 5th, 2008, 8:49 pm



Solution 1



/* Program to change the Temperature from Fahrenheit to Celsius */

#include<stdio.h>
#include<conio.h>
void main()
{
       float f,c;
       clrscr();
       printf("Enter the value of temperature in Fahrenheit :- \n\n");
       scanf("%f",&f);
       
       c=(f-32)/1.8;
       
       printf("\n\n Converted Temperature in Degree Celsius is %f. \n\n",c);
       getch();
}


===========================================================================================

Solution 2


/* Program to calculate the sum of the digits of a five digit number */

#include<stdio.h>
#include<conio.h>
void main()
{
    long num,d1,d2,d3,d4,d5,sum=0;
    clrscr();
    printf("\n\n Enter the five digit number.\n\n");
    scanf("%ld",&num);

    d1=num%10;
    d2=(num/10)%10;
    d3=(num/100)%10;
    d4=(num/1000)%10;
    d5=num/10000;

    sum=d1 + d2 + d3 + d4 + d5;

    printf(" \n\n The digits when added will give %ld as the sum.\n\n",sum);
    getch();
}


===========================================================================================

Solution 3


/* Program to reverse the entered five digit number */

#include<stdio.h>
#include<conio.h>
void main()
{
    long num,d1,d2,d3,d4,d5,rev=0;
    clrscr();
    printf("\n\n Enter the five digit number.\n\n");
    scanf("%ld",&num);

    d1=num%10;
    d2=(num/10)%10;
    d3=(num/100)%10;
    d4=(num/1000)%10;
    d5=num/10000;

    rev=d1*10000 + d2*1000 + d3*100 + d4*10 + d5;

    printf(" \n\n The reversed number is %ld .\n\n",rev);
    getch();
}
Follow The Rules. Be Yourself. Trust Yourself. :D
User avatar
Admin
Gyan Pitara Founder
Gyan Pitara Founder
 
Posts: 181
Joined: December 22nd, 2007, 11:55 pm
Location: Gurgaon, India
Online: 10d 20h 44m 45s
Operating System: Windows XP
Browser: Google Chrome
Gender: Male
MCA: Alumni

Re: Some Questions Of Language C :- Level - 1

Postby viveck » October 20th, 2008, 1:03 pm



Excellent work for the learners of C keep it up bro.
Do the things you fear and the fear will disappear.
User avatar
viveck
Hardworking Farmhand
Hardworking Farmhand
 
Posts: 22
Joined: May 15th, 2008, 6:47 pm
Location: una (h.p)
Online: 18h 56m
Operating System: Windows VISTA
Browser: Mozilla Firefox
Gender: Male


Return to Programming & Tutorials

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 2 guests