0

Program to Count and print those no which are division by 19 in range 1 to 50000 in c language

anyone know then plz post the solution

25th Jul 2018, 2:07 PM
jyo berwal
7 ответов
+ 1
it's same for both c and c++... refer below link for more details: https://www.includehelp.com/c/return-0-from-int-main-in-c-programming.aspx
25th Jul 2018, 3:14 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
for(int i=19;i<=50000;i=i+19) { cout << i << endl; } This is the fastest way to get output as 19 is prime number... simple solution is as below: for(int i=19;i<=50000;++i) { if(i%19==0) {cout << i << endl; } }
25th Jul 2018, 2:31 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
you want all number divisible by 19 between 1 to 50000 , then only for loop is required.. otherwise check number i.e. a in if case is enough... another thing is return type for main... it should be int rather than void
25th Jul 2018, 2:40 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
main is the function which gets called in first... If void is the return type, one cannot return value for failure or success... Your os should get information about failure or success of ur code and that can be achieved by sending 0 or 1... c++ is designed to have this return type as int and not bool... to conclude, it's designated as int main...
25th Jul 2018, 2:52 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
#include<stdio.h> #include<conio.h> Void main() { Int a, i; Printf("enter the number: "); Scanf("%d",&a); for( i=1;i<=50000;I++) { if(a%19==0) Printf (no "%d" is division by 19 ); else Printf ( no "%d" is not division by 19); } getch(); } right or wrong
25th Jul 2018, 2:37 PM
jyo berwal
0
plz tell me the rsn of .....int main
25th Jul 2018, 2:43 PM
jyo berwal
0
m talking about c not c++
25th Jul 2018, 3:04 PM
jyo berwal