If else statement in C Program

by on August 16, 2007 · 263 comments· LAST UPDATED August 16, 2007

in , ,

Q. Can you give me example for If else statement in C Program under Linux or TC?

A. C follows universal syntax for if..else. You can use any complier GNU Linux gcc or UNIX or old good TC.

if..else syntax

General if..else syntax is as follows:

if ( condition ) {
   expr_set1;
}
else  {
   expr_set2;
}

If given condition is TRUE, expr_set1 will get executed.
If given condition is FALSE (not TRUE), expr_set2 will get executed.

if..else example

Following example will find out large number from given input:

#include<stdio.h>
int main(){
        int x,y;
        printf("Enter value for x :");
        scanf("%d",&x);
        printf("Enter value for y :");
        scanf("%d",&y);
        if ( x > y ){
                printf("X is large number - %d\n",x);
        }
        else{
                printf("Y is large number - %d\n",y);
        }
        return 0;
}
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 263 comments… read them below or add one }

1 ferdinand v. baguingay December 10, 2008 at 3:22 am
#include
int main(){
        int x,y;
        printf("Enter value for x :");
        scanf("%d",&x);
        printf("Enter value for y :");
        scanf("%d",&y);
        if ( x > y ){
                printf("x is large number - %d\n",x);
        }
        else{
                printf("y is large number - %d\n",y);
        }
        return 0;
}

Reply

2 genji July 2, 2010 at 12:05 pm

i need more information about “if else”

Reply

3 merc velasco August 2, 2011 at 10:25 am

#include
main()
{
int grade;
char student[25],section[25];

clrscr();
printf(“Enter the name of a student: “);
scanf(“%s”, &student);
printf(“Enter the section of a student: “);
scanf(“%s”, &section);
printf(“Enter the grade of a student: “);
scanf(“%d”, &grade);

if(grade>75)
printf(“PASSED”);
else
print(“FAILED”);

getch();
}

Reply

4 Amit February 28, 2013 at 7:23 am

friend your “scanf(“%s”, &student); ” is not correct

the correct is “scanf(“%s”, student); ” thank you.

Reply

5 mira March 2, 2013 at 7:23 am

yes,it should be no & for character string,which means for name. only the character we must include the sign & for the scanf

Reply

6 amit March 4, 2013 at 11:52 am

yes mira i also mean the same

Reply

7 Hitesh March 31, 2014 at 9:25 am

hey amit u r wrong…………….the true statement is “scanf(“%s”,&student) Understand……

Reply

8 WAHID AKRAM November 15, 2013 at 5:11 am

how to count a repeated word in a phrase in TC (C Programming).

Reply

9 twinkle September 2, 2011 at 10:14 am

require more explanation
and examples

Reply

10 Ratnesh February 12, 2012 at 9:31 am

if statements is a conditional statements that executes on a particular condition
the syntax is
if (true) /* Here true means if(12>10) ,this is true so it will execute. */
{
execute this code
}
else
{
else execute this code
}

Reply

11 igki December 23, 2012 at 4:06 pm

In turbo c if clause is used in many places.An example of if statement is
void main()
{
int year;
clrscr();
printf(“Enter the year”);
scanf(“%d”&year);
if(year%4==0)
printf(It is a leap year”);
else
printf(“It is not a leap year”);
}

Reply

12 naga April 30, 2014 at 7:41 pm

in the if statement instead of “if(year%4==0) “statement if i use “if(year%4) ” then what does it represents can you please explain

Reply

13 anisha October 19, 2013 at 3:45 pm

The ability to control the flow of your program, letting it make decisions on what code to execute, is valuable to the programmer. The if statement allows you to control if a program enters a section of code or not based on whether a given condition is true or false. One of the important functions of the if statement is that it allows the program to select an action based upon the user’s input. For example, by using an if statement to check a user entered password, your program can decide whether a user is allowed access to the program.

Reply

14 Devendra,sujeet jha June 9, 2011 at 5:40 pm

#include
#include
void main()
{
int x,y,large;
clrscr();
printf(“input any two number”);
scanf(“%d %d”,&x,&y);
if(x > y)
{
printf(“large is =%d”,x);
}
else
{
printf(“largeis =%d”,y);
}
getch();
}

Reply

15 Justine July 12, 2011 at 10:54 am

What if, if I input f it would appear female alone then if m, it would male alone ?

Reply

16 affrin January 2, 2012 at 10:54 am

i need the answer for small and greatest number in 10 numbers

Reply

17 ashutosh sharma April 2, 2013 at 5:00 am

why we use return 0 in the last of program

Reply

18 arpitha.k July 8, 2014 at 9:22 am

bcz function is not returning any value

Reply

19 Ringkhang July 11, 2014 at 2:01 am

When we use int main() instead of void main(), it must be return 0. If u write void main(), none it to give return 0.

Reply

20 nazmul January 27, 2009 at 9:42 am

I need more if else program.i have simple problem.i don’t know your wbsite is active or not.next time i give a problem please solve it.

Reply

21 ankita May 5, 2010 at 1:28 pm

I need more program about if else

Reply

22 Meera. M May 25, 2010 at 5:08 am

#include
#include
main()
{
int age;
clrscr();
printf(“Enter the age:”);
scanf(“%d”, &a);
if(a<18)
printf("can't vote");
else
printf("can vote");
}

Reply

23 sreekanth October 8, 2010 at 5:30 pm

its wrong miss meera actually, wat u declared is age, and wat u using in (if statement) is a thats y its an error program

Reply

24 anisha October 19, 2013 at 3:40 pm

wrong answer

Reply

25 Devendra,sujeet jha June 9, 2011 at 5:51 pm

#include
#include
void main()
{
int age;
clrscr();
printf(“enter age=”);
scanf(“%d”,&age);
if(age>18)
{
printf(“can vote”);
}
else
{
printf(“can’t vote”);
}
getch();
}

Reply

26 addie stha September 1, 2011 at 3:52 am

#include
#include
void main()
{
int n;
clrscr();
printf(“enter the number:”);
scanf(“%d”,&n);
if (n%2==0)
printf(“the number is even”);
else
printf(“the number is odd”);
getch;
}

Reply

27 Chichaii January 14, 2013 at 12:06 pm

i need a example w/ no limitation..

Reply

28 ashutosh sharma April 2, 2013 at 5:16 am

there is error about voat.it gives only cannot voat

Reply

29 Bharath July 21, 2010 at 9:34 am

#include
main();
{
int marks;
scanf(“%d”,&marks);
if(marks>35)
printf(“Pass”);
else
printf(“Fail”);
}

Reply

30 Sharad Puri May 26, 2011 at 1:07 pm

PROGRAM To find whether a given year is leap or not
main()

{

int y,r1,r2;

printf(“Enter a year”);

scanf(“%d”,&y);

r1=y%4;

if (r1 = = 0)

{

r2=y%100;

if(r2 = = 0)

printf(“The given year is not a leap year”);

else

printf(“The given year is a leap year”);

}

else

printf(“The given year is not a leap year”);

}

Reply

31 Avinash veer July 10, 2011 at 5:53 pm

r2=y%100
(r2!=o)

Reply

32 Avinash veer July 10, 2011 at 5:58 pm

i need aprogram whan scanf true or faise and print 100 numbers

Reply

33 rin August 3, 2011 at 8:57 am

what do u mean by “y”,”r1″,”r2″ integer there?thnks!

Reply

34 tyaiba August 25, 2011 at 12:01 pm

why we use y%4.show me answer

Reply

35 adil August 26, 2011 at 2:55 pm

y%4

that means which value is store in y that is divided by 4
% is a modular

Reply

36 Amit February 28, 2013 at 7:37 am

y%4 does not store the value in y the correct process is y=y%4

Reply

37 ajnabi April 30, 2013 at 9:03 pm

bro u used twice dat else statement for printing the gvn year is nt a leap year which is wrong!!
u strtd in othr bracket within da if statement vch is nt possible!!

Reply

38 waleed February 18, 2013 at 12:48 pm

we use to find leap year that is why we use y%4

Reply

39 azizur rahman October 7, 2011 at 5:25 am

the year divided by 4, get remainder zero ,is leap year.

Reply

40 Ratnesh February 12, 2012 at 9:21 am

void main()
{
int num,grenum;
grenum=10;
printf(“Enter the number: “);
scanf(“%d”,&num);
if(num>gernum)
{
printf(“The number is Greater”);
}
else{
printf(“The number is smaller”);
}
}

Reply

41 aldrin March 22, 2009 at 1:34 pm

can you convert this to java program?

Reply

42 saviye.saviyola April 21, 2009 at 4:01 am

I just study programming .

Reply

43 alyssa mae cruz July 6, 2009 at 8:01 am

hello all..exiting ang programming nuh?haha

Reply

44 roy March 10, 2011 at 6:04 am

yeaH..that so exiting..even though i was lil bit confused.

Reply

45 Justine July 12, 2011 at 10:55 am

depende. mnsan nkkbwisit rn. haha

Reply

46 markjasonarceo September 21, 2009 at 9:45 am

how to analyze the problem to make c program?tnx

Reply

47 carrys September 24, 2009 at 3:41 am

hi i am a n IT student. i just want to ask if you could pls give me some simple problems regarding if else , if else if else, and i/o. and also those more complicated ones. thanks.

Reply

48 rossa maljuril September 22, 2011 at 4:29 am

you just search at programming statement.then all simple of statement in if else-if else will be displayed at your answer.

Reply

49 Pooja Sree December 3, 2009 at 5:15 am

Super Example For If Statement

Reply

50 BharathSVK July 21, 2010 at 9:40 am

#include
main()
{
int age;
Printf(“Age selection for Security”);
scanf(“%d”,&age);
if(age<50)
printf("Selected");
else
pritnf("Age excess-Sorry try Another place");
}

Reply

51 kalpana March 7, 2012 at 12:21 pm

void main()
{
int i,n;
printf(“Enter the level\n”);
scanf(“%d”,&n);
for(i=0;i<n;i++)
{
if(i%2==0)
{
printf("even number=%d",i);
}
else
{
printf("odd number=%d",i);
}
}
}

Reply

52 allen joyce December 15, 2009 at 5:55 am

i’m excited to try this program

Reply

53 allen joyce December 15, 2009 at 5:57 am

i need to create program right now for my project …………….help me …………………hehehe using IF ELSE STATEMENT

Reply

54 allen joyce December 15, 2009 at 5:58 am

Give me another example of IF ELSE STATEMENT

Reply

55 ajwa September 25, 2011 at 3:15 pm

#include
#include
void main()
{
float mob.mt, per;
clrscr();
printf(“\n enter the obtained marks:”);
scanf(“%f” , & mob);
printf(“\n enter the total marks in exams;”);
scanf(“%f” , & mt);
per= mob/tm* 100;
if(per>=40.0)
{
printf(“\n pass”);
}
else
printf(“\n fail”);
}
getch();
}

Reply

56 kalpana March 7, 2012 at 12:24 pm

