0

how to write a c program to display all 2 digit number whose sum of them is 5?

5th Jul 2020, 2:25 PM
narthana wickramasinghe
narthana wickramasinghe - avatar
6 Réponses
+ 3
narthana wickramasinghe It can be done in multiple ways but you should try first. And then show your attempt then we can help you.
5th Jul 2020, 2:30 PM
uday kiran
uday kiran - avatar
+ 1
This is my attempt can you correct that
6th Jul 2020, 1:01 AM
narthana wickramasinghe
narthana wickramasinghe - avatar
0
#include<stdio.h> int main() { int n,sum=1; for(n=1;n<=5;n++){ sum=sum+n; } while(sum==5){ printf("%d",n); } }
6th Jul 2020, 1:00 AM
narthana wickramasinghe
narthana wickramasinghe - avatar
0
narthana wickramasinghe this what I understand from your question for(n=10;n<=50;n++) { dup = n; f_digit= dup%10; dup = dup/10; l_digit= dup%10; if ( f_digit + l_digit == 5) printf("%d\n",n); }
6th Jul 2020, 2:13 AM
uday kiran
uday kiran - avatar
0
Okkkk thankzzz
6th Jul 2020, 2:19 AM
narthana wickramasinghe
narthana wickramasinghe - avatar