Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
any one give answer to my question?
We have write one 'C' program.
Problem is
Accept floating point no from user,and find out this no is divisible by 7 and not divisible by 2.
constriants
using simple if statment only,not nested if statement.
In if statemnet using only logical or not allowed logical AND.
no need the no.
i want program in 'c' languagae
6 Answers
- 2 decades agoFavorite Answer
include <stdio.h>
void main(){
float no;
scanf("%f",&no);
if(!( ((int)no)%7!=0 || ((int)no)%2==0 ))
printf("No is divisible by 7 and not divisible by 2");
}
salam
- luninabnerLv 42 decades ago
...no matter how bright or cloudy the
day, when the sun goes down, it gets
dark. That's logic as I know it.
Floating points,statments and statemnets make
no sense whatever.
- 2 decades ago
main()
{
float a,b;
printf ("enter the number");
scanf("%f",&a);
b=(int) a;
if (b%7==0)
{
if (b%2!=0)
{
printf ("divisible by 7 and not by 2);
}
else
printf ("Not divisible by 7");
}
getch();
}
- How do you think about the answers? You can sign in to vote the answer.
- iyiogrenciLv 62 decades ago
float n;
int x,y;
printf("Enter a number :");
scanf("%f",&n);
x=n%7;
y=n%2;
if(x != 0) printf("It is not divisible by 7)
else prinft("It is divisible by 7);
if(x != 0) printf("It is not divisible by 2)
else prinft("It is divisible by 2);
Source(s): http://www.pekiyi.150m.com/