void main()
{
int a;
printf(“enter the a value\n”);
scanf(“%d”,&a);
if(a>0)
printf(“a is positive”);
else
printf(“a is negative”);
}

Reply

57 bayan December 23, 2009 at 1:27 pm

can you help me to write this home work in C programs

*wirte the programsin C about if else
*the program should ask the user to enter the total marks out of 100, and then display the letter grade on the screen
*Grade Rules:
75 and above=”A”grade
60-74=”B”grade
50-59=”c”grade
40-49=”D”grade
Below 40=”Fail”

thanks .
please send it to my Email bayan321@live.com

Reply

58 Kenny June 19, 2010 at 12:16 pm

Your homework is very easy just use the
if(user>=75)
printf(“A”);
else if(user>=60 && user<=74)
printf("B");

and so on.

Reply

59 sujesha October 2, 2010 at 12:20 pm

did you manage to get the answer?
did anyone mailed you?
thanks
sujesha

Reply

60 riyas October 31, 2010 at 7:31 am

void main()
{
float mark;
clrscr();
printf(“Enter the total mark out of 100″);
scanf(“%f”,&mark);
if(mark<==75)
{
print{"Student has secured A Grade ";
}
else
{
.
.
.
.
.
.
getch();
}

Reply

61 myrabelle cabriana March 8, 2011 at 4:59 am

thank u..

Reply

62 sujeet jha June 10, 2011 at 12:10 pm

#include #include
void main(){
int i,j,k,l,m;
clrscr();
printf(“Enter your total marks”);
scanf(“%d”,&i);
if(i>=75){ printf(“Grade-A”);}
if(i=60){printf(“Grade-B”);}
if(i=50){printf(“Grade-C”);}
if(i=40){printf(“Grade-D”);}
if(i<40){printf("Fail");}
getch();
}

Reply

63 emxif January 22, 2010 at 6:14 am

i need some help guys
i am making a function oriented program and i used if else statement, i know that my statement is right but there is only 1 error and it says misplaced else…..
how can i fix that?
pls help me….
plss notify me on my email
thanks

Reply

64 vince July 27, 2010 at 4:36 am

you should misplace the curly braces { }. the syntax is
if (condition) {
statement 1
}
else {
statement 2
}

Reply

65 ali March 3, 2011 at 8:38 pm

Hello
make sure you use the proper braces before and after else statement.

Reply

66 JD October 8, 2011 at 10:41 am

hey else ya if ke baad semi colon ya brackat hoga isliye yeh erro aa rahi hai …………..
for example
else();
if()
so if and else use without any syntax…..
for example
if(condition)
{
statements(s)
}
else
{
statament(s)
}
ok byyyyyyyyyyyeeeeeeeeeeeeeeeeeeee

Reply

67 Glenn February 3, 2010 at 2:26 am

can you give more examples :-)

Reply

68 Levi February 18, 2010 at 1:21 am

Thanks I love you!!

Reply

69 mabel March 6, 2010 at 2:54 pm

pls. give me a program example of official receipt of sm using if else statement pls. we need it badly…pls…thanx

Reply

70 Darren March 9, 2010 at 11:47 pm

why can’t I place another “if statement” inside and “if statement”?

Reply

71 KAJI April 14, 2010 at 11:46 pm

using visual basic net i have to write a program using if-else statement based on the following condition the grdes of the students
0-49 D
50-55 C
56-60 C+
61-70 B
71-75 B+
76-85 A
86-100 A+

The program should repeat itself unless the user enters a negative value to terminate the program

Reply

72 venkata sai November 12, 2010 at 4:05 am

can you give me the def of if family statements

Reply

73 vishu May 26, 2010 at 4:51 am

include
int main(){
int x,y;
printf(“Enter value for x :”);
scanf(“%d”,&x);
printf(“Enter value for y :”);
scanf(“%d”,&y);
if ( x > y ){
printf(“x is large number – %d\n”,x);
}
else{
printf(“y is large number – %d\n”,y);
}
return 0;
}

Reply

74 Muneeb zargar June 1, 2010 at 4:23 pm

Use indentations ur prblm wl be solved

Reply

75 reyjohn June 24, 2010 at 9:51 am

PLEASE HELP ME!!!!

Can you answer the code of this?
The output is:

Enter the first number:
Enter the second number:
Enter the third number:

The smallest number is:
The middle number is:
The largest number is:

Reply

76 Noelene February 9, 2011 at 11:20 am

This is a Dev c++ software.. and if you’re using turbo c… just add –>clrscr();

#include
#include

int main ()
{
int n1,n2,n3;
int small, medium, large;
clrscr();
printf(“Enter the first number:”);
scanf(“%d”,&n1);
printf(“Enter the second number:”);
scanf(“%d”,&n2);
printf(“Enter the third number:”);
scanf(“%d”,&n3);

large=0;
if (large<n1) large=n1;
if (large<n2) large=n2;
if (largen1) small=n1;
if (small>n2) small=n2;
if (small>n3) small=n3;

medium=0;
if (medium<n1 && medium!=large) medium=n1;
if (medium<n2 && medium!=large) medium=n2;
if (medium<n3 && medium!=large) medium=n3;

printf(“The smallest number is:%d\n”,small);
printf(“The middle number is:%d\n”,medium);
printf(“The largest number is:%d\n”,large);
getch();
return 0;
}

Reply

77 Noelene February 9, 2011 at 11:23 am

Sorry about the first one, there are some errors…

This is a Dev c++ software.. and if you’re using turbo c… just add –>clrscr();

#include
#include

int main ()
{
int n1,n2,n3;
int small, medium, large;
clrscr();
printf(“Enter the first number:”);
scanf(“%d”,&n1);
printf(“Enter the second number:”);
scanf(“%d”,&n2);
printf(“Enter the third number:”);
scanf(“%d”,&n3);

large=0;
if (large<n1) large=n1;
if (large<n2) large=n2;
if (largen1) small=n1;
if (small>n2) small=n2;
if (small>n3) small=n3;

medium=0;
if (medium<n1 && medium!=large) medium=n1;
if (medium<n2 && medium!=large) medium=n2;
if (medium<n3 && medium!=large) medium=n3;

printf(“The smallest number is:%d\n”,small);
printf(“The middle number is:%d\n”,medium);
printf(“The largest number is:%d\n”,large);
getch();
return 0;
}

Reply

78 Mrityunjay Agrawal May 14, 2011 at 12:14 pm

#include

void main()
{
int a,b,c;
printf(“Enter first number–>”);
scanf(“%d”,&a);
printf(“Enter Second number–>”);
scanf(“%d”,&a);
printf(“Enter Third number–>”);
scanf(“%d”,&a);
if(a>b && a>c)
{
printf(“The largest number is->%d”,a);
if(b>c)
{
printf(“The middle number is –>%d”,b);
printf(“The smallest number is— >%d”,c);
}
else
{
printf(“The middle number is–>%d”,c);
printf(“The smallest number is – >%d”,b);
}
}
else if(b>c)
{
printf(“Largest number is —>%d”,b);
if(a>c)
{
printf(“The middle number is –>%d”,a);
printf(“The smallest number is— >%d”,c);
}
else
{
printf(“The middle number is–>%d”,c);
printf(“The smallest number is – >%d”,a);
}
}
else
{
printf(“Largest number is —>%d”,c);
if(b>a)
{
printf(“The middle number is –>%d”,b);
printf(“The smallest number is— >%d”,a);
}
else
{
printf(“The middle number is–>%d”,a);
printf(“The smallest number is – >%d”,a);
}
}

Reply

79 IT_Specialist June 26, 2010 at 7:20 pm

#include
main()
{
int x,y,z;
clrscr();
printf(“Enter the first number:”);
scanf(“%d”,&x);
printf(“Enter the second number:”);
scanf(“%d”,&y);
printf(“Enter the third number:”);
scanf(“%d”,&z);
z=x+y+z;
y=x+y+z;
x=x+y+z;
printf(“The smallest number is:%d\n”,z);
printf(“The middle number is:%d\n”,y);
printf(“The largest number is:%d\n”,x);
getch();
return 0;
}

Reply

80 Rej Irving February 14, 2011 at 5:44 am

Can u help me on this one?I need to create a program which tells the user what color he chose using codes:

Bl- Blue
G-Green
(so on and so forth)

i did use char color;
then
if (color==”Bl”)
{
printf (“You chose BLUE”);
}
else
{
printf (“Pick another color:”);
}
getch ()
}

The thing is there is no error but the result is only “PICK ANOTHER COLOR”. It means that the condition is not read isn’t it?

pleease help me..

Reply

81 arlyn July 5, 2010 at 8:58 am

can you make a program in this question?

plss reply at my email address, asap!!!

Objective:To learn how to write a C++ program using switch and do-while loop as applied to a simple airline application.

Procedure:

Write a program that will validate the status code so that only values from 0 to 3 will be accepted.If an invalid status code is entered, display the message “Invalid Status” and repeatedly accept a status code until a valid value is entered.Repeatedly accept passenger data prompting for “More Entries? (Y/N):” each time a set of data is entered.Terminate processing when response to this prompt is ‘N’.

Note: for string values you need to use strcpy function to assign the value entered to a character array variable (refer to your manual).

Name: XXXXXXXXXXXXXXXXX

Status:XChecked-in

Fare:9,999.99

Specifications:

1.The name of student and exercise no. should appear on screen.

2.Segregate input, process, validation and output statements by introducing void functions

3.Maintain the same display format as follows taking consideration of the error message and the “More Entries” prompt.

Name: XXXXXXXXXXXXXXXXX

Status :XBoarded

Fare:9999.99

More Entries? (Y/N):

4.Use the switch statement to display the corresponding descriptive status.

Statusdescription

0On-Schedule

1 Checked-In

2 Boarded

3 Arrived

Reply

82 Dyulokdyuti July 8, 2010 at 1:34 am

Thanx for help my study

Reply

83 angel August 16, 2010 at 1:19 am

Make a C program that will accept any integers from 1-12 and displays equivalent month, Example if 3 “March”.

Reply

84 anonimous August 25, 2010 at 1:25 pm

you could try using either switch case or nested if for that program

Reply

85 ... August 25, 2010 at 1:31 pm

#include
main()
{
int month;
printf(“\n Enter Number:”);
scanf(“%d”,&month);

switch(month){
case 1: printf(“January”);
break;
case 2: printf(“Febuary”);
break;
case 3:… and so on up to case 12..

default: printf(“number selected is invalid”);
}
}

Reply

86 jane krizia hailar August 23, 2010 at 1:00 am

i need more explanation of if-esle statement also example….

Reply

87 teoh September 5, 2010 at 6:12 am

i want to do a menu using if else,but after i try the error is occur.the error say that i using illege if else..wat is the problem that i face ,n how can i solve tis problem

Reply

88 chetan gupta September 14, 2010 at 5:12 pm

how to find square root of a number by using if else in c program?

Reply

89 Jason October 15, 2010 at 11:48 am

can you make a program that converts the value of binary to decimal, binary to-octal binary-hexa and decimal-binary, decimal-octal, decimal-hexa, and octal-decimal,octal-binary,octal-hexa, and hexa-binary,hexa-decimal,.hexa-octal;
your prompt reply is highly appreciated. thank you in advance.!
god bless..

Reply

90 Queen13 December 14, 2010 at 9:48 am

-SAMPLE “IF ELSE” PROGRAM-

#include
#include

int main(){
int grade;
clrscr();
printf(“Enter Grade:\n”);
scanf(“%d”, &grade);

if((grade>=80)&&(grade=75)&&(grade<=79))
printf("Nice");

else
printf("Poor");

getche();
return 0;
}

Reply

91 edison layco January 10, 2011 at 9:51 am

can you make a program in this output?

output
MODE OF PAYMENT
[1] CASH 10% DISCOUNT
[2] TWO-INSTALLMENT 5% INTEREST
[3] THREE-INSTALLMENT 10% INTEREST

ENTER YOUR TUITION FEE: 20,000
CHOOSE MODE OF PAYMENT: 1
THE AMOUNT OF PAYMENT:18,000

this is the output plsss. help me

Reply

92 emi January 10, 2011 at 2:17 pm

can any one solve this:
write a c program tht accept n integear from the user and pass it to the function that print the crossponding day 1=saturday
2=sunday
3=monday
4=tuesday
5=wednesday
6=thursday
7=friday

Reply

93 sonu asati October 3, 2011 at 11:45 am

#include
#include
void main()
{
int no_day;
clrscr();
printf(“enter the number of day \n”);
scanf(“%d”,&no_day);
switch(no_day)
{
case 2 :
printf(“sunday”);
break;
case 3 :
printf(“monday”);
break;
case 4 :
printf(“tuesday”);
break;
case 5 :
printf(“wednesday”);
break;
case 6 :
printf(“thursday”);
break;
case 7 :
printf(“friday”);
break;
default :
printf(“no match “);
}
getch();
}

Reply

94 ajj January 31, 2011 at 10:12 am

Can anyone tell me what will be the output of the following code.
P.S. Ignore the errors in the statements. Just know that this is the logic.
int a = 10;
if (!!a)
printf(“%d”,!a);
else
printf(“%d”, a)

Reply

95 ratnesh February 6, 2011 at 5:43 am

void main(){
int i;
switch(i){
case 1:
Printf(”monday”);
case 2:
Printf(”tuesday”);
case 3:
Printf(”wednesday”);
Case 4:
Printf(”thursday”);
.
.
.
Case 7:
Printf(”sunday”);
Default:
Printf(”enter appropriate number”);
}
}

Reply

96 AjWa September 25, 2011 at 3:27 pm

can v also solve it by else_if too…..??

Reply

97 AjWa September 25, 2011 at 3:28 pm

ratnesh u hve nt included break statement in switch statement.. without it prog cant run..!!!

Reply

98 Roni February 7, 2011 at 3:53 am

1. Prompts the user to input a percentile mark (i.e. prints a string asking the user to input a value between 0 and 100);
2. Reads a value from standard input and saves it in an appropriate variable (note: marks can be fractional);
3. Prints an error message if the mark entered is less than 0 or greater than 100;
4. If the mark is in range (i.e. between 0 and 100, inclusive) then print out the appropriate letter grade of the mark according to the following scale:
* 90+ = A+
* 80+ = A
* 75+ = B+
* 70+ = B
* 65+ = C+
* 60+ = C
* 55+ = D+
* 50+ = D
* < 50 = F

Reply

99 wiwie69 March 3, 2011 at 2:24 pm

can you help me with this…

ADDI, is one of the courier company that provide express service in delivering goods to customers. The tariff are based on total weight and delivery destination. Table below shows the pricelist.
Table 1 : Weight
Total Weight Price per kg

1st kilogram 15.00

The next 4kg ( 2-5kg) 13.00

The next 20kg (6-25 kg) RM 11.00

More than 25 kg RM 10.00

Table 2 : Destination
Destination Rate
Within a state
i. 1-25km
i. RM 5
ii. More than 25 km ii. RM 15
Domestic RM 30

For express delivery (within 1 day delivery), extra RM 25.00 is add.
You are required to write a program that will help customer to calculate the tariff based on information given. Your program shall display:
• Type of goods – documents or parcel
• Quantity
• Total weight
• Destination
• And delivery type – normal or express
• Total price to be paid

Reply

100 Masha March 12, 2011 at 12:59 pm

can someone halp me with this?

every week from monday to friday you go to class. when it is raining, you take an umbrella.
but on the weekend,what you do depends on the weather. if it is raining, you stay indoors. otherwise, you have fun outdoors.
write a c program to present your weekly program using if/else control statements.

Reply

101 joy March 22, 2011 at 7:21 am

please give me a code using array and function

Reply

102 renu April 2, 2011 at 7:32 am

i need more informations of c programs.

Reply

103 aklima akther April 21, 2011 at 11:47 am

can anyone help me to convert binary to octal by using for loop and bit wise operator.
what does bit wise (n>>i &7) mean and in last for loop what does i -= 3 mean.how is it related to convert octal.can anyone please help me this,

Reply

104 anch May 25, 2011 at 7:55 am

how to compare two number using bitwise… compare means is two number is less than or greater than each other . if suppose a and b are the two number we normailly compare by using
if(a>b)
…..
else
….
how can i do it by bitwise … :D

Reply

105 tejas May 27, 2011 at 1:22 pm

can you help me in making calc with frem

Reply

106 Joshua May 30, 2011 at 4:09 am

Can someone help me solve this assingnment ? am submiting it soon.Thanks

The manager, Mini Bit of the Megabyte mall wants a program to help his salespersons instantly determine the price of items purchase by their customers. To start with the manager wants a program that will be used to compute the prices of the following provisions: Fanta, Coke, Chocolate and Sprite. As a programmer you have been directed to come up with a program that will determine the item’s under consideration (eg. Fanta, coke, or…….) and ask for the price quote on the item as well as the number of that particular item you purchased. With this information the program should be able to calculate the total price someone is supposed to pay on the item.
Start from requirement and end at design
[15

Reply

107 sam June 1, 2011 at 7:14 am

write a c++ program to implement AND logic

Reply

108 sagal paudel June 2, 2011 at 1:34 pm

i want more in formation about the if else statement.

Reply

109 ramadhan kabange June 28, 2011 at 3:50 pm

i want to know more abt if else

Reply

110 arpit mishra August 8, 2011 at 8:06 am

#include
int main(){
int x,y;
printf(“Enter value for x :”);
scanf(“%d”,&x);
printf(“Enter value for y :”);
scanf(“%d”,&y);
if ( x > y ){
printf(“x is large number – %d\n”,x);
}
else{
printf(“y is large number – %d\n”,y);
}
return 0;
}

Reply

111 AjWa September 25, 2011 at 3:30 pm

if else statement is that:
if statement provides the facility to take action provided that some given condition is true. it does not allow to take action if the given condition is false. tha if_else statement gives this opportuinty.. the syntax of if_alse statement is;

if(condition)
{
statement 1;
statement 2;
.
.
.
statement n;
}
else
{
statement 1;
statement 2;
.
.
.
statement n;
}

the statement given before the else part vill be executed. if the given condition is true & in case of false statement,the statements given after the else vill be executed…..
do u need a perfect xmple of if_else statement????

Reply

112 Justine July 12, 2011 at 11:05 am

Hi, can u help me now pls ? ahm, how to do this:
1. When I input F it displays female
2. When I input M it inputs male ?

Reply

113 anver va July 21, 2011 at 12:49 pm

even though compiler says “succes” .i can’t run the program it says elseif statement error

Reply

114 THONIE July 21, 2011 at 3:58 pm

plss help me with this one !!
A salesman is paid a commission on the following basis
Sale Value Commission
up to $100 zero
over $100 to $1000 2%
over $1000 3%

Enter the sale value and print out the commission value (use a maximum entry value of $32000)

Reply

115 jheremie rochina July 23, 2011 at 5:01 am

can u help me to get the c code of this….
enter the first no:20
enter the second no:30
selection operation:+,-,/,%

Reply

116 mj calago August 12, 2011 at 7:44 am

can you give me a program for votation?? dat would also count the votes and declare who will win !!! please??? i’m begging you guys..!!!

Reply

117 joniel August 22, 2011 at 3:22 am

please give me an example using the IF statement… Please.. :)

Reply

118 Hanna August 22, 2011 at 1:15 pm

Kindly please help me with this:

Write a program that ask the user to input item name, item unit per price and item quantity. Determine the following:

Range(Quantity) Discount
0-50 0%
51-90 1%
90-100 2%
101-500 3%
501-1000 5%
1001-5000 7%
5801-above 10%

Reply

119 Dianne August 26, 2011 at 12:49 am

Can you help me figure out this problem?

This game is like the traditional “bato-bato pick” we Filipinos play. In this game, the user will select among “BATO”, “PAPEL”, and “GUNTING”. The computer will randomly select it’s pick. The game will be played for 5 rounds. The program will display the winner every after round and the player with the most win after 5 rounds will be declared as the winner. In case of a tie provide another round until the tie is broken.

Kindly help me. Using C Language programming only, Using if-else statement without the use of loop or jump. Thanks

Reply

120 vaishali August 27, 2011 at 5:42 am

1 scan four values from user and find maximum number from four numbers.

2.read any character from user and check whether that character is vowel or not . using conditional operator. (a,e,i,o,u are called vowel)

Reply

121 leecel August 29, 2011 at 2:27 am

Can you make a c program on this problem please:
-make a c program using “if else statements” where when you enter a month(in small letters), it will display the holidays on that month!
please, email me!

Reply

122 umesh kumar vishwakarma August 31, 2011 at 1:02 pm

/*Write a c program to accept any character and print their ASCII code.
sol:-
#include
#include
void main()
{
clrscr();
char ch;
printf(“\nEnter any character:-”);
scanf(“%c”,&ch);
printf(“ASCII code=%d”,ch);
getch();
}

Reply

123 harisha September 14, 2011 at 2:04 pm

i require a c program by using if else statement to print smallest of given four numbers

Reply

124 AjWa September 25, 2011 at 3:31 pm

if else statement is that:
if statement provides the facility to take action provided that some given condition is true. it does not allow to take action if the given condition is false. tha if_else statement gives this opportuinty.. the syntax of if_alse statement is;

if(condition)
{
statement 1;
statement 2;
.
.
.
statement n;
}
else
{
statement 1;
statement 2;
.
.
.
statement n;
}

the statement given before the else part vill be executed. if the given condition is true & in case of false statement,the statements given after the else vill be executed…..

Reply

125 Cool Gtm March 25, 2012 at 8:05 am

#include
#include
void main()
{
int a=10,b=20,c=30,d=40;
if (a<b && a<c && a< d)
printf("A is smallest");
else if (b<a &&b<c &&b<d)
printf(" b is smallest );
else if (c <a && c<b && c <d)
printf("c is smallest");
else
printf("D is smallest");
getch()
}

Reply

126 sneha September 15, 2011 at 7:08 am

can any one please send me a program to accept five numbers from console and then to dispaly them back on console in ascending number

Reply

127 harisha September 18, 2011 at 8:31 am

i require a c program by using if else statement to print smallest of given four numbers
please email me

Reply

128 divya s September 19, 2011 at 8:05 am

i want more in formation about the if else statement.

Reply

129 Monica September 20, 2011 at 10:02 pm

I need help with writing a program that prompts the user to enter two dates and then indicate which date comes earlier on the calendar

Enter first date (mm/dd/yy): 3/6/08
Enter second date (mm/dd/yy): 5/17/07
5/17/07 is earlier than 3/6/08

Your help would be greatly appreciated!!!!!

Reply

130 Numan January 10, 2014 at 8:08 pm

Input 31/1/2014

And let me know the output

Reply

131 foong September 25, 2011 at 1:34 pm

The program allows user to perform the operations of a calculator, namely addition, subtraction, multiplication and division. However, these four operations will be implemented slightly differently and they are described below.

You must use functions to implement these arithmetic operations. The function prototypes and their descriptions are as follows:

int add( int num1, int num 2);
- returns the sum of num1 and num2.

int subtract( int num1, int num2 );
- returns the difference of num1 – num2

int multiply( int num1, int num2 );
- returns the product of num1 and num2. You are not allow to use the * operator. Use a loop and the add() function to implement the multiplication. Note that the product of num1 and num2 is equal to (num1 added num2 times).

int divide( int num1, num2 );
- returns the quotient of num1 divided by num2. If num2 is zero, it prints an error message (division by zero is invalid) and it returns the value 0.

In addition to the functions above, the program should also have a function which prints out a nice menu that prompts the user for input. The user will always enter two numbers. The user’s input is to be interpreted in the following way.

1. If both numbers are non-negative, it means the user wishes to perform multiplication of the two numbers.
2. If only one number is non-negative, it means the user wishes to perform division.
3. If both numbers are negative and the first number is bigger than the second number, then the user wishes to perform subtraction.
4. If both numbers are negative and the first number is smaller than the second number, it means the user wishes to perform addition.
5. If both numbers are negative and have the same value, it means the user wishes to quit the program.

The program should allow the user to enter two numbers and then perform the corresponding task. This process should be repeated until the user enters the appropriate numbers (two negative numbers of equal value) to quit the program.

When the user chooses to quit the program, your program should print out the following statistics. This should be done using a function. The statistics are:
1. A count of how many times the user has performed each of the addition, subtraction, multiplication and division operations.
2. A count of the total number of operations performed.

help me pls….apply the use of nest if else, loops, function

Reply

132 Peter B. September 26, 2011 at 3:09 pm

Reading everything but the original post made me feel dumber. To everyone:
1) Learn how to spell. and when and when not to capitalize
2) Actually learn something about C before coming here.

Reply

133 sonu asati October 5, 2011 at 12:32 pm

//program for bell sound
#include
#include
void main()
{
clrscr();
printf(“\a wellcome wwww \ a”);
getch();
}

Reply

134 mutuzo ruth October 7, 2011 at 7:19 am

good and interesting

Reply

135 leah October 10, 2011 at 9:30 am

can you give me more definitions about if-else statement plsss..tnx a lot

Reply

136 Andrei de Luna October 11, 2011 at 7:25 am

can you make a program in this output?

output
MODE OF PAYMENT
[1] CASH 10% DISCOUNT
[2] TWO-INSTALLMENT 5% INTEREST
[3] THREE-INSTALLMENT 10% INTEREST

ENTER YOUR TUITION FEE: 20,000
CHOOSE MODE OF PAYMENT: 1
THE AMOUNT OF PAYMENT:18,000

this is the output plsss. help me

Reply

137 nerissa March 14, 2013 at 3:06 pm

do you have already a code of that mode of payment

Reply

138 Maria Moosa October 12, 2011 at 6:45 pm

write a c program that will get 4 integers and will print out the maximum integer…can anyone solve this?

Reply

139 niwash October 15, 2011 at 3:39 pm

i want more information collect about if &else condition
thanks

Reply

140 Anand panday October 15, 2011 at 4:10 pm

Pls help me. A programe which accpt three no. & if the 1st no. Is 3rd no. Then print sqare other wise multiply is by 3. If 1st no. Is >2nd no. But <3rd no. Then prnt gud question . Else print boaring question.

Reply

141 Anand panday October 15, 2011 at 4:42 pm

Ans.

#Include
#include
void main()
{
int n1, n2, n3;
clrscr();
printf(“enter three no.”);
scanf(“%d,%d,%d; &n1,n2,n3″);
if (n1>n3)
printf(“n1 is largest”);
else
printf(“n3 is largest”);
}
else
{
if (n2>n3)
printf (“n2 is largest”);
else
printf (“n3 is largest”);
}
getch();
}

Reply

142 nor mafuzah bt mohamad yusof October 17, 2011 at 1:54 pm

please help me..
can you do for me this question?
Write a program that is capable of finding the 2 largest and 2 smallest integers.
As input, the program is to read the data from the data file TWOMM.DAT.
This data file consists of
line 1 int1 int2 int3…………int10
line2 int11 int12 int13……int20

Write the output to the screen in the form:

The two largest values in the list are:
… …..
The two largest values in the list are:
….. …..

Reply

143 nor mafuzah bt mohamad yusof October 17, 2011 at 2:03 pm

help me please..do this answer..
Write a program that is capable of finding the 2 largest and 2 smallest integer in a list of 20 integers.
As input, the program is to read the data from the data file TWOMM.DAT.
This data files consists of

line 1 int1 int2 int3 ……………………..int10
line 2 int11 int12 int13……………………….int20

Write the ouput to the screen in the form:
The two largest values in the list are:
….
The two largest values in the list are:
……

Reply

144 fLirTty October 17, 2011 at 5:58 pm

#include
void main()

{
int a,c,e,hours,wage,salary;
printf(“enter hours\n”);
scanf(“%d”,&a);
salary=a*10;
if(hours<=40)
printf("salary=%d",salary);
else
printf("enter no hours");
scanf("%d",&c);
printf("enter the wage");
scanf("%d",&e);
salary=((c-40)*15)+(400);
printf("salary=%d",salary);
}

Reply

145 fLirTty October 17, 2011 at 6:02 pm

i havE tO makE a salary calculatOr, in which if a worker works for <=40 hours he will get 10$
but fOr EvEry Extra hOur abOvE 40 hE wiLl wagE 1.5 timEs morE.. :/
Outputs shOuld bE likE this: E.g.
39 hOurs= 390 $
40 hOurs= 400 $
41 hOurs= 415 $
42 hOurs= 430 $..
can anyonE hElp.. :|

Reply

146 sumit October 24, 2011 at 3:31 am

i have some problem’s in if else statements or give me suggestion how i read about it

Reply

147 Utku October 29, 2011 at 1:30 pm

Help me plss i dont run. idont make. pls explore . . .

1. The proper divisors of a positive integer n are those integers, excluding n itself,
that
divide n exactly. For example, the proper divisors of 12 are 1, 2, 3, 4 and 6.
Write a program that inputs a positive integer and outputs its proper divisors.
Sample run :
Input: 8
Output: 1 2 4
2. A program that accepts a set of integers and displays the number of positive and negative
numbers. The program stops when the user enters 0 for the integer value.

Reply

148 sri November 5, 2011 at 8:02 am

2. Write a program that reads the marks of a student, determine and prints the equivalent grade, based on the following:

Marks Range Grade
< 45 E
45 <= Marks < 60 D
60 <= Marks < 75 C
75 <= Marks = 90 A

i got do.but there got some error that i can’t find.please help me.

#include
void main()
{
int mark;
char grade;

printf(“Enter your mark:”);
scanf(“%f”,&mark);

if(mark<45)
grade='E';

else if(mark<=45 && mark<60)
grade='D';

else if (mark<=60 && mark<75)
grade='C';

else if(mark<=75 && mark=90);
grade=’A’;

printf(“Your grade is %c\n”,grade);

}

Reply

149 sri November 5, 2011 at 10:03 am

Please give me answer for this question
Suppose a company decides to raise the salaries of its employees according to the following table:

employee_status years_of_service percent_raise
Full-time Less than 5 years 4.0
Full-time 5 years or more 5.0
Part-time Less than 5 years 2.5
Part-time 5 years or more 3.0

If employee_status value is ‘F’, the employee is Full-time; if it is ‘P’, he or she is part-time. Using any selection control structure of your choice, write a program that computes the new salary of an employee given his or her employee_status, years_of_service and salary by the users.

Reply

150 hira November 8, 2011 at 11:31 pm

Write a program that prompts the user to input an integer between 0 and 25. If user enters 0 then Display A, if user enters 1 then Display B, if user enter 2 then Display C and so On…

Reply

151 Jibril November 17, 2011 at 2:25 pm

can someone solve this problem for me .
~ leave a comment “//” of their use and function..

[1]van arrives
[2]passenger arrives
[3]passenger boards van
[4]van leaves

each van has the following properties: plate number, driver,passenger, limit
let letters represent passenger vans and numbers represent passenger
flow of van and passenger is as follows
raymark: IF event 1 happens, then a van arrives at the terminal..
starting with label A
there can only be one passenger van at the terminal
at a time
hence
if event 1 happens while there is still a van at the terminal, . message saying “terminal is full”
should be displayed. the next van that arrives at the terminal should be labeled as b and so on

if event 2 happens, a passenger arrives at the terminal, starting with label 1, if there is a van at the terminal, then the passenger boards the van automatically(event3). otherwise, the passenger waits in a queue. once a van arrives the passenger un the queue will automatically load the van.

a van automatically leaves the terminal(event4) if the number of a passenger who have boarded is equal to the passenger limit of the van
the foolowing information mus be displayed at all times: current van label and passenger list.

you are to write an iterative, menu driven JAVA APPLICATION that simulates the van at ATC

the following implementation details are req: functions use of control structures – selection and control and use of variable

( free to organize your menu choices as long as the feature described above . )

Your help would be greatly appreciated!!!!!
send to my email..

Reply

152 Jibril November 17, 2011 at 2:27 pm

follow up ! using DEV c++ compiler …

Reply

153 jia November 28, 2011 at 5:17 am

Write a program in which user enters the integer value and your program returns its binary equivalent. can any body help me with it?

Reply

154 janani December 2, 2011 at 4:09 am

can u just tell me, wat condition shuld be placed inside for loop

if( )
{
printf(“abcd”);
else
printf(“acdb”)
}

it should give output as

abcd
acdb

or

acdb
abcd

pls can u just tell me wat condition should be given inside if loop..

Reply

155 DeeP_HackeRR January 24, 2013 at 6:23 pm

Dude it will print “abcd” when condition is true otherwise when condition is false it will put “acdb”…to make neat and easy code using ‘For’ loop try to give “TRUE” condition.like wrote below:
if (num>0)
printf(“You have Entered positive number”);
else
printf(“You have Entered nagative number”);

Reply

156 sanat June 12, 2013 at 12:56 pm

after condition use ;

Reply

157 Patricia December 8, 2011 at 12:33 pm

help me please. I need to make a program entering someone’s birthday and the current date today and it will identify your age. How??

Reply

158 prabhat December 8, 2011 at 1:43 pm

thankz a lot

Reply

159 Joseph December 10, 2011 at 3:22 am

/*Create a C++ Program that will input
two (2) values and will output its:
-> sum -> exponent product
-> difference -> square root of the first value
-> product -> square root of the second value
-> quotient -> remainder/modulo quotient
-> integer quotient */

#include
#include

using namespace std;

int main()
{

double Number1,Number2,IntegerQoutient;
double Sum,Difference,Product,Qoutient;
double ExponentProduct,squareroot1,squareroot2,remainder;

cout <<"This is a calculator" << endl;

cout <> Number1;
cout <> Number2;

Sum=Number1+Number2;
Difference=Number1 – Number2;
Product=Number1 * Number2;
Qoutient=Number1 / Number2;
IntegerQoutient=Number1/ Number2;
ExponentProduct=pow(Number1,Number2);
squareroot1=sqrt(Number1);
squareroot2=sqrt(Number2);
remainder=fmod(Number1,Number2);

cout <<"OPERATION:" << endl;
cout < Press 1″ << endl;
cout < Press 2″ << endl;
cout < Press 3″ << endl;
cout < Press 4″ << endl;
cout < Press 5″ << endl;
cout < Press 6″ << endl;
cout < Press 7″ << endl;
cout < Press 8″ << endl;
cout < Press 9″ << endl;
int n;

cout << "Please choose any from the option above " <> n;

if (n==1)
cout <<"Youve chosen Addition, the answer is: "<< Sum << endl;
else if (n==2)
cout <<"Youve chosen Subtraction, the answer is: "<< Difference << endl;
else if (n==3)
cout <<"Youve chosen Multiplication, the answer is: "<< Product << endl;
else if (n==4)
cout <<"Youve chosen Division, the answer is: "<< Qoutient << endl;
else if (n==5)
cout <<"Youve chosen IntegerQoutient, the answer is: "<< IntegerQoutient << endl;
else if (n==6)
cout <<"Youve chosen ExponentProduct, the answer is: "<< ExponentProduct << endl;
else if (n==7)
cout <<"Youve chosen Squareroot of 1st no, the answer is: " << squareroot1 << endl;
else if (n==8)
cout <<"Youve chosen Squareroot of 1st no, the answer is:" << squareroot2 << endl;
else if (n==9)
cout <<"Youve chosen Remainder, the answer is:" << remainder <9

Reply

160 Joseph December 10, 2011 at 3:24 am

/*Create a C++ Program that will input
two (2) values and will output its:
-> sum -> exponent product
-> difference -> square root of the first value
-> product -> square root of the second value
-> quotient -> remainder/modulo quotient
-> integer quotient */
——— my answer
#include
#include

using namespace std;

int main()
{

double Number1,Number2,IntegerQoutient;
double Sum,Difference,Product,Qoutient;
double ExponentProduct,squareroot1,squareroot2,remainder;

cout <<"This is a calculator" << endl;

cout <> Number1;
cout <> Number2;

Sum=Number1+Number2;
Difference=Number1 – Number2;
Product=Number1 * Number2;
Qoutient=Number1 / Number2;
IntegerQoutient=Number1/ Number2;
ExponentProduct=pow(Number1,Number2);
squareroot1=sqrt(Number1);
squareroot2=sqrt(Number2);
remainder=fmod(Number1,Number2);

cout <<"OPERATION:" << endl;
cout < Press 1″ << endl;
cout < Press 2″ << endl;
cout < Press 3″ << endl;
cout < Press 4″ << endl;
cout < Press 5″ << endl;
cout < Press 6″ << endl;
cout < Press 7″ << endl;
cout < Press 8″ << endl;
cout < Press 9″ << endl;
int n;

cout << "Please choose any from the option above " <> n;

if (n==1)
cout <<"Youve chosen Addition, the answer is: "<< Sum << endl;
else if (n==2)
cout <<"Youve chosen Subtraction, the answer is: "<< Difference << endl;
else if (n==3)
cout <<"Youve chosen Multiplication, the answer is: "<< Product << endl;
else if (n==4)
cout <<"Youve chosen Division, the answer is: "<< Qoutient << endl;
else if (n==5)
cout <<"Youve chosen IntegerQoutient, the answer is: "<< IntegerQoutient << endl;
else if (n==6)
cout <<"Youve chosen ExponentProduct, the answer is: "<< ExponentProduct << endl;
else if (n==7)
cout <<"Youve chosen Squareroot of 1st no, the answer is: " << squareroot1 << endl;
else if (n==8)
cout <<"Youve chosen Squareroot of 1st no, the answer is:" << squareroot2 << endl;
else if (n==9)
cout <<"Youve chosen Remainder, the answer is:" << remainder << endl;

return 0;
}

Reply

161 Md.Akbar December 13, 2011 at 1:51 pm

#include
#include
main()
{
int x,y;
clrscr();
printf(“Enter a value for x and y:”);
scanf(“%d%d”,&x,&y);
if(x>y)
printf(“X is greater”);
else
printf(“Y is greater”);
getch();
}

Reply

162 pradeep kumar October 18, 2012 at 1:15 pm

good

Reply

163 Hak December 22, 2011 at 1:22 pm

when have exersice about time ?what we do in if else?can u example

Reply

164 student December 24, 2011 at 12:37 pm

Thankyou for post!! If- else statement examples still not enough.
Im not being able to find out what exactly the error is here:
#include
void main()
{
int numsweet;
double cost;
printf(“How many icecream do you want : “);
scanf(“%f, &numsweet”);
cost = 12.10 * numsweet;
if (numsweet > 1000)
{
printf(“The store does not have that much icecream in stock!”);
}
else
{
printf(“You have to pay $%f to the cashier!\n Thankyou!\n”, cost);
}
}

It gives a warning saying says “Possible use of numsweet before definition in funtion main. Plz help! any advice is welcomed.

Reply

165 muru October 5, 2012 at 9:40 am

scanf(“%f, &numsweet”);
change this to :
scanf(“%f”, &numsweet);

Reply

166 Brendon October 13, 2012 at 9:14 am

Your header file declaration is incomplete #include 2.scanf(“%f”,&numsweet); here you didn’t close the conversion or format string with quotes””.

Reply

167 Deepak Jain November 2, 2012 at 5:56 am

While reading integer use %d & not %f.
%f is used to read a float value not a integer

Reply

168 SATYARANJAN DAS December 24, 2011 at 1:49 pm

#include
void main()
{
int n,rem;
clrscr();
printf(“enter the number”);
scanf(“%d”,&n);
rem=n%2
if(rem==0)
printf(“the number is even”);
else
printf(“the number is odd”);
getch();
}

Reply

169 pop December 24, 2011 at 1:56 pm

#include
void main()
{
int a=10;
if(x==10)
{
printf(“pop”);
printf(“rock”);
}
else
printf(“song”);
printf(“romance”);
}
o/p:-pop rock romance

Reply

170 Mohamad Mostafa January 8, 2012 at 1:52 am

i need you help guys about something, i am trying to use “if and else” commands but it’s not working at all, can someone tell me what i did wrong ?!!!

#include
main()
{
char name[4] = {”};
char namem[5] = {”};

printf(“What is your name ?!\n”);
scanf(“%s”, &name);

if(“name==Mark”)
{
printf(“Right, Your name is %s\n\n”, &name);
}

else {
printf(“No, your name is Mark”, &namem);
}

system(“pause”);
}

Reply

171 khushi October 18, 2012 at 12:01 pm

#include //link section
#include
void main()
{
char name[4]; //local variable declare string type
char namem[5]=”ANIL”; //declare & initialized string
clrscr();
printf(“What is your name ?”);
scanf(“%s”, name); // input any string in run time

if(name==”Mark”) // check condition
{
printf(“Right, Your name is: %s”,name);
}

else
{
printf(“No, your name is Mark %s”, namem);
}
getch();
}

Reply

172 hansel January 22, 2012 at 3:16 am

The number 153 has interesting property, it equals to the sum of the cubes of its digit, that is 13+53+33=1+125+27=153. Construct a C Program that reads in a positive three integer number and determine if the number satisfy the property or not. Accordingly, display the number with a message “SATISFY THE PROPERTY” or “DOES NOT SATISFY THE PROPERTY”.

Reply

173 rajeeva February 26, 2012 at 3:35 pm

#include
int main()
{
int A,a,B,b,num,T;

printf(“\t Please Enter an Integer you need to check the properties :”);
scanf(“%d”,&num);

A=num%10;
a=num/10;
B=a%10;
b=a/10;
//This is to check the values, in case of confusion//
printf(“A=%d a=%d B=%d b=%d \n”,A,a,B,b);

A=A*A*A;
B=B*B*B;
b=b*b*b;
//This is to check the values, in case of confusion//
printf(“A=%d B=%d b=%d \n”,A,B,b);
T=A+B=b;
if(T==num)
{
printf(“\t SATISFY THE PROPERTY/n”);
}
else
{
printf(“\t DOES NOT SATISFY THE PROPERTY /n”);
}
return 0;
}

Since this is regarding if-else statement you may use this method,but can also reduce the steps by using a for or do-while loop,=)

Reply

174 rosen September 12, 2012 at 4:57 pm

@hansel
this number 153 is one of the armstrong numbers..
an armstrong number is a number whose sum of the cube of the digits is same as that of the number..

#include
#include
void main()
{
int r,c1,c2,c3,n,t,num;
clrscr();
printf(“\n please enter the 3 digit no.”);
scanf(“%d”,&n);
t=n;
//calculates the cube of last digit
r=n%10;
n=n/10;
c1=r*r*r;
//calculates the cube of middle digit
r=n%10;
n=n/10;
c2=r*r*r;
//calculates the cube of first digit
r=n%10;
n=n/10;
c3=r*r*r;
//sums up the cubes
num=c1+c2+c3;
//checking
if(num==t)
{
printf(“\n%d Satisfies the property”,t);
}
else
{
printf(“\n%d doesnot Satisfies the property”,t);
}
getch();
}

Reply

175 hansel January 22, 2012 at 3:17 am

Plss. .help me about this problem. . . .

Reply

176 sangeetha January 25, 2012 at 2:14 pm

i want the program to fing greatest among 4 numbers using nested if else ladder

Reply

177 Anna January 30, 2012 at 12:01 pm

Please help me guys!!!!!!!!!!!!!
I need a program for the sales and inventory system…….ASAP!!!!!!!!!!!
if ever who have a knowledge about the said system please email me at my yahoo account….. annarah_aquipan@yahoo.com
“May God will pay back you for your kindness”……..
Thank you so much!!!!!!!!!!!

Reply

178 enkeli February 4, 2012 at 2:15 pm

pls help me

pls create a program that will accept 5 integers and display the lowest integer

pls use nested if for c++/turbo c

thanks..

Reply

179 enkeli February 4, 2012 at 2:19 pm

pls create a program that will accept 5 integers and display the highest and the lowest number

any conditional statement in c++/turbo c

thanks..

Reply

180 skret February 9, 2012 at 5:32 am
181 skret February 9, 2012 at 5:33 am

some one please help me on my task, i need to write a program that can read 10 integer and then display the:

>biggest number
>smallest number
>total
>average

Reply

182 Reccalyn Castillo February 9, 2012 at 10:56 am

–>> i badly need the answer regarding this program, can you help me:))

