I want to print I love dsvv using if-else.in if part I love and else part dsvv. Is this possible? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

I want to print I love dsvv using if-else.in if part I love and else part dsvv. Is this possible?

By c language

9th Mar 2021, 11:22 AM
Ankit Kumar
Ankit Kumar - avatar
9 Answers
+ 3
For this you may use 2 if statements. or a loop . In a single if-else you can't execute if block & else block at the same time .
9th Mar 2021, 11:28 AM
TOLUENE
TOLUENE - avatar
+ 3
Or loop int a; for(a=1;a<3;a++) { if(a==1) printf("I love"); else printf ("dsvv"); }
9th Mar 2021, 2:49 PM
R YUVARAJ
R YUVARAJ - avatar
+ 2
? why not just print the whole thing in one statement?
9th Mar 2021, 11:23 AM
Slick
Slick - avatar
+ 2
or a loop for(int i=0;i<2;i++){ if(i%2==0) printf("i love"); else printf("bd"); }
9th Mar 2021, 11:32 AM
TOLUENE
TOLUENE - avatar
+ 2
There's no point. It would have to be two seperate if-else statements. Thats the whole point of if-else statements. its this OR that, NOT both
9th Mar 2021, 11:32 AM
Slick
Slick - avatar
11th Mar 2021, 4:25 AM
Ankit Kumar
Ankit Kumar - avatar
+ 2
Ye hai
11th Mar 2021, 4:26 AM
Ankit Kumar
Ankit Kumar - avatar
+ 1
How?
9th Mar 2021, 11:30 AM
Ankit Kumar
Ankit Kumar - avatar
+ 1
if(!printf("I love ")) { Abc; } else { printf("dsvv"); }
3rd Apr 2021, 2:05 AM
Ankit Kumar
Ankit Kumar - avatar