#include<stdio.h> #include<conio.h> main() { int i, n, sum; printf("Enter numbers: "); scanf("%d", &n); sum=0; for(i=1; i<=n; i++) sum = sum+i*i; printf("The sum is: %d", sum); getch (); }
#include<stdio.h> #include<conio.h> main() { int i, n, sum; printf("Enter number: "); scanf("%d", &n); um=0; for(i=2; i<=n; i=i+2) sum = sum+i; printf("The sum is: %d", sum); getch(); }
#include<stdio.h> #include<conio.h> main() { int i, n, sum; printf("Enter numbers: "); scanf("%d", &n); sum=0; for(i=1; i<=n; i=i+2) sum = sum+i; printf("The sum is: %d", sum); getch(); }
#include<stdio.h> #include<conio.h> main() { int b, h, area; printf("Enter Base and Height:"); scanf("%d" "%d", &b, &h); area =1/2*b*h; printf("Area is: %.2f", area); getch(); }
#include<stdio.h> #include<conio.h> Main () { Int y; printf (“Enter year :”); scanf (“%d ”, &y); if (y%400==0) printf(“The year is Leap Year”); else if ((y%4==0) && (y%100!=0)) printf(“The year is Leap Year”); else printf(“The year is Not Leap Year”); getch () ; }
#include<stdio.h> #include<conio.h> Main () { Int n; p rintf (“Enter numbers :”); scanf (“%d ”, &n); if (n>0) printf(“The number is positive”); else printf(“The number is negative”); getch () ; }
#include<stdio.h> #include<conio.h> Main () { Int n; p rintf (“Enter numbers :”); scanf (“%d ”, &n); if (n%2==0) printf(“The number is even”); else printf(“The number is odd”); getch () ; }
#include<stdio.h> #include<conio.h> Main () { Int a, b, c; p rintf (“Enter numbers :”); scanf (“%d %d %d”, &a, &b, &c); if ((a<b) && (a<c) printf(“Smallest number is: %d” ,a); else if ( (b<a) && (b<c) ) printf (“Smallest number is: %d” ,b); else printf(“Smallest number is: %d” ,c); getch () ; }
#include<stdio.h> #include<conio.h> Main () { Int a, b, c; p rintf (“Enter numbers :”); scanf (“%d %d %d”, &a, &b, &c); if ((a>b) && (a>c) printf(“Largest number is: %d” ,a); else if ( (b>a) && (b>c) ) printf (“Largest number is: %d” ,b); else printf(“Largest number is: %d” ,c); getch () ; }
#include<stdio.h> #include<conio.h> main () { int x, y, sum, Avg ; printf ("the value of x :"); scanf ("%d" , &x); printf ("the value of y :"); scanf ("%d" , &y); sum=x+y; Avg=sum/2; printf ("the average of two numbers is %d" , Avg); return 0; }
#include<stdio.h> #include<conio.h> main () { int a, b, sum ; printf (''Enter the value of a:"); scanf ("%d", &a); printf (''Enter the value of b:"); scanf ("%d", &b); sum= a+b; printf ("The total is %d", sum); return 0; }