Write a program that complete the users prompt a services of numbers the program must be determine the odd and even number.. prompt by the users ; also sum the odd and even numbers.

Reply

183 shiva February 9, 2012 at 11:17 am

Nice to see this site.
am learning c language from this cyberciti.biz web site. its really good to learn c for freshers.

Reply

184 hassan February 10, 2012 at 4:28 am

write a program that inputs movie and displays his movie according ti following character ;
s sorrow movie
r romentic movie
a action movie
s scientific movie
f funny movie

Reply

185 Cool Gtm March 25, 2012 at 8:53 am

//trying first check this program n plz send comment in cool_gtm2005@yahoo.com
void main()
{
char m1[20],m2[20],m3[20],m4[20],m5[20];
char ch;
printf(“Enter the five different movies\n\n”);
scanf(“1 %2s \n %2s \n %2s \n %2s \n %2s”, &m1,&m2,&m3, &m4, &m5);
clrscr();
printf(“enter the choice( S,R,A,s,F) TO GET MOVIES”);
scanf(“%c”,&ch);
if(ch==’S’)
printf( ” ur selection is %s”,m1);
eise if (ch==’R’)
printf(“ur selection is %s”,m2);
else if ( ch==’A’)
printf(“ur selection is %s”,m3);
else if (ch==’s’)
printf(” ur selection is %s”,m4);
else
printf(” ur selection is %s”,m5)
getch();
}

