Some Questions of Language C :- Level - 2

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 - 2

Postby Admin » October 21st, 2008, 2:03 pm



Dear friends,
Here i am presenting some questions Of language C which will check your knowledge. Starting level questions have already been asked so this time level 2 questions are being given.


Question-1:- Any integer is input through the keyboard. Write a program to find out whether it is an odd number or even number.


Question-2:- If the ages of Ram, Shyam and Ajay are input through the keyboard, write a program to determine the youngest of the three.


Question-3:- Find the absolute value of a number entered through the keyboard.




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: 196
Joined: December 22nd, 2007, 11:55 pm
Location: Gurgaon, India
Online: 11d 3h 55m 25s
Operating System: Windows XP
Browser: Google Chrome
Gender: Male
MCA: Alumni

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

Postby Admin » October 24th, 2008, 11:08 am



Solution 1



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

void main()

{
    int a;
    clrscr();
    printf("Enter the integer to be checked");
    scanf("%d",&a);
    if (a%2==0)
      {
        printf("Your number is EVEN.");
      }
    else
      {
        printf("Your number is ODD");
      }
    getch();

}


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

Solution 2


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

void main()

{
    int ram,shyam,ajay;
    clrscr();
    printf("Enter the age of RAM, SHYAM & AJAY respectively\n");
    scanf("%d%d%d",&ram,&shyam,&ajay);
    if (ram>shyam && ram>ajay)
      {
        printf("RAM Is Youngest.");
      }
    else if (shyam>ram && shyam>ajay)
      {
        printf("SHYAM Is Youngest.");
      }
    else
      {
        printf("AJAY Is Youngest.");
      }
    getch();

}


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

Solution 3


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

void main()

{
    int a;
    clrscr();
    printf("Enter any number\n");
    scanf("%d",&a);
    if (a<0)
      {
        a=0-a;
      }
    printf("Absolute value of given number is %d",a);
    getch();

}
Follow The Rules. Be Yourself. Trust Yourself. :D
User avatar
Admin
Gyan Pitara Founder
Gyan Pitara Founder
 
Posts: 196
Joined: December 22nd, 2007, 11:55 pm
Location: Gurgaon, India
Online: 11d 3h 55m 25s
Operating System: Windows XP
Browser: Google Chrome
Gender: Male
MCA: Alumni


Return to Programming & Tutorials

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 2 guests