Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/ #include <stdio.h> int main() { int X,a,b; scanf("%d", &X); if(X%2==0) { for(a=X+1;a<=X+11;a=a+2) printf("%d\n",a); } else { for(b=X;b<=X+10;b=b+2) printf("%d\n",b); } return 0; }
More simple!
ReplyDeleteint main(){
int num=0;
scanf("%d",&num);
for (int i=1; i<=11; i++){
num++;
if(num%2!=0){
printf("%d\n",num);
}
}
This comment has been removed by the author.
ReplyDelete#include
ReplyDeleteint main()
{
int n;
int i;
int cnt=0;
scanf("%d",&n);
for(i=n; cnt<6; i++){
if(i%2==1){
printf("%d\n",i);
cnt++;
}
}
return 0;
}
why x+11?
ReplyDeletecause you need more 5 odd number like
Deleteif x=2
then x=2+1
if you add 11 you get 5 more odd number 5,7,9,11,13
#include
ReplyDeleteint main()
{
int x,i;
scanf("%d",&x);
if(x%2!=0)
{
for(i=0;i<6;i++)
{
x=x+2;
printf("%d\n",x);
}
}
else
{
x--;
for(i=0;i<6;i++)
{
x=x+2;
printf("%d\n",x);
}
}
return 0;
}