Reply

186 arnel March 22, 2013 at 3:02 pm

what does ch means? i dk, sorry explain.

Reply

187 swapna yadav February 17, 2012 at 7:55 am

can anyone say me y do v use == instead =

Reply

188 arnel March 22, 2013 at 3:02 pm

== is use for if conditions while = is use for assigning a value. for example, if(a==1) and int a=1.

Reply

189 Ahsin Khan February 21, 2012 at 6:17 am

I want to make a program to find out largest and smallest numbers out of 5 numbers using only 10 if statements and 7 printf statements……is there any one who can solve it…please let make it solve quickly its assignment……!!!!

Reply

190 Cool Gtm March 25, 2012 at 9:06 am

// im trying coo gtm less than 10 if state
void main()
{
int num1,num2,num3,num4,num5,great;
if (num1>num2 && num>num3 && num1>num4 && num1>num5)
great=num1;
else if (num2>num1 && num2 >num3 && num2 >num4 && num2> num5)
great=num2;
else if (num3>num1 && num3 >num2 && num3 >num4 && num3 > num5)
great =num3;
else if (num4>num1 && num4 >num2 && num4 >num3 && num4>num5)
great=num4;
else
grate=num5;
/* same opposite to smallest number*/
printf( “the greatest number is %d”, great);
getch();
}

