Category: Computer

C programming code to list all factors of n

Share This Topic:     Course Details Field of Study: Computer Science and Engineering Course Name: C Programming Course Description: C programming code to list all factors of n Code #include<stdio.h> #include<conio.h> void main() { clrscr(); int n; printf(“Enter the number\n”); scanf(“%d”,&n); for(int i=1;i<=n;i++) { if(n%i==0) printf(“%d “,i); } getch(); }

C programming code to add all numbers divisible by 3 from 1 to 1000

Share This Topic:     Course Details Field of Study: Computer Science and Engineering Course Name: C Programming Course Description: C programming code to add all numbers divisible by 3 from 1 to 1000 Code #include<stdio.h> #include<conio.h> void main() { clrscr(); float sum=0; for(int i=1;i<=1000;i++) { if(i%3==0) sum=sum+i; } printf(“The sum of all numbers divisible by 3 from

C programming code to display the first n even numbers

Share This Topic:     Course Details Field of Study: Computer Science and Engineering Course Name: C Programming Course Description: C programming code to display the first n even numbers #include<stdio.h> #include<conio.h> void main() { clrscr(); int n; printf(“Enter the number.\n”); scanf(“%d”,&n); for(int i=1;i<=n;i++){ printf(“%d “,2*i); } getch(); }

C programming code to display the first n odd numbers

Share This Topic:     Course Details Field of Study: Computer Science and Engineering Course Name: C Programming Course Description: C programming code to display the first n odd numbers #include<stdio.h> #include<conio.h> void main() { clrscr(); int n; printf(“Enter the number.\n”); scanf(“%d”,&n); for(int i=1;i<=n;i++){ printf(“%d “,(2*i)-1); } getch(); }