## Solved Assignment - MCS-011 Problem Solving and Programming of Q1

Q1. (a) Write a simple program to find out how many of the numbers from 1 to 10 is greater than 4. Solution: #include<stdio.h>

#include<conio.h>

void main()

{

int i, count=0;

clrscr();

for(i=1;i<=10;i++){

if(i>4)

{

++count;

}

}

printf("nTotal number grater then 4 are: %d",count);

getch();

}

(b). Write a program in C that prompts the user with the following lines:

c) Compare two integers for the larger

t) Test an integer for odd or even

q) Quit

Solution: #include<stdio.h>

#include<conio.h>

void main()

{

int a,b,sum,ch;

char another='y';

clrscr();

while(another=='y'){

printf("nnYou have four choice:n");

printf("2: Compare two integers for the larger.n");

printf("3: Test the integer for odd or even.n");

printf("4: Quitnn");

printf("Enter Choice :");

scanf("%d",&ch);

switch(ch)

{

case 1:

printf("nnEnter two value :");

scanf("n%d%d",&a,&b);

sum=a+b;

break;

case 2:

printf("nnEnter two number :");

scanf("%d%d",&a,&b);

if(a>b)

{

printf("nThe grater number is %d.",a);

}else{

printf("nThe grater number is %d.",b);

}

break;

case 3:

printf("nnEnter any number :");

scanf("%d",&a);

if(a%2==0)

{

printf("nThe number is even.");

}else{

printf("nThe number is odd.");

}

break;

case 4:

exit();

break;

default:

printf("nnYou have entered wrong.");

}

printf("nnnFor continue enter y:");

another=getch();

}

}

(c). Write a function celsius() to convert degrees Fahrenheit to degrees Celsius.

Note: The conversion formula is °C = 5/9 * (°F - 32) (5×3=15 Marks)

Solution:

#Inclide<stdio.h>

#inclide<conio.h>

main()

{

float C; F;

printf(“Enter the tem. in Fahrenheit:”);

scnsf(“%f”,&F );

C=Float 5/9*(F-32);

printf(“nTem. In Celsius:”);

}

« MCS-011 Problem Solving and Programming

Posted on Thursday, May 28th, 2009 at 9:51 PM under   Year 2009 | RSS 2.0 Feed

Start Discussion!
*
* (Will not be published)
* (First time user can put any password, and use same password onwards)
*
Start a new topic: (If you have any question related to this post/category then you can start a new topic and people can participate by answering your question in a separate thread)
Title/Question: (55 Chars. Maximum)
Comment/Detailed description:* (No HTML / URL Allowed)

Characters left

Verification code:*

(If you cannot see the verification code, then refresh here)

Disclaimer: For documents and information available on BoardGuess.com, we do not warrant or assume any legal liability or responsibility for the accuracy, completeness, or usefulness of any information. Papers, Results, Syllabus, Logo and other educational contents are owned by Indian Education Board and BoardGuess does not hold any copyright on it. The format of materials, being displayed on this website, comes under the copyright act. BoardGuess.com, All Rights Reserved ©