Reply

191 mary faith February 24, 2012 at 3:46 am

i want to make a program that will ask the user, how much will be the cost in playing in the computer shop per minute. the program will calculate the cost based on the given formula.

1.) 1 peso every 4mins.
cost * mins = total payment

2.) cost * sec. = total payment
sec. =.25

Reply

192 sandhya March 13, 2012 at 3:32 pm

hi!! i need the answer for this program please. :):)
Write A Program To Accept The Marks Of Five Subjects And Find The Total And Percentage.
Description :-
If Value Of Any Of Five Subjects Is Negative Or Zero Or 100 An Appropriate Error Is To Be Displayed On The Screen And Program Should Terminate.

Reply

193 Reshma Rajeev April 1, 2012 at 6:58 am

If(“condition”)
printf(“Hello”);
else
printf(“World”);

What should be the “condition” if the output is “HelloWorld”.

Reply

194 shadik August 9, 2012 at 7:33 pm

condition means….num==num2 or num!=num2 like this.but you just use
if(condition) but you didn’t give any condition.

Reply

195 anum shakir April 24, 2012 at 2:47 pm

hi i need heip from u in this program and my question is
write a program that perform all basic operation of calculator.?
these re options
1) add, sub. multiply, divide
2) using oject and class of iostream and ostream
# long as data type .
plz send me thiz program tomorrow itz my assignment and i ll be very grate ful to u for thiz favour thnkz

Reply

196 Ly po May 12, 2012 at 11:53 am

I want to print like This In C++ and C
######
#####
####
###
##
#
Thanks

Reply

197 sitesh September 22, 2012 at 4:08 am

#include
void main()
{
char title[]=”SUBHAS CHANDRA BOSE”;
for(int i=0; title[i];i++)
cout<<"\n"<<(title+i);
}

Reply

198 Chetna January 28, 2013 at 4:16 am

for(i=8;i>0;i–)
{
printf(“\n #”);
}

Reply

199 Rajat May 14, 2012 at 12:14 pm

please, help me task ,
write a c program input any number b/w 1 to 12 and print month name according to input number.(using if else statement)

Reply

200 Chetna January 28, 2013 at 4:22 am

if(m==1)
{
printf(“\n January”);
}
else if(m==2)
{
printf(“”\n February);
}
else if(m==3)
{
printf(“”\n March);
}
else if(m==4)
{
printf(“”\n April);
}
else if(m==5)
{
printf(“”\n May);
}
else if(m==6)
{
printf(“”\n June);
}
else if(m==7)
{
printf(“”\n Julye);
}
else if(m==8)
{
printf(“”\n Ogust);
}
else if(m==9)
{
printf(“”\n September);
}
else if(m==10)
{
printf(“”\n Octomber);
}
else if(m==11)
{
printf(“”\n November);
}
else if(m==12)
{
printf(“”\n December);
}
else
{
printf(“”\n Invalid selection);
}

Reply

201 darmie May 19, 2012 at 8:40 am

pls help write a program in c-language. the integral of (2t^2 +3t +1) the limit is from 0 to 4.using the trapezoidal rule

Reply

202 Hozefa May 26, 2012 at 6:55 am

include
main()
{
int m;
cout<>m;
if(m==0)cout<<"Jan";
else if(m==o)cout<<"Feb";
else if(m==o)cout<<"Mar";
else if(m==o)cout<<"Apr";
else if(m==o)cout<<"May";
else if(m==o)cout<<"June";
else if(m==o)cout<<"July";
else if(m==o)cout<<"Aug";
else if(m==o)cout<<"Sept";
else if(m==o)cout<<"Oct";
else if(m==o)cout<<"Nov";
else if(m==o)cout<<"Dec";
else cout<<"Wrong entry";
getch();}

Reply

203 Chetna January 28, 2013 at 4:24 am

include
main()
{
int m;
coutm;
if(m==1)cout<<"Jan";
else if(m==2)cout<<"Feb";
else if(m==3)cout<<"Mar";
else if(m==4)cout<<"Apr";
else if(m==5)cout<<"May";
else if(m==6)cout<<"June";
else if(m==7)cout<<"July";
else if(m==8)cout<<"Aug";
else if(m==9)cout<<"Sept";
else if(m==10)cout<<"Oct";
else if(m==11)cout<<"Nov";
else if(m==12)cout<<"Dec";
else cout<<"Wrong entry";
getch();}

Reply

204 dorothy June 12, 2012 at 6:26 am

so nice answers are provide and sharing

Reply

205 Sandeep Chaurasia August 7, 2012 at 4:46 pm

void main()
{
int i,j;
clrscr();
for(i=1;i=i;j–)
printf(“#”,j);
printf(“\n”);
}
getch();
}

Reply

206 Poorva August 22, 2012 at 7:19 pm

#include
#include
void main()
{
int x;
printf(“enter any number between 1 to 12″);
scanf(“%d”,&x);
if(x==1)
{
printf(“month is jan. %d\n”,x);
}
else if(x==2)
{
printf(“month is feb%d\n”,x);
}
else if(x==3)
{
printf(“month is march .%d\n”,x);
}
else if(x==4)
{
printf(“month is april %d /n”,x);
}
else if……………….
…………………………………….
………………..
………………………
…………………………….
else(x==12)
{
printf(“month is december %d\n”);
}
getch();
}

Reply

207 atal September 29, 2012 at 6:08 pm

how to use if else statment to find out the that given integer is prime no or not

Reply

208 pravin parse October 2, 2012 at 7:38 am

write a c programme to calculate first class, second class, pass class, of student where marks by supplied by user/*………………plz give me ans fast…………..*/

Reply

209 Tanvir Hossain October 17, 2012 at 6:28 pm

you have to work with three temperature types: Celsius, Fahrenheit and Kelvin. What we are going to do here, people would come to you to ask to convert temperature. They come with three inputs, the temperature which they want to convert, the type of the temperature and the intended type to convert it. As we are dealing with three types of temperature, we represent them 0, 1 and 2 (Celsius = 0, Fahrenheit = 1 and Kelvin = 2). The temperature is a number (floating point). The output is the temperature in the intended type.

Reply

210 fateh October 26, 2012 at 6:47 am

how to put if else inside if else?

#include
void calculation();
int main(void)
{
int type,no_resistor,resistor1,resistor2,resistor3,voltage,totalr,current;
printf(“Circuit Calculator V1.0\n”);
printf(“Structured programming & interfacing\n”);
printf(“By: Muhammad Al-fateh\n”);
printf(“Date: 1 NOV 2012\n”);
printf(“Purpose:This programme will ask user to enter elements of circuit and calculate the total resistance & current value\n\n”);
printf(“———————————————–\n”);
printf(“Please choose type of circuit:\n”);
printf(“1.Series Circuit\n”);
printf(“2.Parallel Circuit\n”);
scanf(“%d”,&type);
if (type == 1)
{
printf(“You have choosen Series circuit.\n”);
printf(“Enter number of resistor (2 or 3 resistor only):”);
scanf(“%d”,&no_resistor);
printf(“This is how the circuit look like\n\n”);
}

if (no_resistor == 2)
{
printf(” +—–===—-===—–+\n”);
printf(” | R1 R2 |\n”);
printf(“(v) |\n”);
printf(” +——————–+\n”);
calculation();
}
else if (no_resistor == 3)
{
printf(” +—–===—-===—–+\n”);
printf(” | R1 R2 |\n”);
printf(“(v) |\n”);
printf(” +—-===————-+\n”);
printf(” R3 \n”);
calculation();
}
else
{
printf(“Choose between 2 or 3 ONLY\n”);
}

else if (type ==2)
{
printf(“You have choosen Parallel circuit.\n”);
printf(“Enter number of resistor (2 or 3 resistor only):\n”);
scanf(“%d”,&no_resistor);
printf(“This is how the circuit look like\n\n”);
}
if (no_resistor == 2)
{
printf(” +——===—–+\n”);
printf(” | R1 |\n”);
printf(” +——===—–+\n”);
printf(” | R2 |\n”);
printf(” +——(V)—–+\n”);
calculation();
}
else if (no_resistor == 3)
{
printf(” +——===—–+\n”);
printf(” | R1 |\n”);
printf(” +——===—–+\n”);
printf(” | R2 |\n”);
printf(” +——===—–+\n”);
printf(” | R3 |\n”);
printf(” +——(V)—–+\n”);
calculation();
}
else
{
printf(“Choose between 2 or 3 ONLY”);
}
else
{
printf(“Choose between no 1 or no 2 (tips: enter digit only)”);
}
return(0);
}
void calculation()
{
int type,no_resistor,r1,r2,r3,voltage,totalr,current; //r1 = resistor 1 and so on..
printf(“This program will now calculate the total voltage and current\n”);
printf(“Please enter voltage value (for battery):”);
scanf(“%d”,voltage);
printf(“Please enter resistor value based on diagram given:”);

if ( type == 1 && no_resistor == 2)
{
printf(“Enter value R1 and R2 ( put space between answers)”);
scanf(“%d %d”,&r1,&r2);
totalr = r1+ r2;
current=voltage/totalr;
printf(“Total resistance = %d and current = %d”,totalr,current);
}
else if ( type == 1 && no_resistor == 3)
{
printf(“Enter value R1 ,R2 and R3( put space between answers)”);
scanf(“%d %d %d”,&r1,&r2,&r3);
totalr = r1+ r2;
current=voltage/totalr;
printf(“Total resistance = %d and current = %d”,totalr,current);
}
else if (type == 2 && no_resistor == 2)
{
printf(“Enter value R1 and R2 ( put space between answers)”);
scanf(“%d %d”,&r1,&r2);
totalr = 1/((1/r1)+ (1/r2));
current=voltage/totalr;
printf(“Total resistance = %d and current = %d”,totalr,current);
}
else if ( type == 2 && no_resistor == 3)
{
printf(“Enter value R1 ,R2 and R3( put space between answers)”);
scanf(“%d %d %d”,&r1,&r2,&r3);
totalr = 1/((1/r1)+ (1/r2)+(1/r3));
current=voltage/totalr;
printf(“Total resistance = %d and current = %d”,totalr,current);
}
else
{
printf(“null”);
}
}

Reply

211 Dilip kumar December 18, 2012 at 9:23 am

#include
#include
main ()
{
int x,y;
scrclr();
printf(“Enter value for x :”);
scanf(“%d”,&x);
printf(“Enter value for y :”);
scanf(“%d”,&y);
if ( x>y)
{
printf(“X is less-than: %d\n”,x);
}
else{
printf(“Y is greater-than: %d\n”,y);
}
getch();
}

Reply

212 santosh January 9, 2013 at 7:01 am

i need while loop examples

Reply

213 vidhya January 15, 2013 at 3:30 am

#include
main()
{
int i=0;
while(i<10)
{
printf("gud morning");
}
getch();
}

Reply

214 vidhya January 15, 2013 at 3:01 am

hai, i want a simple program about for loop. may u pls.thanks

Reply

215 romeje January 15, 2013 at 12:34 pm

the xyz telegram company charges 18.50 for telegram that do not exceed 12 words and 1.50 pesos for every succeeding word.construct a C program that accepts the number of words in a telegram compute and display the charges.

Reply

216 Yogesh January 16, 2013 at 2:58 am

Can anyone clarify on me, on below statement,

if (++time>59)
{
statement1;
}

Reply

217 cj January 23, 2013 at 2:33 pm

somebody help me plzz .. so important :D

the new telephone company has the follwing rate structure for long distance calls:

a. any call started after 7:00PM (1900hrs) but before 8:00 (0800 hours) is discounted 30%
b. any call stared after 8:00 am (0800 hours) but before 7:00 (1900 hours) is charged full.
c. all calls are subjected to 8% tax
d. the regular rate for a call is P15.00 per minute.
e. Any call longer than 60 minutes receives a 20% discount on its cost (after any other discount is subtracted but beofre tax is added)

Instructions:
1. Write a c program that takes the start time for a call based on a 24-hour clock and the lenght of the call in minutes. the gross cost (before any discounts or tax) should be printed followed by the net cost (after discounts is deducted and tax added).
2. Design a graphical user interface or GUI that fits to the given problem.
3. The program will accept multiple user.

Reply

218 vidhya January 25, 2013 at 11:57 am

hai, i want to know about while loop

Reply

219 navya January 26, 2013 at 7:35 am

give the syntax of simple if statement in c

Reply

220 soumen dofadar January 26, 2013 at 5:30 pm

good…but not enough to understand clearly…..

Reply

221 Eva mae January 30, 2013 at 2:33 am

guys!! will you help me to create a program that have a switch statement,do while, and if else.. this is can be see in a one program only..!

Reply

222 Siddarth February 5, 2013 at 2:10 pm

#include
int main()
{
int x,y;
printf(“enter value for x=”);
scanf(“%d”,&x);
printf(“enter value for y=”);
if(x>y){
printf(“x is the greater number=%d\n”,x);
}
else{
printf(“y is the greater number\n”,y);
}
return 0;
}

Reply

223 kartikpareek February 10, 2013 at 8:26 am

plz give answer -wap to input number continuslt but only positive number will display input 0 for stop program?

Reply

224 krishan kant azad February 24, 2013 at 3:27 pm

#include
#include
void main()
{
int a;
clrscr();
printf(“enter the any value”);
scanf(“%d”,&a);
if(a==5)
printf(“A is a greater the”);
else
printf(B is a less then);
getch();
}

Reply

225 Sheukh March 11, 2013 at 12:54 pm

//* hi friends i have a problem with the following program.actualy i used turbo c compiler under dosbox 0.74v when i compile this program then it shows none error.when i run this program then it runs properly but i cant get desired o/p.
this program is to define wether the driver is insured or not.conditions for insurance are as
1) if driver is married – then driver is insured.
2) if driver is unmarried,male and age more than 30 – then driver is insured.
3) if driver is unmarried,female and age more than 25 – then driver is insured.
when i enter age-22,sex-f,and marrital status-u
(i.e.age=22/sex=female/marrital status=unmarried)
then i get o/p that driver is insured.
so kindly help me.
#include
void main()
{
clrscr();
char ms,sex;
int age;
printf(“enter age,sex & marrital status\n”);
scanf(“%d%c%c”,&age,&sex,&ms);
if(ms==’m’)
printf(“driver is insured\n”);
else
{
if(sex==’m’)
{
if(age>30)
printf(“driver is insured\n”)
else
printf(“driver is not insured\n”);
}
else
{
if(age>25)
printf(“driver is insured\n”);
else
printf(“driver is not insured\n”);
}
}
getch();
}

Reply

226 mike March 12, 2013 at 12:51 am

Prompt the user for a day number then print the name of the day, where 1 = Sunday, 2 = Monday, etc. If the user enters a number other than 1 through 7, print an error message.

Use If-then/else statement and then do the same for switch statements

Reply

227 muhammd asim ismaila March 15, 2013 at 3:36 am

need a little more simplicity and explanation

Reply

228 neeraj March 21, 2013 at 4:50 pm

write a pgm using logical operation to find out that a person has insurence policy or not
1) if married
2)if unmaried – gender-male
age more than 30 years
gender- female
age more than 23 years
can smone tell me completely.

Reply

229 manoo March 25, 2013 at 8:05 pm

show the solution at the vedio store new releases rent for 3.00 a night oldies rent 2.00 your sales clerk will enter 1 for new release 2 for oldies to be stored in the variable type OR write the statement s that would increment the appropriate counter variable keeping track of the number of new releases and oldies rented and add the appropriate amount to the variable keeping track of the current sale.

Reply

230 manoo March 25, 2013 at 8:07 pm

i wana need a help for solving this solution plz help me

Reply

231 sohaimey March 26, 2013 at 11:43 am

I need loop (while, do while, do) in C program

Reply

232 newbie March 30, 2013 at 4:50 am

sir .. can you help me.. plss..
using do/while loop write a program that computes and display the sum of all even positive input numbers. the program terminates if it reads a negative number..

sample input/ouput dialogue:
enter a number:1
enter a number:2
enter a number:3
enter a number:4
enter a number:-4

the sum of all even number(s) is:6

now na po.. ^_^

Reply

233 Kevin July 17, 2013 at 6:16 am

sum = 1+2+3+4+-4;

Reply

234 Marc April 18, 2013 at 10:27 am

Need help please. Assignment Please answer it. Thank you so much :)

write a program that computes the grade of a student using the formula:
grade=40% major exam + 30% ave of 2 long exams + 30% of a short quizzes.
Display the average of two long exams, average of 3 short quizzes and the grade of the student.display also a message whether the student passed of failed passing is 75%

Reply

235 Roy May 14, 2013 at 9:26 am

Prompt the users to enter the subject name and traverse the list of subjects and if the entered subject is in list, display the name of the subjects (English, Math, Science. French). Using only if/switch statements

Reply

236 abdi May 17, 2013 at 5:15 am

hy guys i did this program my assigment so i wanna added like when you ask you name i wana printed if it dont know like i dont understand can any one help me pleas
if you can this is my email s3368964@student.rmit.edu.au
#include

int main (){
int UserAsk ;
int UserName ;
int UserAge;
int UserSpeed;
printf(“sir can i see y license?”);
scanf(“%”,UserAsk);

printf(“whats you name?”);
scanf(“%abdi”,&UserName);

printf(“how old are you sir”);

scanf(“%d”,&UserAge);

if(UserAge=40)

printf(“Sir Are you drunk?”);
scanf(“%d” , &UserSpeed);

//Conditional Statment to Test if the Driver is drunk
//if the user is not drunk, they are allowed to drive

if(UserSpeed 70
printf(“You drive safety speed thnx.”);

}else{
//This stuff runs only if the statement evaluates to <70
printf("sir your speeding,mor then 70 km/h!");
}
getchar();
getchar();

return 0;
}

Reply

237 Amy May 30, 2013 at 3:46 pm

Hotel Seri Malaysia has pointed you to build a room reservation system. The system required total of guest that will be insert by user. Then, the system allowed user to select appropriate rooms. There are 4 types of rooms with different of prizes and capacity. If the total guest balance is 1, the guest will suggested to share the room with others guest. Refer to when that has different prices and the amount of different people. Each room is given different discount value. Please refer to Table 1 for the detail.

Table 1: Information of available rooms in Hotel Bayu.
Room types Maximum (persons) Price (peak) Discount given
Melur 1 150 10% off
Kenanga 2 250 20% off
Teratai (studio) 2 300 25% off
Rafflesia (suite) 3 350 30% off

Customer is required to pay a deposit of 50% of the actual price.

Your system should have:
1. Global declaration of all the variables and functions.
2. 5 functions: function melur, function kenangan, function teratai, function rafflesia and calculate balance of person.
3. In each function, you need to calculate the following items:
a. Number of rooms
b. Total price before discount
c. Total price after discount
d. Amount paid by customer
e. Amount to be paid
Below is the example of the formula to be used:
Example of formula (for room type Kenanga) :
num_of_rooms = num_of_people/2;
before_discount = 250*num_of_rooms;
after_discount = (before_discount-(0.20*before_discount))
deposit = 0.5*after_discount;
to_be_paid = after_discount-deposit;

4. If there is a balance person that not allocated in the rooms, user needs to re-select the room.
5. System will calculate total amount from the to_be_paid amount.

Your program must use operators, control statements (for, do while or any equivalent) and at least 4 functions.

Reply

238 rokon June 22, 2013 at 12:45 pm

Take two number inputs and a arithmetic operator (+,-,*,/,%) as a character input and to the arithmetic operation and give the output. For example, Your output should be like this:

Enter a number (A) : 3.0
Enter a number (B) : 8.5
Enter an operator : *

A*B= 25.5

Reply

239 nimpha June 23, 2013 at 12:59 pm

i need a help using switch here is the question….
Create a c program that will accept a value or amount prom peso and convert it based on a given choice of user
Choice Currency AMOUNT
1 YEN .50
2 UAD 40.50
3 USD 42.50
4 EURO 62.25

Reply

240 Kevin July 17, 2013 at 5:49 am

guys can you help me?

i need an example of if else statement that accept 3 numbers as input the identify the highest,lowest and middle value.

anyone can help me. please! :(

Reply

241 Unell August 7, 2013 at 2:50 pm

can u help me to construct C program !!!! this is the question
The XYZ telegram company charges 18.50 for telegrams do not exceed 12 words and
1.50 pesos for every succeeding word. Construct a C program that accepts the number of words in a telegram compute and display the charge..

can u help me about this !!!!! using turbo C

Reply

242 ashish saxena August 10, 2013 at 6:58 am

i want to convert numeric value to char valu(as 199).is but i wann to print (one hundered ninty nine) thi output

plz tell me how this possibale thank you……

Reply

243 Shuvo August 19, 2013 at 6:25 pm

#include
#include
void main()
{
int a;
while(‘N’)
{
printf(“\nEntr Your Marks: “);
scanf(“%d”,&a);
if(a>’39′&&a=’33′&&a<='39')

printf("D\n\n");

else if(a=’0′)printf(“F”);

else

printf(“Wrong Input. please Enter Marks 0 to 100.\n\t\t Thanks”);}
getch();
}

Reply

244 3in@j August 27, 2013 at 4:28 am

Will u pls help me print this output? .:(
Election Results
Enter no. of precints: 3
No. of votes:
Precint 1: 10
Precint 2: 13
Precint 3:15
Precint with highest votes: 3
Precint with lowest votes: 1

Reply

245 Jerome agas August 30, 2013 at 3:30 pm

can you please help me to program . . .
/*create the program that accepts three numbers and identify the largest, middle and smallest number if the two or three numbers are equal the output will be the two or three number are equal and smaller or larger

Reply

246 zamaal September 7, 2013 at 5:27 pm

1. Write a C program that asks user to input an amount, then display 5%, 10% and 15% discount of that amount. For example,
Please input the amount:
5% Discount =
10% Discount=
15% Discount=

Reply

247 muhammad anwar bin hassan al ashari September 12, 2013 at 8:36 am

use the If else programming, please do program below

formula BMI = Weight(kg) / [Height(m) x Height (m)]

Using program control to print below conditions;

1.If Your BMI Less than 18.5, you are underweight
2.If Your BMI is 18.5 less than 25, your weight is desirable
3.If Your BMI is 25 to less than 30, your are overweight
4.If Your BMI is 30 or more, you are obese

Reply

248 Naqash Ahmed October 11, 2013 at 10:04 am

develop a program to print the charges for a person,if he enter his age then program ask the user to enter his age and by using if else structure print the charges,if age is 55 and above it the charges is 10$ if age is 21 to 54 it charges is 15$ if age is 13 to 20 it charges is 8$ if age is 3 to 12 it charges is 5$ if under 3 no charges that will be free.
plz snd me in cmplete c++ format

Reply

249 ahmad October 22, 2013 at 12:34 pm

how to print as below:
4 4 4 4
4 4
4 4
4 4 4 4
when a user enters 7, it will printed:
7 7 7 7 7 7 7
7 7
7 7
7 7
7 7
7 7
7 7 7 7 7 7 7
when user enter 2, it will printed:
2 2
2 2

The program should only allow a user to enter an integer from 1 to 9 in which the ‘Invalid integer’ will be displayed and user will be asked to reenter the integer from 1 to 9 again. After the rectangular shape has been printed, user should be asked whether they want to reenter another integer to reprint the other size of rectangular or they want to exit the program.

Reply

250 Fresnel November 9, 2013 at 6:29 am

Hey guys! Can you help me with this?

Make a C++ program that will ask the user to input an alphabet character then will display the rest of the characters taking user’s input as its initial value.

Example:
Enter a small letter: r
Output: r s t u v w x y

Reply

251 james January 12, 2014 at 8:50 pm

can i do sth like this ====> if (a==xxxx) {printf”you are ok “}
else { you are not ok}
where xxxx is a character . plz txt me back cuz i need it now . thnx :)

Reply

252 michael January 18, 2014 at 11:28 am

My Question:
Call charges:1st minutes are free and 2.25 for each minutes.
SMS chargers:0.25 per SMS(50 SMSs are free for month).
Monthly rental is 300.00.
Government taxes 12.5% of total bill amount.
Write a suitable C program to calculate total bill(including taxes)when number of minutes and SMSs are given as input.
Please tell me what’s the wrong with those code.When I run the program it did not work properly.

int main()
{
    printf("\t\tDialog Monthly Total Bill Amount-Version-R01\n");
    float x,y,Total1,Total2,Tatol3;
    {
        printf("Number of minute for call:",x);
        printf("Number of SMSs sent:",y);
    }
    if (x>200)
    {
        printf("call charge=(minutes-200)*2.25");
    }
    else
    {
        printf("call charge=0");
    }
    if (y<=50)
    {
        printf("SMS charge=0");
    }
    else
    {
        printf("SMS charge=SMS*0.25");
    }
    printf(Total1=(300+(call charge+SMS charge))*0.125));
    scanf("%f",Total1);
    {
        printf("Total1 is%0.2f",Total1)
    }
    return 0;

Reply

253 akanksha paithane January 29, 2014 at 3:35 am

explain if \else statement with its syntax which logical operation are user in false statement and how explain whith examples.

Reply

254 arbe February 23, 2014 at 11:14 am

hi,guys .. can you give me a example to create a program that deals in if then statement?

thanks..

Reply

255 pooja mehta April 2, 2014 at 9:52 am

hello.my question is that what does it means
1.if(;;)
2.how we can infinitely use if condtion
3.if(=)

Reply

256 janaki April 15, 2014 at 12:49 pm

please give me the solution for this programm

if(?)
{
printf(“Hello”);
}
else
{
printf(“world”);

what is the condition for get Output:”Hello World”
}

Reply

257 Michael May 6, 2014 at 6:15 am

please i need help i want to know whats wrong with this my codes
#include
#include
#include

int main()
{
float price = 91;
float quantity;
float discount1 = 1 – 0.2;
float discount2 = 1 – 0.3;
float discount3 = 1 – 0.4;
float discount4 = 1 – 0.5;
float totalcost1 = price * quantity * discount1;
float totalcost2 = price * quantity * discount2;
float totalcost3 = price * quantity * discount3;
float totalcost4 = price * quantity * discount4;

printf(“\t Micro-world Technologies Discount Sales\n\n “);
printf(” Please enter the quantity of items sold: \n”);
scanf(“quantity is: %f\n”, &quantity);

if(10 >= quantity = quantity = quantity <= 99){
printf(" Total cost on 40percent discount is = %f\n", totalcost3);
} else {
printf(" Total cost on 50percent discount is = %f\n", totalcost4);
}

system("pause");
return 0;
}

Reply

258 Michael May 6, 2014 at 6:18 am

#include
#include
#include

int main()
{
float price = 91;
float quantity;
float discount1 = 1 – 0.2;
float discount2 = 1 – 0.3;
float discount3 = 1 – 0.4;
float discount4 = 1 – 0.5;
float totalcost1 = price * quantity * discount1;
float totalcost2 = price * quantity * discount2;
float totalcost3 = price * quantity * discount3;
float totalcost4 = price * quantity * discount4;

printf(“\t Micro-world Technologies Discount Sales\n\n “);
printf(” Please enter the quantity of items sold: \n”);
scanf(“quantity is: %f\n”, &quantity);

if(10 >= quantity = quantity = quantity <= 99){
printf(" Total cost on 40percent discount is = %f\n", totalcost3);
}
else {
printf(" Total cost on 50percent discount is = %f\n", totalcost4);
}

system("pause");
return 0;
}

Reply

259 wilson sanico June 12, 2014 at 2:56 am

help me to solve this problem
,, create a c++ program that will accept 3 integers an

Reply

260 elgo July 12, 2014 at 10:48 am

if input the distance traveled by a taxi in kilometer and then display the taxi fare based on the distance traveled. the flag down rate is $40 and additional $ 3.50 per 300 meters traveled.
1km=1000meter

Reply

261 john August 1, 2014 at 2:13 pm

1. Create A program that will accept number between 1-40.
2. Program will identify whether the number is HIGH or LOW category based from criteria.
* HIGH —> 21-40
* LOW —-> 1-20
3. under low category each number falls on this must be labeled as above 10 or below 10, criteria.
* ABOVE 10 = 11-20
* BELOW 10 = 1-10
4. program display the result.
5. program close.

OUTPUT:

Enter number = 18

18 is above 10 under low category.

Enter number = 22

22 is above 20 under high category.

pls help me. im using DEV C++ 5.6.2.
pls HELP me.

Reply

262 Ridoy Bhuiya August 2, 2014 at 8:26 pm

Please Help ME!!!!!

Write a program in c that prompts the user to enter the year and a month of the year and displays the calendar table for the month of that year on the console…

Reply

263 Bernard August 18, 2014 at 12:52 pm

Can i Have a question??
it can be happen if the state is IF ELSE statement inside has a SWITCH Statement?? it can be possible??

Reply

Leave a Comment

Tagged as: , , , ,

Previous Faq:

Next Faq: